diff options
author | dfr <dfr> | 2000-06-13 15:33:04 +0000 |
---|---|---|
committer | dfr <dfr> | 2000-06-13 15:33:04 +0000 |
commit | a7d68dd330d54fe061a05b308718f57b442faa66 (patch) | |
tree | 1b20e362ebd871524068a6f241cb00996c349625 | |
parent | ee5a915c97aac09db82aa65f01f0c70491217b68 (diff) |
Merge trunk into bsd-1-0-1-branch.bsd-1-0-1-20000613bsd-1-0-1-branch
218 files changed, 47055 insertions, 14235 deletions
diff --git a/xc/config/cf/Imake.tmpl b/xc/config/cf/Imake.tmpl index d4bf580c8..432a3a241 100644 --- a/xc/config/cf/Imake.tmpl +++ b/xc/config/cf/Imake.tmpl @@ -561,6 +561,15 @@ TCLIBDIR = TclLibDir #endif #endif +/* + * SystemUsrLibDir is independent of ProjectRoot. It is used primarily + * to allow links for shared libraries in /usr/lib for compliance to + * various standards (e.g., Linux/OpenGL). + */ +#ifndef SystemUsrLibDir +#define SystemUsrLibDir /usr/lib +#endif + #ifndef ShLibDir #define ShLibDir UsrLibDir #endif @@ -1260,6 +1269,7 @@ TCLIBDIR = TclLibDir INCROOT = IncRoot /* base of where to put header files */ USRLIBDIR = UsrLibDir /* nonshared libraries */ VARLIBDIR = VarLibDir /* xdm runtime files */ + SYSTEMUSRLIBDIR = SystemUsrLibDir /* system's "/usr/lib" */ SHLIBDIR = ShLibDir /* shared libraries */ LINTLIBDIR = LintlibDir /* lint libraries */ MANPATH = ManPath /* top of manual page tree */ diff --git a/xc/config/cf/X11.tmpl b/xc/config/cf/X11.tmpl index 2e2fbf4cf..d55f6eb04 100644 --- a/xc/config/cf/X11.tmpl +++ b/xc/config/cf/X11.tmpl @@ -1422,7 +1422,7 @@ ProjectUnsharedLibReferences(XTHRSTUB,XThrStub,$(XTHRSTUBSRC),XBuildLibDir) #define SharedLibGlx HasSharedLibraries #endif #ifndef NormalLibGlx -#define NormalLibGlx YES +#define NormalLibGlx (!SharedLibX11 | ForceNormalLib) #endif #ifndef DebugLibGlx #define DebugLibGlx NO @@ -1430,6 +1430,9 @@ ProjectUnsharedLibReferences(XTHRSTUB,XThrStub,$(XTHRSTUBSRC),XBuildLibDir) #ifndef ProfileLibGlx #define ProfileLibGlx NO #endif +#ifndef LinkGLToUsrLib +#define LinkGLToUsrLib NO +#endif #endif #ifndef SharedLibXext diff --git a/xc/config/cf/host.def b/xc/config/cf/host.def new file mode 100644 index 000000000..a8e712215 --- /dev/null +++ b/xc/config/cf/host.def @@ -0,0 +1,32 @@ + +#define DefaultGcc2i386Opt -O2 +#define LibraryCDebugFlags -O2 +#define BuildServersOnly YES +#define XF86CardDrivers vga tdfx i810 mga r128 glint +#define LinuxDistribution LinuxRedHat +#define GccWarningOptions -Wall -Wpointer-arith -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wnested-externs +#define DefaultCCOptions -ansi GccWarningOptions -pipe -g +#define NormalLibGlx NO + +#define BuildXF86DRI YES +#define HasGlide3 YES + +/* Optionally turn these on for debugging */ +/* #define GlxBuiltInTdfx YES */ +/* #define GlxBuiltInI810 YES */ +/* #define GlxBuiltInMga YES */ +/* #define GlxBuiltInR128 YES */ +/* #define DoLoadableServer NO */ + +/* Optionally turn this on to change the place where you install the build */ +/* #define ProjectRoot /usr/XF86-main */ + +/* Optionally turn this on to force the kernel modules to build */ +/* #define BuildXF86DRM YES */ + +#define SharedLibFont NO +#define XnestServer NO +#define XVirtualFramebufferServer NO +#define XprtServer NO diff --git a/xc/config/cf/linux.cf b/xc/config/cf/linux.cf index d51ba9785..be7f79931 100644 --- a/xc/config/cf/linux.cf +++ b/xc/config/cf/linux.cf @@ -512,6 +512,10 @@ XCOMM binutils: (LinuxBinUtilsMajorVersion) #define StaticLibrary(libpath,libname) -Wl,-Bstatic Concat(-L,libpath) Concat(-l,libname) -Wl,-Bdynamic #endif +#ifndef LinkGLToUsrLib +#define LinkGLToUsrLib YES +#endif + #define HasGnuMake YES #define MakeNamedTargetSubdir(dir,flags,subname)\ diff --git a/xc/extras/Mesa/include/GL/gl.h b/xc/extras/Mesa/include/GL/gl.h index 03988f43b..f7d1224cf 100644 --- a/xc/extras/Mesa/include/GL/gl.h +++ b/xc/extras/Mesa/include/GL/gl.h @@ -32,113 +32,57 @@ #endif +/********************************************************************** + * Begin system-specific stuff. + */ #if defined(__BEOS__) #include <stdlib.h> /* to get some BeOS-isms */ #endif - #if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO)) #define OPENSTEP #endif - -/* - * XXX move as many of these pragma's and MS Windows-isms into - * the new src/glheader.h file. - */ - #if defined(_WIN32) && !defined(__WIN32__) -# define __WIN32__ +#define __WIN32__ #endif -#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN32__)) -# pragma warning( disable : 4068 ) /* unknown pragma */ -# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ -# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ -# pragma warning( disable : 4127 ) /* conditional expression is constant */ -# if defined(MESA_MINWARN) -# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ -# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ -# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ -# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ -# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ -# endif +#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN__)) # if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ # define GLAPI __declspec(dllexport) -# define WGLAPI __declspec(dllexport) # elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ # define GLAPI __declspec(dllimport) -# define WGLAPI __declspec(dllimport) # else /* for use with static link lib build of Win32 edition only */ # define GLAPI extern -# define WGLAPI __declspec(dllimport) # endif /* _STATIC_MESA support */ # define GLAPIENTRY __stdcall -# define GLAPIENTRYP __stdcall * -# define GLCALLBACK __stdcall -# define GLCALLBACKP __stdcall * -# if defined(__CYGWIN32__) -# define GLCALLBACKPCAST * -# else -# define GLCALLBACKPCAST __stdcall * -# endif -# define GLWINAPI __stdcall -# define GLWINAPIV __cdecl #else /* non-Windows compilation */ # define GLAPI extern # define GLAPIENTRY -# define GLAPIENTRYP * -# define GLCALLBACK -# define GLCALLBACKP * -# define GLCALLBACKPCAST * -# define GLWINAPI -# define GLWINAPIV -#endif /* WIN32 / CYGWIN32 bracket */ - -/* compatability guard so we don't need to change client code */ - -#if defined(_WIN32) && !defined(_WINDEF_) && !defined(OPENSTEP) -# define CALLBACK GLCALLBACK -typedef int (GLAPIENTRY *PROC)(); -typedef void *HGLRC; -typedef void *HDC; -typedef unsigned long COLORREF; -#endif +#endif /* WIN32 / CYGWIN bracket */ -#if defined(_WIN32) && !defined(_WINGDI_) && !defined(OPENSTEP) -# define WGL_FONT_LINES 0 -# define WGL_FONT_POLYGONS 1 -# ifdef UNICODE -# define wglUseFontBitmaps wglUseFontBitmapsW -# define wglUseFontOutlines wglUseFontOutlinesW -# else -# define wglUseFontBitmaps wglUseFontBitmapsA -# define wglUseFontOutlines wglUseFontOutlinesA -# endif /* !UNICODE */ -typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR; -typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT; -typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR; +#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) #include <gl/mesa_wgl.h> #endif -#ifdef __cplusplus -extern "C" { +#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED +#pragma import on #endif +/* + * End system-specific stuff. + **********************************************************************/ -#ifdef macintosh - #pragma enumsalwaysint on - #if PRAGMA_IMPORT_SUPPORTED - #pragma import on - #endif + +#ifdef __cplusplus +extern "C" { #endif #define GL_VERSION_1_1 1 #define GL_VERSION_1_2 1 -#define GL_HAS_GLEXT 1 @@ -1778,14 +1722,93 @@ GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, - /* - * XXX these extensions may eventually be moved into glext.h + * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1) */ +#ifndef GL_ARB_multitexture +#define GL_ARB_multitexture 1 + +#define GL_TEXTURE0_ARB 0x84C0 +#define GL_TEXTURE1_ARB 0x84C1 +#define GL_TEXTURE2_ARB 0x84C2 +#define GL_TEXTURE3_ARB 0x84C3 +#define GL_TEXTURE4_ARB 0x84C4 +#define GL_TEXTURE5_ARB 0x84C5 +#define GL_TEXTURE6_ARB 0x84C6 +#define GL_TEXTURE7_ARB 0x84C7 +#define GL_TEXTURE8_ARB 0x84C8 +#define GL_TEXTURE9_ARB 0x84C9 +#define GL_TEXTURE10_ARB 0x84CA +#define GL_TEXTURE11_ARB 0x84CB +#define GL_TEXTURE12_ARB 0x84CC +#define GL_TEXTURE13_ARB 0x84CD +#define GL_TEXTURE14_ARB 0x84CE +#define GL_TEXTURE15_ARB 0x84CF +#define GL_TEXTURE16_ARB 0x84D0 +#define GL_TEXTURE17_ARB 0x84D1 +#define GL_TEXTURE18_ARB 0x84D2 +#define GL_TEXTURE19_ARB 0x84D3 +#define GL_TEXTURE20_ARB 0x84D4 +#define GL_TEXTURE21_ARB 0x84D5 +#define GL_TEXTURE22_ARB 0x84D6 +#define GL_TEXTURE23_ARB 0x84D7 +#define GL_TEXTURE24_ARB 0x84D8 +#define GL_TEXTURE25_ARB 0x84D9 +#define GL_TEXTURE26_ARB 0x84DA +#define GL_TEXTURE27_ARB 0x84DB +#define GL_TEXTURE28_ARB 0x84DC +#define GL_TEXTURE29_ARB 0x84DD +#define GL_TEXTURE30_ARB 0x84DE +#define GL_TEXTURE31_ARB 0x84DF +#define GL_ACTIVE_TEXTURE_ARB 0x84E0 +#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 +#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 + +GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); +GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); +GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); +GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); +GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); +GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); +GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); +GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); +GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); +GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); +GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); +GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); +GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); +GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); +GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); +GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); +GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); +GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); +GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); +GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); +GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); +GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); + +#endif /* GL_ARB_multitexture */ + + + + +#if defined(GL_GLEXT_LEGACY) /* - * GL_EXT_abgr (number 1) + * 1. GL_EXT_abgr */ #ifndef GL_EXT_abgr #define GL_EXT_abgr 1 @@ -1797,7 +1820,7 @@ GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format, /* - * GL_EXT_blend_color (number 2) + * 2. GL_EXT_blend_color */ #ifndef GL_EXT_blend_color #define GL_EXT_blend_color 1 @@ -1815,7 +1838,7 @@ GLAPI void GLAPIENTRY glBlendColorEXT( GLclampf red, GLclampf green, GLclampf bl /* - * GL_EXT_polygon_offset (number 3) + * 3. GL_EXT_polygon_offset */ #ifndef GL_EXT_polygon_offset #define GL_EXT_polygon_offset 1 @@ -1831,7 +1854,7 @@ GLAPI void GLAPIENTRY glPolygonOffsetEXT( GLfloat factor, GLfloat bias ); /* - * GL_EXT_texture3D (number 6) + * 6. GL_EXT_texture3D */ #ifndef GL_EXT_texture3D #define GL_EXT_texture3D 1 @@ -1858,7 +1881,7 @@ GLAPI void GLAPIENTRY glCopyTexSubImage3DEXT( GLenum target, GLint level, GLint /* - * GL_EXT_texture_object (number 20) + * 20. GL_EXT_texture_object */ #ifndef GL_EXT_texture_object #define GL_EXT_texture_object 1 @@ -1885,7 +1908,7 @@ GLAPI GLboolean GLAPIENTRY glIsTextureEXT( GLuint texture ); /* - * GL_EXT_rescale_normal (number 27) + * 27. GL_EXT_rescale_normal */ #ifndef GL_EXT_rescale_normal #define GL_EXT_rescale_normal 1 @@ -1897,7 +1920,7 @@ GLAPI GLboolean GLAPIENTRY glIsTextureEXT( GLuint texture ); /* - * GL_EXT_vertex_array (number 30) + * 30. GL_EXT_vertex_array */ #ifndef GL_EXT_vertex_array #define GL_EXT_vertex_array 1 @@ -1958,7 +1981,7 @@ GLAPI void GLAPIENTRY glDrawArraysEXT( GLenum mode, GLint first, GLsizei count ) /* - * GL_SGIS_texture_edge_clamp (number 35) + * 35. GL_SGIS_texture_edge_clamp */ #ifndef GL_SGIS_texture_edge_clamp #define GL_SGIS_texture_edge_clamp 1 @@ -1970,7 +1993,7 @@ GLAPI void GLAPIENTRY glDrawArraysEXT( GLenum mode, GLint first, GLsizei count ) /* - * GL_EXT_blend_minmax (number 37) + * 37. GL_EXT_blend_minmax */ #ifndef GL_EXT_blend_minmax #define GL_EXT_blend_minmax 1 @@ -1987,7 +2010,7 @@ GLAPI void GLAPIENTRY glBlendEquationEXT( GLenum mode ); /* - * GL_EXT_blend_subtract (number 38) (requires GL_EXT_blend_max ) + * 38. GL_EXT_blend_subtract (requires GL_EXT_blend_max ) */ #ifndef GL_EXT_blend_subtract #define GL_EXT_blend_subtract 1 @@ -2000,7 +2023,7 @@ GLAPI void GLAPIENTRY glBlendEquationEXT( GLenum mode ); /* - * GL_EXT_blend_logic_op (number 39) + * 39. GL_EXT_blend_logic_op */ #ifndef GL_EXT_blend_logic_op #define GL_EXT_blend_logic_op 1 @@ -2012,7 +2035,7 @@ GLAPI void GLAPIENTRY glBlendEquationEXT( GLenum mode ); /* - * GL_EXT_point_parameters (number 54) + * 54. GL_EXT_point_parameters */ #ifndef GL_EXT_point_parameters #define GL_EXT_point_parameters 1 @@ -2024,47 +2047,15 @@ GLAPI void GLAPIENTRY glBlendEquationEXT( GLenum mode ); GLAPI void GLAPIENTRY glPointParameterfEXT( GLenum pname, GLfloat param ); GLAPI void GLAPIENTRY glPointParameterfvEXT( GLenum pname, const GLfloat *params ); +GLAPI void GLAPIENTRY glPointParameterfSGIS(GLenum pname, GLfloat param); +GLAPI void GLAPIENTRY glPointParameterfvSGIS(GLenum pname, const GLfloat *params); #endif /* GL_EXT_point_parameters */ /* - * GL_PGI_misc_hints (number 77) - */ -#ifndef GL_PGI_misc_hints -#define GL_PGI_misc_hints 1 - -#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 107000 -#define GL_STRICT_DEPTHFUNC_HINT_PGI 107030 -#define GL_STRICT_LIGHTING_HINT_PGI 107031 -#define GL_STRICT_SCISSOR_HINT_PGI 107032 -#define GL_FULL_STIPPLE_HINT_PGI 107033 -#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 107011 -#define GL_NATIVE_GRAPHICS_END_HINT_PGI 107012 -#define GL_CONSERVE_MEMORY_HINT_PGI 107005 -#define GL_RECLAIM_MEMORY_HINT_PGI 107006 -#define GL_ALWAYS_FAST_HINT_PGI 107020 -#define GL_ALWAYS_SOFT_HINT_PGI 107021 -#define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 -#define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 -#define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 -#define GL_ALLOW_DRAW_SPN_HINT_PGI 107024 -#define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 -#define GL_CLIP_NEAR_HINT_PGI 107040 -#define GL_CLIP_FAR_HINT_PGI 107041 -#define GL_WIDE_LINE_HINT_PGI 107042 -#define GL_BACK_NORMALS_HINT_PGI 107043 -#define GL_NATIVE_GRAPHICS_HANDLE_PGI 107010 - -GLAPI void GLAPIENTRY glHintPGI(GLenum target, GLint mode); - -#endif /* GL_PGI_misc_hints */ - - - -/* - * GL_EXT_paletted_texture (number 78) + * 78. GL_EXT_paletted_texture */ #ifndef GL_EXT_paletted_texture #define GL_EXT_paletted_texture 1 @@ -2101,19 +2092,19 @@ GLAPI void GLAPIENTRY glGetColorTableParameterivEXT( GLenum target, GLenum pname /* - * GL_EXT_clip_volume_hint (number 79) + * 79. GL_EXT_clip_volume_hint */ #ifndef GL_EXT_clip_volume_hint #define GL_EXT_clip_volume_hint 1 -#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F +#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0 #endif /* GL_EXT_clip_volume_hint */ /* - * GL_EXT_compiled_vertex_array (number 97) + * 97. GL_EXT_compiled_vertex_array */ #ifndef GL_EXT_compiled_vertex_array #define GL_EXT_compiled_vertex_array 1 @@ -2126,10 +2117,20 @@ GLAPI void GLAPIENTRY glUnlockArraysEXT( void ); #endif /* GL_EXT_compiled_vertex_array */ +/* + * 137. GL_HP_occlusion_test + */ +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 + +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 + +#endif /* GL_HP_occlusion_test */ /* - * GL_EXT_shared_texture_palette (number 141) (req's GL_EXT_paletted_texture) + * 141. GL_EXT_shared_texture_palette (req's GL_EXT_paletted_texture) */ #ifndef GL_EXT_shared_texture_palette #define GL_EXT_shared_texture_palette 1 @@ -2141,7 +2142,7 @@ GLAPI void GLAPIENTRY glUnlockArraysEXT( void ); /* - * GL_EXT_stencil_wrap (number 176) + * 176. GL_EXT_stencil_wrap */ #ifndef GL_EXT_stencil_wrap #define GL_EXT_stencil_wrap 1 @@ -2154,24 +2155,7 @@ GLAPI void GLAPIENTRY glUnlockArraysEXT( void ); /* - * GL_EXT_blend_func_separate (EXT number 173) (aka GL_INGR_blend_func_separate) - */ -#ifndef GL_EXT_blend_func_separate -#define GL_EXT_blend_func_separate 1 - -#define GL_BLEND_DST_RGB_EXT 0x80C8 -#define GL_BLEND_SRC_RGB_EXT 0x80C9 -#define GL_BLEND_DST_ALPHA_EXT 0x80CA -#define GL_BLEND_SRC_ALPHA_EXT 0x80CB - -GLAPI void GLAPIENTRY glBlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha ); - -#endif /* GL_EXT_blend_func_separate */ - - - -/* - * GL_NV_texgen_reflection (number 179) + * 179. GL_NV_texgen_reflection */ #ifndef GL_NV_texgen_reflection #define GL_NV_texgen_reflection 1 @@ -2184,7 +2168,7 @@ GLAPI void GLAPIENTRY glBlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorR /* - * GL_EXT_texture_env_add (number 185) + * 185. GL_EXT_texture_env_add */ #ifndef GL_EXT_texture_env_add #define GL_EXT_texture_env_add 1 @@ -2195,89 +2179,10 @@ GLAPI void GLAPIENTRY glBlendFuncSeparateEXT( GLenum sfactorRGB, GLenum dfactorR -/* - * GL_ARB_multitexture (ARB 0) - */ -#ifndef GL_ARB_multitexture -#define GL_ARB_multitexture 1 - -#define GL_TEXTURE0_ARB 0x84C0 -#define GL_TEXTURE1_ARB 0x84C1 -#define GL_TEXTURE2_ARB 0x84C2 -#define GL_TEXTURE3_ARB 0x84C3 -#define GL_TEXTURE4_ARB 0x84C4 -#define GL_TEXTURE5_ARB 0x84C5 -#define GL_TEXTURE6_ARB 0x84C6 -#define GL_TEXTURE7_ARB 0x84C7 -#define GL_TEXTURE8_ARB 0x84C8 -#define GL_TEXTURE9_ARB 0x84C9 -#define GL_TEXTURE10_ARB 0x84CA -#define GL_TEXTURE11_ARB 0x84CB -#define GL_TEXTURE12_ARB 0x84CC -#define GL_TEXTURE13_ARB 0x84CD -#define GL_TEXTURE14_ARB 0x84CE -#define GL_TEXTURE15_ARB 0x84CF -#define GL_TEXTURE16_ARB 0x84D0 -#define GL_TEXTURE17_ARB 0x84D1 -#define GL_TEXTURE18_ARB 0x84D2 -#define GL_TEXTURE19_ARB 0x84D3 -#define GL_TEXTURE20_ARB 0x84D4 -#define GL_TEXTURE21_ARB 0x84D5 -#define GL_TEXTURE22_ARB 0x84D6 -#define GL_TEXTURE23_ARB 0x84D7 -#define GL_TEXTURE24_ARB 0x84D8 -#define GL_TEXTURE25_ARB 0x84D9 -#define GL_TEXTURE26_ARB 0x84DA -#define GL_TEXTURE27_ARB 0x84DB -#define GL_TEXTURE28_ARB 0x84DC -#define GL_TEXTURE29_ARB 0x84DD -#define GL_TEXTURE30_ARB 0x84DE -#define GL_TEXTURE31_ARB 0x84DF -#define GL_ACTIVE_TEXTURE_ARB 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1 -#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2 - -GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture); -GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture); -GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s); -GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v); -GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s); -GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v); -GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s); -GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v); -GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s); -GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v); -GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t); -GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v); -GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t); -GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v); -GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t); -GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v); -GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t); -GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v); -GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r); -GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v); -GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r); -GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v); -GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r); -GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v); -GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r); -GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v); -GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q); -GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v); -GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q); -GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v); -GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q); -GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v); -GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q); -GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v); - -#endif /* GL_ARB_multitexture */ - /* - * GL_MESA_window_pos (197) + * 197. GL_MESA_window_pos */ #ifndef GL_MESA_window_pos #define GL_MESA_window_pos 1 @@ -2312,7 +2217,7 @@ GLAPI void GLAPIENTRY glWindowPos4dvMESA( const GLdouble *p ); /* - * GL_MESA_resize_bufffers (196) + * 196. GL_MESA_resize_bufffers */ #ifndef GL_MESA_resize_bufffers #define GL_MESA_resize_buffers 1 @@ -2322,52 +2227,27 @@ GLAPI void GLAPIENTRY glResizeBuffersMESA( void ); #endif /* GL_MESA_resize_bufffers */ +#else /* GL_GLEXT_LEGACY */ -/* - * GL_ARB_tranpose_matrix (ARB 2) - */ -#ifndef GL_ARB_transpose_matrix -#define GL_ARB_transpose_matrix 1 - -#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3 -#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4 -#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 -#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 - -GLAPI void GLAPIENTRY glLoadTransposeMatrixdARB( const GLdouble m[16] ); -GLAPI void GLAPIENTRY glLoadTransposeMatrixfARB( const GLfloat m[16] ); -GLAPI void GLAPIENTRY glMultTransposeMatrixdARB( const GLdouble m[16] ); -GLAPI void GLAPIENTRY glMultTransposeMatrixfARB( const GLfloat m[16] ); +#include <GL/glext.h> -#endif /* GL_ARB_tranpose_matrix */ +#endif /* GL_GLEXT_LEGACY */ -/* - * GL_ARB_multisample (ARB 4) +/********************************************************************** + * Begin system-specific stuff */ -#ifndef GL_ARB_multisample -#define GL_ARB_multisample 1 - -GLAPI void GLAPIENTRY glSampleCoverageARB(GLclampf value, GLboolean invert); - -GLAPI void GLAPIENTRY glSamplePassARB(GLenum pass); - -#endif /* GL_ARB_multisample */ - - - #if defined(__BEOS__) || defined(__QUICKDRAW__) #pragma export off #endif - -#ifdef macintosh - #pragma enumsalwaysint reset - #if PRAGMA_IMPORT_SUPPORTED - #pragma import off - #endif +#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED +#pragma import off #endif +/* + * End system-specific stuff + **********************************************************************/ #ifdef __cplusplus diff --git a/xc/extras/Mesa/include/GL/glext.h b/xc/extras/Mesa/include/GL/glext.h index 4c7ccbb2f..0eb4ca49a 100644 --- a/xc/extras/Mesa/include/GL/glext.h +++ b/xc/extras/Mesa/include/GL/glext.h @@ -3,9 +3,10 @@ /* - * XXX Many extensions need to be added yet. * XXX Some token values aren't known (grep for ?) * XXX This file may be automatically generated in the future. + * XXX There are some doubly-defined tokens with different values! Search + * for "DUPLICATE". */ @@ -14,7 +15,7 @@ extern "C" { #endif -#ifdef _WIN32 +#if defined(_WIN32) && !defined(__CYGWIN__) #define WIN32_LEAN_AND_MEAN 1 #include <windows.h> #endif @@ -23,7 +24,7 @@ extern "C" { #define GLAPI extern #endif -#ifdef GLAPIENTRY +#if defined(GLAPIENTRY) && !defined(APIENTRY) #define APIENTRY GLAPIENTRY #endif @@ -32,7 +33,31 @@ extern "C" { #endif -#define GL_GLEXT_VERSION_EXT 1 +/* + * Versions: + * 1. Brian Paul, 24 Feb 2000 + * Intial Version + * 2. Brian Paul, 7 Mar 2000 + * Added GL_HP_occlusion_test, GL_EXT_texture_lod_bias + * 3. Brian Paul, 20 Mar 2000 + * Added all missing extensions up to number 137 + * 4. Brian Paul, 23 Mar 2000 + * Now have all extenions up to number 197 + * 5. Brian Paul, 27 Mar 2000 + * Added GL_ARB_texture_compression + * 6. Brian Paul, 5 Apr 2000 + * Added GL_ARB_multisample tokens, added GL_ARB_texture_env_add + * 7. Brian Paul, 7 Apr 2000 + * Minor clean-ups, temporary token values for GL_SGIS_pixel_texture + * 8. Brian Paul, 15 Apr 2000 + * Added GL_EXT_texture_cube_map, GL_NV_texgen_emboss, adding some + * missing tokens values. + * 9. Brian Paul, 4 May 2000 + * Added a bunch of missing token values. + * 10. Brian Paul, 11 May 2000 + * Added extensions 198 .. 212. + */ +#define GL_GLEXT_VERSION_EXT 10 /* @@ -86,6 +111,65 @@ typedef void (APIENTRY * PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bia /* + * 4. GL_EXT_texture + */ +#ifndef GL_EXT_texture +#define GL_EXT_texture 1 + +#define GL_ALPHA4_EXT 0x803B +#define GL_ALPHA8_EXT 0x803C +#define GL_ALPHA12_EXT 0x803D +#define GL_ALPHA16_EXT 0x803E +#define GL_LUMINANCE4_EXT 0x803F +#define GL_LUMINANCE8_EXT 0x8040 +#define GL_LUMINANCE12_EXT 0x8041 +#define GL_LUMINANCE16_EXT 0x8042 +#define GL_LUMINANCE4_ALPHA4_EXT 0x8043 +#define GL_LUMINANCE6_ALPHA2_EXT 0x8044 +#define GL_LUMINANCE8_ALPHA8_EXT 0x8045 +#define GL_LUMINANCE12_ALPHA4_EXT 0x8046 +#define GL_LUMINANCE12_ALPHA12_EXT 0x8047 +#define GL_LUMINANCE16_ALPHA16_EXT 0x8048 +#define GL_INTENSITY_EXT 0x8049 +#define GL_INTENSITY4_EXT 0x804A +#define GL_INTENSITY8_EXT 0x804B +#define GL_INTENSITY12_EXT 0x804C +#define GL_INTENSITY16_EXT 0x804D +#define GL_RGB2_EXT 0x804E +#define GL_RGB4_EXT 0x804F +#define GL_RGB5_EXT 0x8050 +#define GL_RGB8_EXT 0x8051 +#define GL_RGB10_EXT 0x8052 +#define GL_RGB12_EXT 0x8053 +#define GL_RGB16_EXT 0x8054 +#define GL_RGBA2_EXT 0x8055 +#define GL_RGBA4_EXT 0x8056 +#define GL_RGB5_A1_EXT 0x8057 +#define GL_RGBA8_EXT 0x8058 +#define GL_RGB10_A2_EXT 0x8059 +#define GL_RGBA12_EXT 0x805A +#define GL_RGBA16_EXT 0x805B +#define GL_TEXTURE_RED_SIZE_EXT 0x805C +#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D +#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E +#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F +#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060 +#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061 +#define GL_REPLACE_EXT 0x8062 +#define GL_PROXY_TEXTURE_1D_EXT 0x8063 +#define GL_PROXY_TEXTURE_2D_EXT 0x8064 + +#endif /* GL_EXT_texture */ + + + +/* + * 5. unknown + */ + + + +/* * 6. GL_EXT_texture3D */ #ifndef GL_EXT_texture3D @@ -120,8 +204,8 @@ typedef void (APIENTRY * PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint le #ifndef GL_SGI_texture_filter4 #define GL_SGI_texture_filter4 1 -#define GL_FILTER4_SGIS ? -#define GL_TEXTURE_FILTER4_SIZE_SGIS ? +#define GL_FILTER4_SGIS 0x8146 +#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147 GLAPI void APIENTRY glGetTexFilterFuncSGIS(GLenum target, GLenum filter, GLfloat *weights); GLAPI void APIENTRY glTexFilterFuncSGIS(GLenum target, GLenum filter, GLsizei n, const GLfloat *weights); @@ -134,6 +218,12 @@ typedef void (APIENTRY * PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filt /* + * 8. unknown + */ + + + +/* * 9. GL_EXT_subtexture */ #ifndef GL_EXT_subtexture @@ -299,22 +389,22 @@ typedef void (APIENTRY * PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum i #ifndef GL_SGI_color_table #define GL_SGI_color_table 1 -#define COLOR_TABLE_SGI 0x80D0 -#define POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 -#define POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 -#define PROXY_COLOR_TABLE_SGI 0x80D3 -#define PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 -#define PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 -#define COLOR_TABLE_SCALE_SGI 0x80D6 -#define COLOR_TABLE_BIAS_SGI 0x80D7 -#define COLOR_TABLE_FORMAT_SGI 0x80D8 -#define COLOR_TABLE_WIDTH_SGI 0x80D9 -#define COLOR_TABLE_RED_SIZE_SGI 0x80DA -#define COLOR_TABLE_GREEN_SIZE_SGI 0x80DB -#define COLOR_TABLE_BLUE_SIZE_SGI 0x80DC -#define COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD -#define COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE -#define COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF +#define GL_COLOR_TABLE_SGI 0x80D0 /* DUPLICATE! */ +#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1 +#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2 +#define GL_PROXY_COLOR_TABLE_SGI 0x80D3 +#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4 +#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5 +#define GL_COLOR_TABLE_SCALE_SGI 0x80D6 +#define GL_COLOR_TABLE_BIAS_SGI 0x80D7 +#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8 +#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9 +#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA +#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB +#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC +#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD +#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE +#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF GLAPI void APIENTRY glColorTableParameterfvSGI(GLenum target, GLenum pname, const GLfloat *params); GLAPI void APIENTRY glColorTableParameterivSGI(GLenum target, GLenum pname, const GLint *params); @@ -342,6 +432,9 @@ typedef void (APIENTRY * PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum forma #ifndef GL_SGIX_pixel_texture #define GL_SGIX_pixel_texture 1 +#define GL_PIXEL_TEX_GEN_SGIX 0x8139 +#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B + GLAPI void APIENTRY glPixelTexGenSGIX(GLenum mode); typedef void (APIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); @@ -356,10 +449,10 @@ typedef void (APIENTRY * PFNGLPIXELTEXGENSGIXPROC) (GLenum mode); #ifndef GL_SGIS_pixel_texture #define GL_SGIS_pixel_texture 1 -#define GL_PIXEL_TEXTURE_SGIS ? -#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS ? -#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS ? -#define GL_PIXEL_GROUP_COLOR_SGIS ? +#define GL_PIXEL_TEXTURE_SGIS 0x8353 +#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354 +#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355 +#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356 GLAPI void APIENTRY glPixelTexGenParameterfSGIS(GLenum target, GLfloat value); GLAPI void APIENTRY glPixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value); @@ -385,21 +478,21 @@ typedef void (APIENTRY * PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum target, #ifndef GL_SGIS_texture4D #define GL_SGIS_texture4D 1 -#define GL_PACK_SKIP_VOLUMES_SGIS ? -#define GL_PACK_IMAGE_DEPTH_SGIS ? -#define GL_UNPACK_SKIP_VOLUMES_SGIS ? -#define GL_UNPACK_IMAGE_DEPTH_SGIS ? -#define GL_TEXTURE_4D_SGIS ? -#define GL_PROXY_TEXTURE_4D_SGIS ? -#define GL_TEXTURE_4DSIZE_SGIS ? -#define GL_TEXTURE_WRAP_Q_SGIS ? -#define GL_MAX_4D_TEXTURE_SIZE_SGIS ? -#define GL_TEXTURE_4D_BINDING_SGIS ? - -GLAPI void APIENTRY glTexImage4DSGIS(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels); +#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130 +#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131 +#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132 +#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133 +#define GL_TEXTURE_4D_SGIS 0x8134 +#define GL_PROXY_TEXTURE_4D_SGIS 0x8135 +#define GL_TEXTURE_4DSIZE_SGIS 0x8136 +#define GL_TEXTURE_WRAP_Q_SGIS 0x8137 +#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138 +#define GL_TEXTURE_4D_BINDING_SGIS 0x814F + +GLAPI void APIENTRY glTexImage4DSGIS(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels); GLAPI void APIENTRY glTexSubImage4DSGIS(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void *pixels); -typedef void (APIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels); +typedef void (APIENTRY * PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels); typedef void (APIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLenum format, GLenum type, const void *pixels); #endif /* GL_SGIS_texture4D */ @@ -407,6 +500,40 @@ typedef void (APIENTRY * PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level /* + * 17. GL_SGI_texture_color_table + */ +#ifndef GL_SGI_texture_color_table +#define GL_SGI_texture_color_table 1 + +#define GL_COLOR_TABLE_SGI_80BC 0x80BC /* DUPLICATE! */ +#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD + +#endif /* GL_SGI_texture_color_table */ + + + +/* + * 18. GL_EXT_cmyka + */ +#ifndef GL_EXT_cmyka +#define GL_EXT_cmyka 1 + +#define GL_CMYK_EXT 0x800C +#define GL_CMYKA_EXT 0x800D +#define GL_PACK_CMYK_HINT_EXT 0x800E +#define GL_UNPACK_CMYK_HINT_EXT 0x800F + +#endif /* GL_EXT_cmyka */ + + + +/* + * 19. unknown + */ + + + +/* * 20. GL_EXT_texture_object */ #ifndef GL_EXT_texture_object @@ -497,6 +624,22 @@ typedef void (APIENTRY * PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, /* + * 24. GL_SGIS_texture_lod + */ + +#ifndef GL_SGIS_texture_lod +#define GL_SGIS_texture_lod 1 + +#define GL_TEXTURE_MIN_LOD_SGIS 0x813A +#define GL_TEXTURE_MAX_LOD_SGIS 0x813B +#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C +#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D + +#endif /* GL_SGIS_texture_lod */ + + + +/* * 25. GL_SGIS_multisample */ @@ -532,6 +675,12 @@ typedef void (APIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); /* + * 26. unknown + */ + + + +/* * 27. GL_EXT_rescale_normal */ #ifndef GL_EXT_rescale_normal @@ -544,6 +693,18 @@ typedef void (APIENTRY * PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern); /* + * 28. GLX_EXT_visual_info + */ + + + +/* + * 29. unknown + */ + + + +/* * 30. GL_EXT_vertex_array */ #ifndef GL_EXT_vertex_array @@ -607,6 +768,66 @@ typedef void (APIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GL /* + * 31. GL_EXT_misc_attribute + */ +#ifndef GL_EXT_misc_attribute +#define GL_EXT_misc_attribute 1 + +#define GL_MISC_BIT_EXT ? + +#endif /* GL_EXT_misc_attribute */ + + + +/* + * 32. GL_SGIS_generate_mipmap + */ +#ifndef GL_SGIS_generate_mipmap +#define GL_SGIS_generate_mipmap 1 + +#define GL_GENERATE_MIPMAP_SGIS 0x8191 +#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192 + +#endif /* GL_SGIS_generate_mipmap */ + + + +/* + * 33. GL_SGIX_clipmap + */ +#ifndef GL_SGIX_clipmap +#define GL_SGIX_clipmap 1 + +#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170 +#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171 +#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172 +#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173 +#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174 +#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175 +#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176 +#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177 +#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178 + +#endif /* GL_SGIX_clipmap */ + + + +/* + * 34. GL_SGIX_shadow + */ +#ifndef GL_SGIX_shadow +#define GL_SGIX_shadow 1 + +#define GL_TEXTURE_COMPARE_SGIX 0x819A +#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B +#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C +#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D + +#endif /* GL_SGIX_shadow */ + + + +/* * 35. GL_SGIS_texture_edge_clamp */ #ifndef GL_SGIS_texture_edge_clamp @@ -619,6 +840,18 @@ typedef void (APIENTRY * PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GL /* + * 36. GL_SGIS_texture_border_clamp + */ +#ifndef GL_SGIS_texture_border_clamp +#define GL_SGIS_texture_border_clamp 1 + +#define GL_CLAMP_TO_BORDER_SGIS 0x812D + +#endif /* GL_SGIS_texture_border_clamp */ + + + +/* * 37. GL_EXT_blend_minmax */ #ifndef GL_EXT_blend_minmax @@ -663,6 +896,70 @@ typedef void (APIENTRY * PFNGLBLENDEQUATIONEXTPROC) (GLenum mode); /* + * 40. GLX_SGI_swap_control + * 41. GLX_SGI_video_sync + * 42. GLX_SGI_make_current_read + * 43. GLX_SGIX_video_source + * 44. GLX_EXT_visual_rating + */ + + + +/* + * 45. GL_SGIX_interlace + */ +#ifndef GL_SGIX_interlace +#define GL_SGIX_interlace 1 + +#define GL_INTERLACE_SGIX 0x8094 + +#endif /* GL_SGIX_interlace */ + + + +/* + * 46. unknown + * 47. GLX_EXT_import_context + * 49. GLX_SGIX_fbconfig + * 50. GLX_SGIX_pbuffer + */ + + + +/* + * 51. GL_SGIS_texture_select + */ +#ifndef GL_SGIS_texture_select +#define GL_SGIS_texture_select 1 + +#define GL_DUAL_ALPHA4_SGIS 0x8110 +#define GL_DUAL_ALPHA8_SGIS 0x8111 +#define GL_DUAL_ALPHA12_SGIS 0x8112 +#define GL_DUAL_ALPHA16_SGIS 0x8113 +#define GL_DUAL_LUMINANCE4_SGIS 0x8114 +#define GL_DUAL_LUMINANCE8_SGIS 0x8115 +#define GL_DUAL_LUMINANCE12_SGIS 0x8116 +#define GL_DUAL_LUMINANCE16_SGIS 0x8117 +#define GL_DUAL_INTENSITY4_SGIS 0x8118 +#define GL_DUAL_INTENSITY8_SGIS 0x8119 +#define GL_DUAL_INTENSITY12_SGIS 0x811A +#define GL_DUAL_INTENSITY16_SGIS 0x811B +#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C +#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D +#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124 +#define GL_QUAD_ALPHA4_SGIS 0x811E +#define GL_QUAD_ALPHA8_SGIS 0x811F +#define GL_QUAD_LUMINANCE4_SGIS0 x8120 +#define GL_QUAD_LUMINANCE8_SGIS 0x8121 +#define GL_QUAD_INTENSITY4_SGIS 0x8122 +#define GL_QUAD_INTENSITY8_SGIS 0x8123 +#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125 + +#endif /* GL_SGIS_texture_select */ + + + +/* * 52. GL_SGIX_sprite */ #ifndef GL_SGIX_sprite @@ -691,6 +988,12 @@ typedef void (APIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GL /* + * 53. unknown + */ + + + +/* * 54. GL_EXT_point_parameters */ #ifndef GL_EXT_point_parameters @@ -703,9 +1006,13 @@ typedef void (APIENTRY * PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GL GLAPI void APIENTRY glPointParameterfEXT(GLenum pname, GLfloat param); GLAPI void APIENTRY glPointParameterfvEXT(GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glPointParameterfSGIS(GLenum pname, GLfloat param); +GLAPI void APIENTRY glPointParameterfvSGIS(GLenum pname, const GLfloat *params); typedef void (APIENTRY * PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param); typedef void (APIENTRY * PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param); +typedef void (APIENTRY * PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params); #endif /* GL_EXT_point_parameters */ @@ -734,7 +1041,23 @@ typedef void (APIENTRY * PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker); typedef void (APIENTRY * PFNGLSTARTINSTRUMENTSSGIXPROC) (void); typedef void (APIENTRY * PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker); -#endif +#endif /* GL_SGIX_instruments */ + + + +/* + * 56. GL_SGIX_texture_scale_bias + */ +#ifndef GL_SGIX_texture_scale_bias +#define GL_SGIX_texture_scale_bias 1 + +#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179 +#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A +#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B +#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C + +#endif /* GL_SGIX_texture_scale_bias */ + /* @@ -770,6 +1093,12 @@ typedef void (APIENTRY * PFNGLTAGSAMPLEBUFFERSGIXPROC) (void); /* + * 59. unknown + */ + + + +/* * 60. GL_SGIX_reference_plane */ #ifndef GL_SGIX_reference_plane @@ -801,9 +1130,137 @@ typedef void (APIENTRY * PFNGLFLUSHRASTERSGIXPROC) (void); /* - * 74. GL_EXT_color_subtable + * 62. GLX_SGI_cushion + */ + + + +/* + * 63. GL_SGIX_depth_texture + */ +#ifndef GL_SGIX_depth_texture +#define GL_SGIX_depth_texture 1 + +#define GL_DEPTH_COMPONENT16_SGIX 0x81A5 +#define GL_DEPTH_COMPONENT24_SGIX 0x81A6 +#define GL_DEPTH_COMPONENT32_SGIX 0x81A7 + +#endif /* GL_SGIX_depth_texture */ + + + +/* + * 64. GL_SGIS_fog_function + */ +#ifndef GL_SGIS_fog_function +#define GL_SGIS_fog_function 1 + +#define GL_FOG_FUNC_SGIS 0x812A +#define GL_FOG_FUNC_POINTS_SGIS 0x812B +#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C + +#endif /* GL_SGIS_fog_function */ + + + +/* + * 65. GL_SGIX_fog_offset + */ +#ifndef GL_SGIX_fog_offset +#define GL_SGIX_fog_offset 1 + +#define GL_FOG_OFFSET_SGIX 0x8198 +#define GL_FOG_OFFSET_VALUE_SGIX 0x8199 + +#endif /* GL_SGIX_fog_offset */ + + + +/* + * 66. GL_HP_image_transform + */ +#ifndef GL_HP_image_transform +#define GL_HP_image_transform 1 + +#define GL_IMAGE_SCALE_X_HP 0x8155 +#define GL_IMAGE_SCALE_Y_HP 0x8156 +#define GL_IMAGE_TRANSLATE_X_HP 0x8157 +#define GL_IMAGE_TRANSLATE_Y_HP 0x8158 +#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159 +#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A +#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B +#define GL_IMAGE_MAG_FILTER_HP 0x815C +#define GL_IMAGE_MIN_FILTER_HP 0x815D +#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E +#define GL_CUBIC_HP 0x815F +#define GL_AVERAGE_HP 0x8160 +#define GL_IMAGE_TRANSFORM_2D_HP 0x8161 +#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162 +#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163 + +GLAPI void APIENTRY glImageTransformParameteriHP(GLenum target, GLenum pname, const GLint param); +GLAPI void APIENTRY glImageTransformParameterfHP(GLenum target, GLenum pname, const GLfloat param); +GLAPI void APIENTRY glImageTransformParameterivHP(GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glImageTransformParameterfvHP(GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY GetImageTransformParameterivHP(GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetImageTransformParameterfvHP(GLenum target, GLenum pname,const GLfloat* params); + +typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, const GLint param); +typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, const GLfloat param); +typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERIVHPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params); +typedef void (APIENTRY * PFNGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params); +typedef void (APIENTRY * PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname,const GLfloat* params); + +#endif /* GL_HP_image_transform */ + + + +/* + * 67. GL_HP_convolution_border_modes + */ +#ifndef GL_HP_convolution_border_modes +#define GL_HP_convolution_border_modes 1 + +#define GL_IGNORE_BORDER_HP 0x8150 +#define GL_CONSTANT_BORDER_HP 0x8151 +#define GL_REPLICATE_BORDER_HP 0x8153 +#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154 + +#endif /* GL_HP_convolution_border_modes */ + + + +/* + * 68. unknown */ + + +/* + * 69. GL_SGIX_texture_add_env + */ +#ifndef GL_SGIX_texture_add_env +#define GL_SGIX_texture_add_env 1 + +#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE + +#endif /* GL_SGIX_texture_add_env */ + + + +/* + * 70. unknown + * 71. unknown + * 72. unknown + * 73. unknown + */ + + + +/* + * 74. GL_EXT_color_subtable + */ #ifndef GL_EXT_color_subtable #define GL_EXT_color_subtable 1 @@ -813,7 +1270,47 @@ GLAPI void APIENTRY glCopyColorSubTableEXT(GLenum target, GLsizei start, GLint x typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const void *data); typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); -#endif +#endif /* GL_EXT_color_subtable */ + + + +/* + * 75. GLU_EXT_object_space_tess + */ + + + +/* + * 76. GL_PGI_vertex_hints + */ +#ifndef GL_PGI_vertex_hints +#define GL_PGI_vertex_hints 1 + +#define GL_VERTEX_DATA_HINT_PGI 107050 +#define GL_VERTEX_CONSISTENT_HINT_PGI 107051 +#define GL_VATERIAL_SIDE_HINT_PGI 107052 +#define GL_VAX_VERTEX_HINT_PGI 107053 +#define GL_VOLOR3_BIT_PGI 0x00010000 +#define GL_VOLOR4_BIT_PGI 0x00020000 +#define GL_VDGEFLAG_BIT_PGI 0x00040000 +#define GL_VNDEX_BIT_PGI 0x00080000 +#define GL_VAT_AMBIENT_BIT_PGI 0x00100000 +#define GL_VAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000 +#define GL_VAT_DIFFUSE_BIT_PGI 0x00400000 +#define GL_VAT_EMISSION_BIT_PGI 0x00800000 +#define GL_VAT_COLOR_INDEXES_BIT_PGI 0x01000000 +#define GL_VAT_SHININESS_BIT_PGI 0x02000000 +#define GL_VAT_SPECULAR_BIT_PGI 0x04000000 +#define GL_VORMAL_BIT_PGI 0x08000000 +#define GL_VEXCOORD1_BIT_PGI 0x10000000 +#define GL_VEXCOORD2_BIT_PGI 0x20000000 +#define GL_VEXCOORD3_BIT_PGI 0x40000000 +#define GL_VEXCOORD4_BIT_PGI 0x80000000 +#define GL_VERTEX23_BIT_PGI 0x00000004 +#define GL_VERTEX4_BIT_PGI 0x00000008 + +#endif /* GL_PGI_vertex_hints */ + /* @@ -836,7 +1333,6 @@ typedef void (APIENTRY * PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei #define GL_ALLOW_DRAW_OBJ_HINT_PGI 107022 #define GL_ALLOW_DRAW_WIN_HINT_PGI 107023 #define GL_ALLOW_DRAW_FRG_HINT_PGI 107024 -#define GL_ALLOW_DRAW_SPN_HINT_PGI 107024 #define GL_ALLOW_DRAW_MEM_HINT_PGI 107025 #define GL_CLIP_NEAR_HINT_PGI 107040 #define GL_CLIP_FAR_HINT_PGI 107041 @@ -882,7 +1378,9 @@ GLAPI void APIENTRY glGetColorTableParameterfvEXT(GLenum target, GLenum pname, G GLAPI void APIENTRY glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint *params); typedef void (APIENTRY * PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); +#ifndef GL_EXT_color_subtable typedef void (APIENTRY * PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); +#endif typedef void (APIENTRY * PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table); typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params); typedef void (APIENTRY * PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params); @@ -930,14 +1428,72 @@ typedef void (APIENTRY * PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum name /* + * 81. GL_SGIX_ir_instrument1 + */ +#ifndef GL_SGIX_ir_instrument1 +#define GL_SGIX_ir_instrument1 1 + +#define GL_IR_INSTRUMENT1_SGIX 0x817F + +#endif /* GL_SGIX_ir_instrument1 */ + + + +/* + * 82. unknown + * 83. GLX_SGIX_video_resize + */ + + + +/* + * 84. GL_SGIX_texture_lod_bias + */ +#ifndef GL_SGIX_texture_lod_bias +#define GL_SGIX_texture_lod_bias 1 + +#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E +#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F +#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190 + +#endif /* GL_SGIX_texture_lod_bias */ + + + +/* + * 85. GLU_SGI_filter4_parameters + * 86. GLX_SGIX_dm_buffer + * 87. unknown + * 88. unknown + * 89. unknown + * 90. unknown + * 91. GLX_SGIX_swap_group + * 92. GLX_SGIX_swap_barrier + */ + + + +/* + * 93. GL_EXT_index_texture + */ +#ifndef GL_EXT_index_texture +#define GL_EXT_index_texture 1 + +/* No new tokens or functions */ + +#endif /* GL_EXT_index_texture */ + + + +/* * 94. GL_EXT_index_material */ #ifndef GL_EXT_index_material #define GL_EXT_index_material 1 -#define GL_INDEX_MATERIAL_EXT ? -#define GL_INDEX_MATERIAL_PARAMETER_EXT ? -#define GL_INDEX_MATERIAL_FACE_EXT ? +#define GL_INDEX_MATERIAL_EXT 0x81B8 +#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9 +#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA GLAPI void APIENTRY glIndexMaterialEXT(GLenum face, GLenum mode); @@ -953,9 +1509,9 @@ typedef void (APIENTRY * PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode); #ifndef GL_EXT_index_func #define GL_EXT_index_func 1 -#define GL_INDEX_TEST_EXT ? -#define GL_INDEX_TEST_FUNC_EXT ? -#define GL_INDEX_TEST_REF_EXT ? +#define GL_INDEX_TEST_EXT 0x81B5 +#define GL_INDEX_TEST_FUNC_EXT 0x81B6 +#define GL_INDEX_TEST_REF_EXT 0x81B7 GLAPI void APIENTRY glIndexFuncEXT(GLenum func, GLfloat ref); @@ -966,6 +1522,25 @@ typedef void (APIENTRY * PFNGLINDEXFUNCEXTPROC) (GLenum func, GLfloat ref); /* + * 96. GL_EXT_index_array_formats + */ +#ifndef GL_EXT_index_array_formats +#define GL_EXT_index_array_formats 1 + +#define GL_IUI_V2F_EXT 0x81AD +#define GL_IUI_V3F_EXT 0x81AE +#define GL_IUI_N3F_V2F_EXT 0x81AF +#define GL_IUI_N3F_V3F_EXT 0x81B0 +#define GL_T2F_IUI_V2F_EXT 0x81B1 +#define GL_T2F_IUI_V3F_EXT 0x81B2 +#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3 +#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4 + +#endif /* GL_EXT_index_array_formats */ + + + +/* * 97. GL_EXT_compiled_vertex_array */ #ifndef GL_EXT_compiled_vertex_array @@ -1005,6 +1580,26 @@ typedef void (APIENTRY * PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat* pa /* + * 99. unknown + * 100. GLU_EXT_nurbs_tessellator + */ + + + +/* + * 101. GL_SGIX_ycrcb + */ +#ifndef GL_SGIX_ycrcb +#define GL_SGIX_ycrcb 1 + +#define GL_YCRCB_422_SGIX 0x81BB +#define GL_YCRCB_444_SGIX 0x81BC + +#endif /* GL_SGIX_ycrcb */ + + + +/* * 102. GL_SGIX_fragment_lighting */ #ifndef GL_SGIX_fragment_lighting @@ -1053,6 +1648,161 @@ typedef void (APIENTRY * PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); /* + * 103. unknown + * 104. unknown + * 105. unknown + * 106. unknown + * 107. unknown + * 108. unknown + * 109. unknown + */ + + + +/* + * 110. GL_IBM_rasterpos_clip + */ +#ifndef GL_IBM_rasterpos_clip +#define GL_IBM_rasterpos_clip 1 + +#endif /* GL_IBM_rasterpos_clip */ + + + +/* + * 111. GL_HP_texture_lighting + */ +#ifndef GL_HP_texture_lighting +#define GL_HP_texture_lighting 1 + +#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167 +#define GL_TEXTURE_POST_SPECULAR_HP 0x8168 +#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169 + +#endif /* GL_HP_texture_lighting */ + + + +/* + * 112. GL_EXT_draw_range_elements + */ +#ifndef GL_EXT_draw_range_elements +#define GL_EXT_draw_range_elements 1 + +#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8 +#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9 + +GLAPI void APIENTRY glDrawRangeElementsEXT(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); + +typedef void (APIENTRY * PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices); + +#endif /* GL_EXT_draw_range_elements */ + + + +/* + * 113. GL_WIN_phong_shading + */ +#ifndef GL_WIN_phong_shading +#define GL_WIN_phong_shading 1 + +#define GL_PHONG_WIN 0x80EA +#define GL_PHONG_HINT_WIN 0x80EB + +#endif /* GL_WIN_phong_shading */ + + + +/* + * 114. GL_WIN_specular_fog + */ +#ifndef GL_WIN_specular_fog +#define GL_WIN_specular_fog 1 + +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC +#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC + +#endif /* GL_WIN_specular_fog */ + + + +/* + * 115. unknown + * 116. unknown + */ + + + +/* + * 117. GL_EXT_light_texture + */ +#ifndef GL_EXT_light_texture +#define GL_EXT_light_texture 1 + +#define GL_FRAGMENT_MATERIAL_EXT 0x8349 +#define GL_FRAGMENT_NORMAL_EXT 0x834A + +#define GL_FRAGMENT_DEPTH_EXT_834B 0x834B /* DUPLICATE! */ +#define GL_FRAGMENT_COLOR_EXT 0x834C +#define GL_ATTENUATION_EXT 0x834D +#define GL_SHADOW_ATTENUATION_EXT 0x834E +#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F +#define GL_TEXTURE_LIGHT_EXT 0x8350 +#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351 +#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352 + +GLAPI void APIENTRY glApplyTextureEXT(GLenum mode); +GLAPI void APIENTRY glTextureLightEXT(GLenum pname); +GLAPI void APIENTRY glTextureMaterialEXT(GLenum face, GLenum mode); + +typedef void (APIENTRY * PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode); +typedef void (APIENTRY * PFNGLTEXTURELIGHTEXTPROC) (GLenum pname); +typedef void (APIENTRY * PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode); + +#endif /* GL_EXT_light_texture */ + + + +/* + * 118. unknown + */ + + + +/* + * 119. GL_SGIX_blend_alpha_minmax + */ +#ifndef GL_SGIX_blend_alpha_minmax +#define GL_SGIX_blend_alpha_minmax 1 + +#endif /* GL_SGIX_blend_alpha_minmax */ + + + +/* + * 120. GL_EXT_scene_marker + */ +#ifndef GL_EXT_scene_marker +#define GL_EXT_scene_marker 1 + +#endif /* GL_EXT_scene_marker */ + + + +/* + * 121. unknown + * 122. unknown + * 123. unknown + * 124. unknown + * 125. unknown + * 126. unknown + * 127. unknown + * 128. unknown + */ + + + +/* * 129. GL_EXT_bgra */ #ifndef GL_EXT_bgra @@ -1066,6 +1816,122 @@ typedef void (APIENTRY * PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); /* + * 130. unknown + * 131. unknown + * 132. unknown + * 133. unknown + * 134. unknown + */ + + + +/* + * 135. GL_INTEL_texture_scissor + */ +#ifndef GL_INTEL_texture_scissor +#define GL_INTEL_texture_scissor 1 + +#define GL_TEXTURE_SCISSOR_INTEL ? +#define GL_TEXTURE_SCISSOR_S_INTEL ? +#define GL_TEXTURE_SCISSOR_T_INTEL ? +#define GL_TEXTURE_SCISSOR_R_INTEL ? + +GLAPI void APIENTRY glTexScissorINTEL(GLenum target, GLclampf tlow, GLclampf thigh); +GLAPI void APIENTRY glTexScissorFuncINTEL(GLenum target, GLenum lfunc, GLenum hfunc); + +typedef void (APIENTRY * PFNGLTEXSCISSORINTELPROC) (GLenum target, GLclampf tlow, GLclampf thigh); +typedef void (APIENTRY * PFNGLTEXSCISSORFUNCINTELPROC) (GLenum target, GLenum lfunc, GLenum hfunc); + +#endif /* GL_INTEL_texture_scissor */ + + + +/* + * 136. GL_INTEL_parallel_arrays + */ +#ifndef GL_INTEL_parallel_arrays +#define GL_INTEL_parallel_arrays 1 + +#define GL_PARALLEL_ARRAYS_INTEL 0x83F4 +#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5 +#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6 +#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7 +#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8 + +GLAPI void APIENTRY glVertexPointervINTEL(GLint size, GLenum type, const void ** pointer); +GLAPI void APIENTRY glNormalPointervINTEL(GLenum type, const void** pointer); +GLAPI void APIENTRY glColorPointervINTEL(GLint size, GLenum type, const void** pointer); +GLAPI void APIENTRY glTexCoordPointervINTEL(GLint size, GLenum type, const void** pointer); + +typedef void (APIENTRY * PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const void ** pointer); +typedef void (APIENTRY * PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const void** pointer); +typedef void (APIENTRY * PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); +typedef void (APIENTRY * PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const void** pointer); + +#endif /* GL_INTEL_parallel_arrays */ + + + +/* + * 137. GL_HP_occlusion_test + */ +#ifndef GL_HP_occlusion_test +#define GL_HP_occlusion_test 1 + +#define GL_OCCLUSION_TEST_HP 0x8165 +#define GL_OCCLUSION_TEST_RESULT_HP 0x8166 + +#endif /* GL_HP_occlusion_test */ + + + +/* + * 138. GL_EXT_pixel_transform + */ +#ifndef GL_EXT_pixel_transform +#define GL_EXT_pixel_transform 1 + +#define GL_PIXEL_MAG_FILTER_EXT 0x8331 +#define GL_PIXEL_MIN_FILTER_EXT 0x8332 +#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333 +#define GL_CUBIC_EXT 0x8334 +#define GL_AVERAGE_EXT 0x8335 +#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330 +#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336 +#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337 +#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338 + +GLAPI void APIENTRY glPixelTransformParameteriEXT(GLenum target, GLenum pname, const GLint param); +GLAPI void APIENTRY glPixelTransformParameterfEXT(GLenum target, GLenum pname, const GLfloat param); +GLAPI void APIENTRY glPixelTransformParameterivEXT(GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glPixelTransformParameterfvEXT(GLenum target, GLenum pname, const GLfloat *params); +GLAPI void APIENTRY glGetPixelTransformParameterivEXT(GLenum target, GLenum pname, const GLint *params); +GLAPI void APIENTRY glGetPixelTransformParameterfvEXT(GLenum target, GLenum pname, const GLfloat *params); + +#endif /* GL_EXT_pixel_transform */ + + + +/* + * 139. GL_EXT_pixel_transform_color_table + */ +#ifndef GL_EXT_pixel_transform_color_table +#define GL_EXT_pixel_transform_color_table 1 + +#define GL_PIXEL_TRANSFORM_COLOR_TABLE_EXT ? +#define GL_PROXY_PIXEL_TRANSFORM_COLOR_TABLE_EXT ? + +#endif /* GL_EXT_pixel_transform_color_table */ + + + +/* + * 140. unknown + */ + + + +/* * 141. GL_EXT_shared_texture_palette (req's GL_EXT_paletted_texture) */ #ifndef GL_EXT_shared_texture_palette @@ -1078,6 +1944,147 @@ typedef void (APIENTRY * PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); /* + * 142. unknown + * 143. unknown + */ + + + +/* + * 144. GL_EXT_separate_specular_color + */ +#ifndef GL_EXT_separate_specular_color +#define GL_EXT_separate_specular_color 1 + +#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8 +#define GL_SINGLE_COLOR_EXT 0x81F9 +#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA + +#endif /* GL_EXT_separate_specular_color */ + + + +/* + * 145. GL_EXT_secondary_color + */ +#ifndef GL_EXT_secondary_color +#define GL_EXT_secondary_color 1 + +#define GL_COLOR_SUM_EXT 0x8458 +#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459 +#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A +#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B +#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C +#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D +#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E + +GLAPI void APIENTRY glSecondaryColor3bEXT(GLbyte red, GLbyte green, GLbyte blue); +GLAPI void APIENTRY glSecondaryColor3dEXT(GLdouble red, GLdouble green, GLdouble blue); +GLAPI void APIENTRY glSecondaryColor3fEXT(GLfloat red, GLfloat green, GLfloat blue); +GLAPI void APIENTRY glSecondaryColor3iEXT(GLint red, GLint green, GLint blue); +GLAPI void APIENTRY glSecondaryColor3sEXT(GLshort red, GLshort green, GLshort blue); +GLAPI void APIENTRY glSecondaryColor3ubEXT(GLubyte red, GLubyte green, GLubyte blue); +GLAPI void APIENTRY glSecondaryColor3uiEXT(GLuint red, GLuint green, GLuint blue); +GLAPI void APIENTRY glSecondaryColor3usEXT(GLushort red, GLushort green, GLushort blue); +GLAPI void APIENTRY glSecondaryColor4bEXT(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha); +GLAPI void APIENTRY glSecondaryColor4dEXT(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha); +GLAPI void APIENTRY glSecondaryColor4fEXT(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +GLAPI void APIENTRY glSecondaryColor4iEXT(GLint red, GLint green, GLint blue, GLint alpha); +GLAPI void APIENTRY glSecondaryColor4sEXT(GLshort red, GLshort green, GLshort blue, GLshort alpha); +GLAPI void APIENTRY glSecondaryColor4ubEXT(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); +GLAPI void APIENTRY glSecondaryColor4uiEXT(GLuint red, GLuint green, GLuint blue, GLuint alpha); +GLAPI void APIENTRY glSecondaryColor4usEXT(GLushort red, GLushort green, GLushort blue, GLushort alpha); +GLAPI void APIENTRY glSecondaryColor3bvEXT(const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor3dvEXT(const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor3fvEXT(const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor3ivEXT(const GLint *v); +GLAPI void APIENTRY glSecondaryColor3svEXT(const GLshort *v); +GLAPI void APIENTRY glSecondaryColor3ubvEXT(const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor3uivEXT(const GLuint *v); +GLAPI void APIENTRY glSecondaryColor3usvEXT(const GLushort *v); +GLAPI void APIENTRY glSecondaryColor4bvEXT(const GLbyte *v); +GLAPI void APIENTRY glSecondaryColor4dvEXT(const GLdouble *v); +GLAPI void APIENTRY glSecondaryColor4fvEXT(const GLfloat *v); +GLAPI void APIENTRY glSecondaryColor4ivEXT(const GLint *v); +GLAPI void APIENTRY glSecondaryColor4svEXT(const GLshort *v); +GLAPI void APIENTRY glSecondaryColor4ubvEXT(const GLubyte *v); +GLAPI void APIENTRY glSecondaryColor4uivEXT(const GLuint *v); +GLAPI void APIENTRY glSecondaryColor4usvEXT(const GLushort *v); +GLAPI void APIENTRY glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride, GLvoid *pointer); + +#endif /* GL_EXT_secondary_color */ + + + +/* + * 146. GL_EXT_texture_env + */ +#ifndef GL_EXT_texture_env +#define GL_EXT_texture_env 1 + +#define GL_TEXTURE_ENV0_EXT 0x? +#define GL_TEXTURE_ENV1_EXT (GL_TEXTURE_ENV0_EXT+1) +#define GL_TEXTURE_ENV2_EXT (GL_TEXTURE_ENV0_EXT+2) +#define GL_TEXTURE_ENV3_EXT (GL_TEXTURE_ENV0_EXT+3) +#define GL_TEXTURE_ENV4_EXT (GL_TEXTURE_ENV0_EXT+4) +#define GL_TEXTURE_ENV5_EXT (GL_TEXTURE_ENV0_EXT+5) +#define GL_TEXTURE_ENV6_EXT (GL_TEXTURE_ENV0_EXT+6) +#define GL_TEXTURE_ENV7_EXT (GL_TEXTURE_ENV0_EXT+7) +#define GL_TEXTURE_ENV8_EXT (GL_TEXTURE_ENV0_EXT+8) +#define GL_TEXTURE_ENV9_EXT (GL_TEXTURE_ENV0_EXT+9) +#define GL_TEXTURE_ENV10_EXT (GL_TEXTURE_ENV0_EXT+10) +#define GL_TEXTURE_ENV11_EXT (GL_TEXTURE_ENV0_EXT+11) +#define GL_TEXTURE_ENV12_EXT (GL_TEXTURE_ENV0_EXT+12) +#define GL_TEXTURE_ENV13_EXT (GL_TEXTURE_ENV0_EXT+13) +#define GL_TEXTURE_ENV14_EXT (GL_TEXTURE_ENV0_EXT+14) +#define GL_TEXTURE_ENV15_EXT (GL_TEXTURE_ENV0_EXT+15) +#define GL_TEXTURE_ENV_MODE_ALPHA_EXT 0x? +#define GL_ENV_COPY_EXT 0x? +#define GL_ENV_REPLACE_EXT 0x? +#define GL_ENV_MODULATE_EXT 0x? +#define GL_ENV_ADD_EXT 0x? +#define GL_ENV_SUBTRACT_EXT 0x? +#define GL_ENV_REVERSE_SUBTRACT_EXT 0x? +#define GL_ENV_BLEND_EXT 0x? +#define GL_ENV_REVERSE_BLEND_EXT 0x? +#define GL_TEXTURE_ENV_SHIFT_EXT 0x? + +#endif /* GL_EXT_texture_env */ + + + +/* + * 147. GL_EXT_texture_perturb_normal + */ +#ifndef GL_EXT_texture_perturb_normal +#define GL_EXT_texture_perturb_normal 1 + +#define GL_PERTURB_EXT 0x85AE +#define GL_TEXTURE_NORMAL_EXT 0x85AF + +GLAPI void APIENTRY glTextureNormalEXT(GLenum mode); + +typedef void (APIENTRY * PFNGLTEXTURENORMALEXT) (GLenum mode); + +#endif /* GL_EXT_texture_perturb_normal */ + + + +/* + * 148. GL_EXT_multi_draw_arrays + */ +#ifndef GL_EXT_multi_draw_arrays +#define GL_EXT_multi_draw_arrays 1 + +GLAPI void APIENTRY glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); + +typedef void (APIENTRY * PFNGLMULTIDRAWARRAYSEXT) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); + +#endif /* GL_EXT_multi_draw_arrays */ + + + +/* * 149. GL_EXT_fog_coord */ #ifndef GL_EXT_fog_coord @@ -1085,7 +2092,7 @@ typedef void (APIENTRY * PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param); #define GL_FOG_COORDINATE_SOURCE_EXT 0x8450 #define GL_FOG_COORDINATE_EXT 0x8451 -#define GL_FRAGMENT_DEPTH_EXT 0x8452 +#define GL_FRAGMENT_DEPTH_EXT 0x8452 /* DUPLICATE! */ #define GL_CURRENT_FOG_COORDINATE_EXT 0x8453 #define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454 #define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455 @@ -1109,6 +2116,106 @@ typedef void (APIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stri /* + * 150. unknown + * 151. unknown + * 152. unknown + * 153. unknown + * 154. unknown + */ + + + +/* + * 155. GL_REND_screen_coordinates + */ +#ifndef GL_REND_screen_coordinates +#define GL_REND_screen_coordinates 1 + +#define GL_SCREEN_COORDINATES_REND 0x8490 +#define GL_INVERTED_SCREEN_W_REND 0x8491 + +#endif /* GL_REND_screen_coordinates */ + + + +/* + * 156. GL_EXT_coordinate_frame + */ +#ifndef GL_EXT_coordinate_frame +#define GL_EXT_coordinate_frame 1 + +#define GL_TANGENT_ARRAY_EXT 0x8439 +#define GL_BINORMAL_ARRAY_EXT 0x843A +#define GL_CURRENT_TANGENT_EXT 0x843B +#define GL_CURRENT_BINORMAL_EXT 0x843C +#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E +#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F +#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440 +#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441 +#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442 +#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443 +#define GL_MAP1_TANGENT_EXT 0x8444 +#define GL_MAP2_TANGENT_EXT 0x8445 +#define GL_MAP1_BINORMAL_EXT 0x8446 +#define GL_MAP2_BINORMAL_EXT 0x8447 + +GLAPI void APIENTRY glTangent3bEXT(GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glTangent3dEXT(GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glTangent3fEXT(GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTangent3iEXT(GLint x, GLint y, GLint z); +GLAPI void APIENTRY glTangent3sEXT(GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glTangent3bvEXT(const GLbyte *v); +GLAPI void APIENTRY glTangent3dvEXT(const GLdouble *v); +GLAPI void APIENTRY glTangent3fvEXT(const GLfloat *v); +GLAPI void APIENTRY glTangent3ivEXT(const GLint *v); +GLAPI void APIENTRY glTangent3svEXT(const GLshort *v); +GLAPI void APIENTRY glBinormal3bEXT(GLbyte x, GLbyte y, GLbyte z); +GLAPI void APIENTRY glBinormal3dEXT(GLdouble x, GLdouble y, GLdouble z); +GLAPI void APIENTRY glBinormal3fEXT(GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glBinormal3iEXT(GLint x, GLint y, GLint z); +GLAPI void APIENTRY glBinormal3sEXT(GLshort x, GLshort y, GLshort z); +GLAPI void APIENTRY glBinormal3bvEXT(const GLbyte *v); +GLAPI void APIENTRY glBinormal3dvEXT(const GLdouble *v); +GLAPI void APIENTRY glBinormal3fvEXT(const GLfloat *v); +GLAPI void APIENTRY glBinormal3ivEXT(const GLint *v); +GLAPI void APIENTRY glBinormal3svEXT(const GLshort *v); +GLAPI void APIENTRY glTangentPointerEXT(GLenum type, GLsizei stride, GLvoid *pointer); +GLAPI void APIENTRY glBinormalPointerEXT(GLenum type, GLsizei stride, GLvoid *pointer); + +typedef void (APIENTRY * PFNGLTANGENT3BEXT) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRY * PFNGLTANGENT3DEXT) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRY * PFNGLTANGENT3FEXT) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTANGENT3IEXT) (GLint x, GLint y, GLint z); +typedef void (APIENTRY * PFNGLTANGENT3SEXT) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRY * PFNGLTANGENT3BVEXT) (const GLbyte *v); +typedef void (APIENTRY * PFNGLTANGENT3DVEXT) (const GLdouble *v); +typedef void (APIENTRY * PFNGLTANGENT3FVEXT) (const GLfloat *v); +typedef void (APIENTRY * PFNGLTANGENT3IVEXT) (const GLint *v); +typedef void (APIENTRY * PFNGLTANGENT3SVEXT) (const GLshort *v); +typedef void (APIENTRY * PFNGLBINORMAL3BEXT) (GLbyte x, GLbyte y, GLbyte z); +typedef void (APIENTRY * PFNGLBINORMAL3DEXT) (GLdouble x, GLdouble y, GLdouble z); +typedef void (APIENTRY * PFNGLBINORMAL3FEXT) (GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLBINORMAL3IEXT) (GLint x, GLint y, GLint z); +typedef void (APIENTRY * PFNGLBINORMAL3SEXT) (GLshort x, GLshort y, GLshort z); +typedef void (APIENTRY * PFNGLBINORMAL3BVEXT) (const GLbyte *v); +typedef void (APIENTRY * PFNGLBINORMAL3DVEXT) (const GLdouble *v); +typedef void (APIENTRY * PFNGLBINORMAL3FVEXT) (const GLfloat *v); +typedef void (APIENTRY * PFNGLBINORMAL3IVEXT) (const GLint *v); +typedef void (APIENTRY * PFNGLBINORMAL3SVEXT) (const GLshort *v); +typedef void (APIENTRY * PFNGLTANGENTPOINTEREXT) (GLenum type, GLsizei stride, GLvoid *pointer); +typedef void (APIENTRY * PFNGLBINORMALPOINTEREXT) (GLenum type, GLsizei stride, GLvoid *pointer); + +#endif /* GL_EXT_coordinate_frame */ + + + +/* + * 157. unknown + */ + + + +/* * 158. GL_EXT_texture_env_combine */ #ifndef GL_EXT_texture_env_combine @@ -1141,6 +2248,232 @@ typedef void (APIENTRY * PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stri /* + * 159. GL_APPLE_specular_vector + */ +#ifndef GL_APPLE_specular_vector +#define GL_APPLE_specular_vector 1 + +#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0 + +#endif /* GL_APPLE_specular_vector */ + + + +/* + * 160. GL_APPLE_transform_hint + */ +#ifndef GL_APPLE_transform_hint +#define GL_APPLE_transform_hint 1 + +#define GL_TRANSFORM_HINT_APPLE 0x85B1 + +#endif /* GL_APPLE_transform_hint */ + + + +/* + * 161. unknown + * 162. unknown + */ + + + +/* + * 163. GL_SUNX_constant_data + */ +#ifndef GL_SUNX_constant_data +#define GL_SUNX_constant_data 1 + +#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5 +#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6 + +GLAPI void APIENTRY glFinishTextureSUNX(void); + +typedef void (APIENTRY * PFNGLFINISHTEXTURESUNX) (void); + +#endif /* GL_SUNX_constant_data */ + + + +/* + * 164. GL_SUN_global_alpha + */ +#ifndef GL_SUN_global_alpha +#define GL_SUN_global_alpha 1 + +#define GL_GLOBAL_ALPHA_SUN 0x81D9 +#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA + +GLAPI void APIENTRY glGlobalAlphaFactorbSUN(GLbyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorsSUN(GLshort factor); +GLAPI void APIENTRY glGlobalAlphaFactoriSUN(GLint factor); +GLAPI void APIENTRY glGlobalAlphaFactorfSUN(GLfloat factor); +GLAPI void APIENTRY glGlobalAlphaFactordSUN(GLdouble factor); +GLAPI void APIENTRY glGlobalAlphaFactorubSUN(GLubyte factor); +GLAPI void APIENTRY glGlobalAlphaFactorusSUN(GLushort factor); +GLAPI void APIENTRY glGlobalAlphaFactoruiSUN(GLuint factor); + +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORBSUN) (GLbyte factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORSSUN) (GLshort factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORISUN) (GLint factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORFSUN) (GLfloat factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORDSUN) (GLdouble factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUBSUN) (GLubyte factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUSSUN) (GLushort factor); +typedef void (APIENTRY * PFNGLGLOBALALPHAFACTORUISUN) (GLuint factor); + +#endif /* GL_SUN_global_alpha */ + + + +/* + * 165. GL_SUN_triangle_list + */ +#ifndef GL_SUN_triangle_list +#define GL_SUN_triangle_list 1 + +#define GL_TRIANGLE_LIST_SUN 0x81D7 +#define GL_REPLACEMENT_CODE_SUN 0x81D8 +#define GL_RESTART_SUN 0x01 +#define GL_REPLACE_MIDDLE_SUN 0x02 +#define GL_REPLACE_OLDEST_SUN 0x03 +#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0 +#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1 +#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2 +#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3 +#define GL_R1UI_V3F_SUN 0x85C4 +#define GL_R1UI_C4UB_V3F_SUN 0x85C5 +#define GL_R1UI_C3F_V3F_SUN 0x85C6 +#define GL_R1UI_N3F_V3F_SUN 0x85C7 +#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8 +#define GL_R1UI_T2F_V3F_SUN 0x85C9 +#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA +#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB + +GLAPI void APIENTRY glReplacementCodeuiSUN(GLuint code); +GLAPI void APIENTRY glReplacementCodeusSUN(GLushort code); +GLAPI void APIENTRY glReplacementCodeubSUN(GLubyte code); +GLAPI void APIENTRY glReplacementCodeuivSUN(const GLuint *code); +GLAPI void APIENTRY glReplacementCodeusvSUN(const GLushort *code); +GLAPI void APIENTRY glReplacementCodeubvSUN(const GLubyte *code); +GLAPI void APIENTRY glReplacementCodePointerSUN(GLenum type, GLsizei stride, const GLvoid *pointer); + +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUISUN) (GLuint code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUSSUN) (GLushort code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUBSUN) (GLubyte code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVSUN) (const GLuint *code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUSVSUN) (const GLushort *code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUBVSUN) (const GLubyte *code); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEPOINTERSUN) (GLenum type, GLsizei stride, const GLvoid *pointer); + +#endif /* GL_SUN_triangle_list */ + + + +/* + * 166. GL_SUN_vertex + */ +#ifndef GL_SUN_vertex +#define GL_SUN_vertex 1 + +GLAPI void APIENTRY glColor4ubVertex2fSUN(GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +GLAPI void APIENTRY glColor4ubVertex2fvSUN(const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor4ubVertex3fSUN(GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4ubVertex3fvSUN(const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glColor3fVertex3fSUN(GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor3fVertex3fvSUN(const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glNormal3fVertex3fSUN(GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glNormal3fVertex3fvSUN(const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN(GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN(const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fVertex3fSUN(GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fVertex3fvSUN(const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fVertex4fSUN(GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fVertex4fvSUN(const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN(GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN(const GLfloat *tc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN(GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN(const GLfloat *tc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN(GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN(const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN(GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN(const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN(GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN(const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN(GLuint rc, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN(const GLuint *rc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN(GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN(const GLuint *rc, const GLubyte *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN(GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN(const GLuint *rc, const GLfloat *c, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN(GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN(const GLuint *rc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN(GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN(const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN(GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN(const GLuint *rc, const GLfloat *tc, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN(GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN(const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN(GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN(const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); + +typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX2FSUN) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y); +typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX2FVSUN) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX3FSUN) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLCOLOR4UBVERTEX3FVSUN) (const GLubyte *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLCOLOR3FVERTEX3FSUN) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLCOLOR3FVERTEX3FVSUN) (const GLfloat *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLNORMAL3FVERTEX3FSUN) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLNORMAL3FVERTEX3FVSUN) (const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FSUN) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLCOLOR4FNORMAL3FVERTEX3FVSUN) (const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FVERTEX3FSUN) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FVERTEX3FVSUN) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD4FVERTEX4FSUN) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLTEXCOORD4FVERTEX4FVSUN) (const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUN) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUN) (const GLfloat *tc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUN) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUN) (const GLfloat *tc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUN) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUN) (const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUN) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUN) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUN) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w); +typedef void (APIENTRY * PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUN) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FSUN) (GLuint rc, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUIVERTEX3FVSUN) (const GLuint *rc, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUN) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUN) (const GLuint *rc, const GLubyte *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUN) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUN) (const GLuint *rc, const GLfloat *c, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUN) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUN) (const GLuint *rc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUN) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUN) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUN) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUN) (const GLuint *rc, const GLfloat *tc, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUN) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUN) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUN) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z); +typedef void (APIENTRY * PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUN) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v); + +#endif /* GL_SUN_vertex */ + + + +/* + * 167. WGL_EXT_display_color_table + * 168. WGL_EXT_extensions_string + * 169. WGL_EXT_make_current_read + * 170. WGL_EXT_pixel_format + * 171. WGL_EXT_pbuffer + * 172. WGL_EXT_swap_control + */ + + + +/* * 173. GL_EXT_blend_func_separate */ #ifndef GL_EXT_blend_func_separate @@ -1179,6 +2512,45 @@ typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLe /* + * 174. GL_INGR_color_clamp + */ +#ifndef GL_INGR_color_clamp +#define GL_INGR_color_clamp 1 + +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 +#define GL_RED_MIN_CLAMP_INGR 0x8560 +#define GL_GREEN_MIN_CLAMP_INGR 0x8561 +#define GL_BLUE_MIN_CLAMP_INGR 0x8562 +#define GL_ALPHA_MIN_CLAMP_INGR 0x8563 +#define GL_RED_MAX_CLAMP_INGR 0x8564 +#define GL_GREEN_MAX_CLAMP_INGR 0x8565 +#define GL_BLUE_MAX_CLAMP_INGR 0x8566 +#define GL_ALPHA_MAX_CLAMP_INGR 0x8567 + +#endif /* GL_INGR_color_clamp */ + + + +/* + * 175. GL_INGR_interlace_read + */ +#ifndef GL_INGR_interlace_read +#define GL_INGR_interlace_read 1 + +#define GL_INTERLACE_READ_INGR 0x8568 + +#endif /* GL_INGR_interlace_read */ + + + +/* * 176. GL_EXT_stencil_wrap */ #ifndef GL_EXT_stencil_wrap @@ -1192,6 +2564,27 @@ typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLe /* + * 177. WGL_EXT_depth_float + */ + + + +/* + * 178. GL_EXT_422_pixels + */ +#ifndef GL_EXT_422_pixels +#define GL_EXT_422_pixels 1 + +#define GL_422_EXT 0x80CC +#define GL_422_REV_EXT 0x80CD +#define GL_422_AVERAGE_EXT 0x80CE +#define GL_422_REV_AVERAGE_EXT 0x80CF + +#endif /* GL_EXT_422_pixels */ + + + +/* * 179. GL_NV_texgen_reflection */ #ifndef GL_NV_texgen_reflection @@ -1205,6 +2598,32 @@ typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLe /* + * 180. unknown + * 181. unknown + */ + + + +/* + * 182. GL_SUN_convolution_border_modes + */ +#ifndef GL_SUN_convolution_border_modes +#define GL_SUN_convolution_border_modes 1 + +#define GL_WRAP_BORDER_SUN 0x81D4 + +#endif /* GL_SUN_convolution_border_modes */ + + + +/* + * 183. GLX_SUN_transparent_index + * 184. unknown + */ + + + +/* * 185. GL_EXT_texture_env_add */ #ifndef GL_EXT_texture_env_add @@ -1217,16 +2636,28 @@ typedef void (APIENTRY * PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLe /* - * ??. GL_WIN_swap_hint + * 186. GL_EXT_texture_lod_bias */ -#ifndef GL_WIN_swap_hint -#define GL_WIN_swap_hint 1 +#ifndef GL_EXT_texture_lod_bias +#define GL_EXT_texture_lod_bias 1 -GLAPI void APIENTRY glAddSwapHintRectWIN(GLint x, GLint y, GLsizei width, GLsizei height); +#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500 +#define GL_TEXTURE_LOD_BIAS_EXT 0x8501 -typedef void (APIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); +#endif /* GL_EXT_texture_lod_bias */ -#endif /* GL_WIN_swap_hint */ + + +/* + * 187. GL_EXT_texture_filter_anisotropic + */ +#ifndef GL_EXT_texture_filter_anisotropic +#define GL_EXT_texture_filter_anisotropic 1 + +#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE +#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF + +#endif /* GL_EXT_texture_filter_anisotropic */ @@ -1238,12 +2669,12 @@ typedef void (APIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei #define GL_VERTEX_WEIGHTING_EXT 0x8509 #define GL_MODELVIEW0_EXT 0x1700 -#define GL_MODELVIEW1_EXT 0x850a -#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850b -#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850c -#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850d -#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850e -#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850f +#define GL_MODELVIEW1_EXT 0x850A +#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B +#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C +#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D +#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E +#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F #define GL_MODELVIEW0_STACK_DEPTH_EXT 0x0BA3 #define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502 #define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510 @@ -1256,7 +2687,7 @@ typedef void (APIENTRY * PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight); typedef void (APIENTRY * PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight); typedef void (APIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer); -#endif +#endif /* GL_EXT_vertex_weighting */ @@ -1269,7 +2700,7 @@ typedef void (APIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum ty #define GL_MAX_SHININESS_NV 0x8507 #define GL_MAX_SPOT_EXPONENT_NV 0x8508 -#endif +#endif /* GL_NV_light_max_exponent */ @@ -1279,14 +2710,19 @@ typedef void (APIENTRY * PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLint size, GLenum ty #ifndef GL_NV_vertex_array_range #define GL_NV_vertex_array_range 1 -/* TOKENS? */ +#define GL_VERTEX_ARRAY_RANGE_NV 0x851D +#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E +#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F +#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520 +#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521 GLAPI void APIENTRY glFlushVertexArrayRangeNV(void); GLAPI void APIENTRY glVertexArrayRangeNV(GLsizei size, const GLvoid * pointer); typedef void (APIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); +typedef void (APIENTRY * PFNGLVERTEXARRAYRANGENV) (GLsizei size, const GLvoid * pointer); -#endif +#endif /* GL_NV_vertex_array_range */ @@ -1296,7 +2732,57 @@ typedef void (APIENTRY * PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void); #ifndef GL_NV_register_combiners #define GL_NV_register_combiners 1 -/* TOKENS? */ +#define GL_REGISTER_COMBINERS_NV 0x8522 +#define GL_COMBINER0_NV 0x8550 +#define GL_COMBINER1_NV 0x8551 +#define GL_COMBINER2_NV 0x8552 +#define GL_COMBINER3_NV 0x8553 +#define GL_COMBINER4_NV 0x8554 +#define GL_COMBINER5_NV 0x8555 +#define GL_COMBINER6_NV 0x8556 +#define GL_COMBINER7_NV 0x8557 +#define GL_VARIABLE_A_NV 0x8523 +#define GL_VARIABLE_B_NV 0x8524 +#define GL_VARIABLE_C_NV 0x8525 +#define GL_VARIABLE_D_NV 0x8526 +#define GL_VARIABLE_E_NV 0x8527 +#define GL_VARIABLE_F_NV 0x8528 +#define GL_VARIABLE_G_NV 0x8529 +#define GL_CONSTANT_COLOR0_NV 0x852A +#define GL_CONSTANT_COLOR1_NV 0x852B +#define GL_PRIMARY_COLOR_NV 0x852C +#define GL_SECONDARY_COLOR_NV 0x852D +#define GL_SPARE0_NV 0x852E +#define GL_SPARE1_NV 0x852F +#define GL_UNSIGNED_IDENTITY_NV 0x8536 +#define GL_UNSIGNED_INVERT_NV 0x8537 +#define GL_EXPAND_NORMAL_NV 0x8538 +#define GL_EXPAND_NEGATE_NV 0x8539 +#define GL_HALF_BIAS_NORMAL_NV 0x853A +#define GL_HALF_BIAS_NEGATE_NV 0x853B +#define GL_SIGNED_IDENTITY_NV 0x853C +#define GL_SIGNED_NEGATE_NV 0x853D +#define GL_E_TIMES_F_NV 0x8531 +#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532 +#define GL_SCALE_BY_TWO_NV 0x853E +#define GL_SCALE_BY_FOUR_NV 0x853F +#define GL_SCALE_BY_ONE_HALF_NV 0x8540 +#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541 +#define GL_DISCARD_NV 0x8530 +#define GL_COMBINER_INPUT_NV 0x8542 +#define GL_COMBINER_MAPPING_NV 0x8543 +#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544 +#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545 +#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546 +#define GL_COMBINER_MUX_SUM_NV 0x8547 +#define GL_COMBINER_SCALE_NV 0x8548 +#define GL_COMBINER_BIAS_NV 0x8549 +#define GL_COMBINER_AB_OUTPUT_NV 0x854A +#define GL_COMBINER_CD_OUTPUT_NV 0x854B +#define GL_COMBINER_SUM_OUTPUT_NV 0x854C +#define GL_NUM_GENERAL_COMBINERS_NV 0x854E +#define GL_COLOR_SUM_CLAMP_NV 0x854F +#define GL_MAX_GENERAL_COMBINERS_NV 0x854D #ifdef VMS /*VMS only allows externals of maximal 31 characters! */ @@ -1345,15 +2831,21 @@ typedef void (APIENTRY * PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum va #ifndef GL_NV_fog_distance #define GL_NV_fog_distance 1 -#define GL_FOG_DISTANCE_MODE_NV 0x855a -#define GL_EYE_RADIAL_NV 0x855b -#define GL_EYE_PLANE_ABSOLUTE_NV 0x855c +#define GL_FOG_DISTANCE_MODE_NV 0x855A +#define GL_EYE_RADIAL_NV 0x855B +#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C #endif /* GL_NV_fog_distance*/ /* + * 193. unknown + */ + + + +/* * 194. GL_NV_blend_square */ #ifndef GL_NV_blend_square @@ -1455,7 +2947,196 @@ typedef void (APIENTRY * PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *p); /* - * ARB 0. GL_ARB_multitexture + * 198. GL_EXT_texture_compression_s3tc + */ +#ifndef GL_EXT_texture_compression_s3tc +#define GL_EXT_texture_compression_s3tc 1 + +#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 +#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 +#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2 +#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3 + +#endif /* GL_EXT_texture_compression_s3tc */ + + + +/* + * 199. GL_IBM_cull_vertex + */ +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 + +#define GL_CULL_VERTEX_IBM 103050 + +#endif /* GL_IBM_cull_vertex */ + + +/* + * 200. GL_IBM_multimode_draw_arrays + */ +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 + +GLAPI void APIENTRY glMultiModeDrawArraysIBM(GLenum *mode, GLint *first, GLsizei *count, GLsizei primcount, GLint modestride); +GLAPI void APIENTRY glMultiModeDrawElementsIBM(GLenum *mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount, GLint modestride); + +typedef void (APIENTRY * PFNGLGLMULTIMODEDRAWARRAYSIBMPROC) (GLenum *mode, GLint *first, GLsizei *count, GLsizei primcount, GLint modestride); +typedef void (APIENTRY * PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (GLenum *mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount, GLint modestride); + +#endif /* GL_IBM_multimode_draw_arrays */ + + + +/* + * 201. GL_IBM_vertex_array_lists + */ +#ifndef GL_IBM_multimode_draw_arrays +#define GL_IBM_multimode_draw_arrays 1 + +#define GL_VERTEX_ARRAY_LIST_IBM 103070 +#define GL_NORMAL_ARRAY_LIST_IBM 103071 +#define GL_COLOR_ARRAY_LIST_IBM 103072 +#define GL_INDEX_ARRAY_LIST_IBM 103073 +#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074 +#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075 +#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076 +#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077 +#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080 +#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081 +#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082 +#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083 +#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084 +#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085 +#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086 +#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087 + +GLAPI void APIENTRY glColorPointerListIBM(GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glSecondaryColorPointerListIBM(GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glEdgeFlagPointerListIBM(GLint stride, const GLboolean **pointer, GLint ptrstride); +GLAPI void APIENTRY glFogCoordPointerListIBM(GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glIndexPointerListIBM(GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glNormalPointerListIBM(GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glTexCoordPointerListIBM(GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +GLAPI void APIENTRY glVertexPointerListIBM(GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); + +typedef void (APIENTRY * PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean **pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); +typedef void (APIENTRY * PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid **pointer, GLint ptrstride); + +#endif /* GL_IBM_multimode_draw_arrays */ + + + +/* + * 202. ? + * 203. ? + * 204. ? + * 205. ? + */ + + +/* + * 206. GL_3DFX_texture_compression_FXT1 + */ +#ifndef GL_3DFX_texture_compression_FXT1 +#define GL_3DFX_texture_compression_FXT1 1 + +#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0 +#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1 + +#endif /* GL_3DFX_texture_compression_FXT1 */ + + + +/* + * 207. GL_3DFX_multisample + */ +#ifndef GL_3DFX_multisample +#define GL_3DFX_multisample 1 + +#define GL_MULTISAMPLE_3DFX 0x86B2 +#define GL_SAMPLE_BUFFERS_3DFX 0x86B3 +#define GL_SAMPLES_3DFX 0x86B4 +#define GL_MULTISAMPLE_BIT_3DFX 0x20000000 + +#endif /* GL_3DFX_multisample */ + + + +/* + * 208. GL_3DFX_tbuffer + */ +#ifndef GL_3DFX_tbuffer +#define GL_3DFX_tbuffer 1 + +GLAPI void APIENTRY glTbufferMask3DFX(GLuint mask); + +typedef void (APIENTRY * PFNGLTBUFFERMASK3DFXPROC) (GLuint mask ); + +#endif /* GL_3DFX_tbuffer */ + + + +/* + * 209. WGL_EXT_multisample + */ +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 + +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 +#define GL_MULTISAMPLE_EXT 0x809D +#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F +#define GL_SAMPLE_MASK_EXT 0x80A0 + +GLAPI void APIENTRY glSampleMaskEXT(GLclampf value, GLboolean invert); +GLAPI void APIENTRY glSamplePatternEXT(GLenum pattern); + +typedef void (APIENTRY * PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert); +typedef void (APIENTRY * PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern); + +#endif /* WGL_EXT_multisample */ + + + +/* + * 210. GL_SGIX_vertex_preclip + */ +#ifndef GL_SGIX_vertex_preclip +#define GL_SGIX_vertex_preclip 1 + +#define GL_VERTEX_PRECLIP_SGIX 0x83EE +#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF + +#endif /* GL_SGIX_vertex_preclip */ + + + +/* + * 212. GL_SGIX_resample + */ +#ifndef GL_SGIX_resample +#define GL_SGIX_resample 1 + +#define GL_PACK_RESAMPLE_SGIX 0x842E +#define GL_UNPACK_RESAMPLE_SGIX 0x842F +#define GL_RESAMPLE_REPLICATE_SGIX 0x8433 +#define GL_RESAMPLE_ZERO_FILL_SGIX 0x8434 +#define GL_RESAMPLE_DECIMATE_SGIX 0x0 /*?*/ + +#endif /* GL_SGIX_resample */ + + + +/* + * ARB 1. GL_ARB_multitexture */ #ifndef GL_ARB_multitexture #define GL_ARB_multitexture 1 @@ -1571,7 +3252,12 @@ typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLs /* - * ARB 2. GL_ARB_tranpose_matrix + * ARB 2. GLX_ARB_get_proc_address + */ + + +/* + * ARB 3. GL_ARB_tranpose_matrix */ #ifndef GL_ARB_transpose_matrix #define GL_ARB_transpose_matrix 1 @@ -1581,10 +3267,10 @@ typedef void (APIENTRY * PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLs #define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5 #define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6 -GLAPI void APIENTRY glLoadTransposeMatrixdARB( const GLdouble m[16] ); -GLAPI void APIENTRY glLoadTransposeMatrixfARB( const GLfloat m[16] ); -GLAPI void APIENTRY glMultTransposeMatrixdARB( const GLdouble m[16] ); -GLAPI void APIENTRY glMultTransposeMatrixfARB( const GLfloat m[16] ); +GLAPI void APIENTRY glLoadTransposeMatrixdARB(const GLdouble m[16]); +GLAPI void APIENTRY glLoadTransposeMatrixfARB(const GLfloat m[16]); +GLAPI void APIENTRY glMultTransposeMatrixdARB(const GLdouble m[16]); +GLAPI void APIENTRY glMultTransposeMatrixfARB(const GLfloat m[16]); typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXDARBPROC) ( const GLdouble m[16] ); typedef void (APIENTRY * PFNGLLOADTRANSPOSEMATRIXFARBPROC) ( const GLfloat m[16] ); @@ -1596,11 +3282,37 @@ typedef void (APIENTRY * PFNGLMULTTRANSPOSEMATRIXFARBPROC) ( const GLfloat m[16] /* - * ARB 4. GL_ARB_multisample + * ARB 4. WGL_ARB_buffer_region + */ + + + +/* + * ARB 5. GL_ARB_multisample */ #ifndef GL_ARB_multisample #define GL_ARB_multisample 1 +#define GL_MULTISAMPLE_ARBfunda 0x809D +#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E +#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F +#define GL_SAMPLE_COVERAGE_ARB 0x80A0 +#define GL_MULTISAMPLE_BIT_ARB 0x20000000 +#define GL_1PASS_ARB 0x80A1 +#define GL_2PASS_0_ARB 0x80A2 +#define GL_2PASS_1_ARB 0x80A3 +#define GL_4PASS_0_ARB 0x80A4 +#define GL_4PASS_1_ARB 0x80A5 +#define GL_4PASS_2_ARB 0x80A6 +#define GL_4PASS_3_ARB 0x80A7 +#define GL_SAMPLE_BUFFERS_ARB 0x80A8 +#define GL_SAMPLES_ARB 0x80A9 +#define GL_SAMPLE_MAX_PASSES_ARB 0x84E7 +#define GL_SAMPLE_PASS_ARB 0x84E8 +#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA +#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB +/* Note: there are more tokens for GLX and WGL */ + GLAPI void APIENTRY glSamplePassARB(GLenum pass); GLAPI void APIENTRY glSampleCoverageARB(GLclampf value, GLboolean invert); @@ -1611,6 +3323,158 @@ typedef void (APIENTRY * PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean +/* + * ARB 6. GL_ARB_texture_env_add + */ +#ifndef GL_ARB_texture_env_add +#define GL_ARB_texture_env_add 1 + +/* No new tokens or functions */ + +#endif /* GL_ARB_texture_env_add */ + + + +/* + * ARB 7. GL_ARB_texture_cube_map + */ +#ifndef GL_ARB_texture_cube_map +#define GL_ARB_texture_cube_map 1 + +#define GL_NORMAL_MAP_ARB 0x8511 +#define GL_REFLECTION_MAP_ARB 0x8512 +#define GL_TEXTURE_CUBE_MAP_ARB 0x8513 +#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518 +#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519 +#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A +#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B +#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C + +#endif /* GL_ARB_texture_cube_map */ + + + +/* + * ARB 8. WGL_ARB_extensions_string + * ARB 9. WGL_ARB_pixel_format + * ARB 10. WGL_ARB_make_current_read + * ARB 11. WGL_ARB_pbuffer + */ + + + +/* + * ARB 12. GL_ARB_texture_compression + */ +#ifndef GL_ARB_texture_compression +#define GL_ARB_texture_compression 1 + +#define GL_COMPRESSED_ALPHA_ARB 0x84E9 +#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA +#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB +#define GL_COMPRESSED_INTENSITY_ARB 0x84EC +#define GL_COMPRESSED_RGB_ARB 0x84ED +#define GL_COMPRESSED_RGBA_ARB 0x84EE +#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF +#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0 +#define GL_TEXTURE_COMPRESSED_ARB 0x86A1 +#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2 +#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3 + +GLAPI void APIENTRY glCompressedTexImage3DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage2DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexImage1DARB(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glCompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +GLAPI void APIENTRY glGetCompressedTexImageARB(GLenum target, GLint lod, GLvoid *img); + +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data); +typedef void (APIENTRY * PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint lod, GLvoid *img); + +#endif /* GL_ARB_texture_compression */ + + + +/* + * ? GL_NV_texgen_emboss + */ + +#ifndef GL_NV_texgen_emboss +#define GL_NV_texgen_emboss 1 + +#define GL_EMBOSS_MAP_NV 0x855F +#define GL_EMBOSS_LIGHT_NV 0x855D +#define GL_EMBOSS_CONSTANT_NV 0x855E + +#endif /* GL_NV_texgen_emboss */ + + + +/* + * ?. GL_WIN_swap_hint + */ +#ifndef GL_WIN_swap_hint +#define GL_WIN_swap_hint 1 + +GLAPI void APIENTRY glAddSwapHintRectWIN(GLint x, GLint y, GLsizei width, GLsizei height); + +typedef void (APIENTRY * PFNGLADDSWAPHINTRECTWINPROC) (GLint x, GLint y, GLsizei width, GLsizei height); + +#endif /* GL_WIN_swap_hint */ + + + +/* + * ?. GL_IBM_cull_vertex + */ +#ifndef GL_IBM_cull_vertex +#define GL_IBM_cull_vertex 1 + +#define GL_CULL_VERTEX_IBM 0x1928A + +#endif /* GL_IBM_cull_vertex */ + + + +/* + * ?. GL_IBM_static_data + */ +#ifndef GL_IBM_static_data +#define GL_IBM_static_data 1 + +#define GL_ALL_STATIC_DATA_IBM 0x19294 +#define GL_STATIC_VERTEX_ARRAY_IBM 0x19295 + +GLAPI void APIENTRY glFlushStaticDataIBM(GLenum target); + +typedef void (APIENTRY * PFNGLFLUSHSTATICDATAIBM) (GLenum target); + +#endif /* GL_IBM_static_data */ + + + +/* + * ?. GL_IBM_texture_mirrored_repeat + */ +#ifndef GL_IBM_texture_mirrored_repeat +#define GL_IBM_texture_mirrored_repeat 1 + +#define GL_MIRRORED_REPEAT_IBM 0x8370 + +#endif /* GL_IBM_texture_mirrored_repeat */ + + + #ifdef __cplusplus } #endif diff --git a/xc/extras/Mesa/include/GL/osmesa.h b/xc/extras/Mesa/include/GL/osmesa.h new file mode 100644 index 000000000..c3bc43d0c --- /dev/null +++ b/xc/extras/Mesa/include/GL/osmesa.h @@ -0,0 +1,246 @@ + +/* + * Mesa 3-D graphics library + * Version: 3.3 + * + * Copyright (C) 1999-2000 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. + */ + + +/* + * Mesa Off-Screen rendering interface. + * + * This is an operating system and window system independent interface to + * Mesa which allows one to render images into a client-supplied buffer in + * main memory. Such images may manipulated or saved in whatever way the + * client wants. + * + * These are the API functions: + * OSMesaCreateContext - create a new Off-Screen Mesa rendering context + * OSMesaMakeCurrent - bind an OSMesaContext to a client's image buffer + * and make the specified context the current one. + * OSMesaDestroyContext - destroy an OSMesaContext + * OSMesaGetCurrentContext - return thread's current context ID + * OSMesaPixelStore - controls how pixels are stored in image buffer + * OSMesaGetIntegerv - return OSMesa state parameters + * + * + * The limits on the width and height of an image buffer are MAX_WIDTH and + * MAX_HEIGHT as defined in Mesa/src/config.h. Defaults are 1280 and 1024. + * You can increase them as needed but beware that many temporary arrays in + * Mesa are dimensioned by MAX_WIDTH or MAX_HEIGHT. + */ + + +#ifndef OSMESA_H +#define OSMESA_H + + +#ifdef __cplusplus +extern "C" { +#endif + + +#include "GL/gl.h" + + +#define OSMESA_MAJOR_VERSION 3 +#define OSMESA_MINOR_VERSION 3 + + + +/* + * Values for the format parameter of OSMesaCreateContext() + * New in version 2.0. + */ +#define OSMESA_COLOR_INDEX GL_COLOR_INDEX +#define OSMESA_RGBA GL_RGBA +#define OSMESA_BGRA 0x1 +#define OSMESA_ARGB 0x2 +#define OSMESA_RGB GL_RGB +#define OSMESA_BGR 0x4 + + +/* + * OSMesaPixelStore() parameters: + * New in version 2.0. + */ +#define OSMESA_ROW_LENGTH 0x10 +#define OSMESA_Y_UP 0x11 + + +/* + * Accepted by OSMesaGetIntegerv: + */ +#define OSMESA_WIDTH 0x20 +#define OSMESA_HEIGHT 0x21 +#define OSMESA_FORMAT 0x22 +#define OSMESA_TYPE 0x23 + + +typedef struct osmesa_context *OSMesaContext; + + +#if defined(__BEOS__) || defined(__QUICKDRAW__) +#pragma export on +#endif + + +/* + * Create an Off-Screen Mesa rendering context. The only attribute needed is + * an RGBA vs Color-Index mode flag. + * + * Input: format - one of OSMESA_COLOR_INDEX, OSMESA_RGBA, OSMESA_BGRA, + * OSMESA_ARGB, OSMESA_RGB, or OSMESA_BGR. + * sharelist - specifies another OSMesaContext with which to share + * display lists. NULL indicates no sharing. + * Return: an OSMesaContext or 0 if error + */ +GLAPI OSMesaContext GLAPIENTRY OSMesaCreateContext( GLenum format, + OSMesaContext sharelist ); + + + + +/* + * Destroy an Off-Screen Mesa rendering context. + * + * Input: ctx - the context to destroy + */ +GLAPI void GLAPIENTRY OSMesaDestroyContext( OSMesaContext ctx ); + + + +/* + * Bind an OSMesaContext to an image buffer. The image buffer is just a + * block of memory which the client provides. Its size must be at least + * as large as width*height*sizeof(type). Its address should be a multiple + * of 4 if using RGBA mode. + * + * Image data is stored in the order of glDrawPixels: row-major order + * with the lower-left image pixel stored in the first array position + * (ie. bottom-to-top). + * + * Since the only type initially supported is GL_UNSIGNED_BYTE, if the + * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA + * value. If the context is in color indexed mode, each pixel will be + * stored as a 1-byte value. + * + * If the context's viewport hasn't been initialized yet, it will now be + * initialized to (0,0,width,height). + * + * Input: ctx - the rendering context + * buffer - the image buffer memory + * type - data type for pixel components, only GL_UNSIGNED_BYTE + * supported now + * width, height - size of image buffer in pixels, at least 1 + * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx, + * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1, + * width>internal limit or height>internal limit. + */ +GLAPI GLboolean GLAPIENTRY OSMesaMakeCurrent( OSMesaContext ctx, + void *buffer, GLenum type, + GLsizei width, GLsizei height ); + + + + +/* + * Return the current Off-Screen Mesa rendering context handle. + */ +GLAPI OSMesaContext GLAPIENTRY OSMesaGetCurrentContext( void ); + + + +/* + * Set pixel store/packing parameters for the current context. + * This is similar to glPixelStore. + * Input: pname - OSMESA_ROW_LENGTH + * specify actual pixels per row in image buffer + * 0 = same as image width (default) + * OSMESA_Y_UP + * zero = Y coordinates increase downward + * non-zero = Y coordinates increase upward (default) + * value - the value for the parameter pname + * + * New in version 2.0. + */ +GLAPI void GLAPIENTRY OSMesaPixelStore( GLint pname, GLint value ); + + + +/* + * Return an integer value like glGetIntegerv. + * Input: pname - + * OSMESA_WIDTH return current image width + * OSMESA_HEIGHT return current image height + * OSMESA_FORMAT return image format + * OSMESA_TYPE return color component data type + * OSMESA_ROW_LENGTH return row length in pixels + * OSMESA_Y_UP returns 1 or 0 to indicate Y axis direction + * value - pointer to integer in which to return result. + */ +GLAPI void GLAPIENTRY OSMesaGetIntegerv( GLint pname, GLint *value ); + + + +/* + * Return the depth buffer associated with an OSMesa context. + * Input: c - the OSMesa context + * Output: width, height - size of buffer in pixels + * bytesPerValue - bytes per depth value (2 or 4) + * buffer - pointer to depth buffer values + * Return: GL_TRUE or GL_FALSE to indicate success or failure. + * + * New in Mesa 2.4. + */ +GLAPI GLboolean GLAPIENTRY OSMesaGetDepthBuffer( OSMesaContext c, + GLint *width, GLint *height, + GLint *bytesPerValue, + void **buffer ); + + +/* + * Return the color buffer associated with an OSMesa context. + * Input: c - the OSMesa context + * Output: width, height - size of buffer in pixels + * format - buffer format (OSMESA_FORMAT) + * buffer - pointer to depth buffer values + * Return: GL_TRUE or GL_FALSE to indicate success or failure. + * + * New in Mesa 3.3. + */ +GLAPI GLboolean GLAPIENTRY OSMesaGetColorBuffer( OSMesaContext c, + GLint *width, GLint *height, + GLint *format, + void **buffer ); + + +#if defined(__BEOS__) || defined(__QUICKDRAW__) +#pragma export off +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/xc/extras/Mesa/src/FX/fxapi.c b/xc/extras/Mesa/src/FX/fxapi.c index 0b96cf439..6d680bcb9 100644 --- a/xc/extras/Mesa/src/FX/fxapi.c +++ b/xc/extras/Mesa/src/FX/fxapi.c @@ -623,7 +623,7 @@ #if defined(FX) #include "fxdrv.h" -fxMesaContext fxMesaCurrentCtx=NULL; +static fxMesaContext fxMesaCurrentCtx=NULL; /* * Status of 3Dfx hardware initialization @@ -694,22 +694,11 @@ void GLAPIENTRY fxMesaSetNearFar(GLfloat n, GLfloat f) /* - * The extension GL_FXMESA_global_texture_lod_bias - */ -void GLAPIENTRY glGlobalTextureLODBiasFXMESA(GLfloat biasVal) -{ - grTexLodBiasValue(GR_TMU0,biasVal); - - if(fxMesaCurrentCtx->haveTwoTMUs) - grTexLodBiasValue(GR_TMU1,biasVal); -} - - -/* * The 3Dfx Global Palette extension for GLQuake. * More a trick than a real extesion, use the shared global * palette extension. */ +extern void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal); /* silence warning */ void GLAPIENTRY gl3DfxSetPaletteEXT(GLuint *pal) { fxMesaContext fxMesa =fxMesaCurrentCtx; @@ -866,6 +855,8 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, GLcontext *ctx = 0; /*FX_GrContext_t glideContext = 0;*/ char *errorstr; + GLboolean useBGR; + char *system = NULL; if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxMesaCreateContext() Start\n"); @@ -890,8 +881,10 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, case FXMESA_DEPTH_SIZE: i++; depthSize=attribList[i]; - if(depthSize) + if(depthSize) { aux=1; + depthSize = 16; + } break; case FXMESA_STENCIL_SIZE: i++; @@ -924,10 +917,7 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, if(depthSize && alphaBuffer) alphaBuffer=0; - if(verbose) - fprintf(stderr,"Mesa fx Voodoo Device Driver v0.30\nWritten by David Bucciarelli (davibu@tin.it.it)\n"); - - if((type=fxQueryHardware()) < 0) { + if ((type=fxQueryHardware()) < 0) { fprintf(stderr,"fx Driver: ERROR no Voodoo1/2 Graphics or Voodoo Rush !\n"); return NULL; } @@ -950,10 +940,8 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, else fxMesa->haveTwoTMUs=GL_FALSE; - fxMesa->haveDoubleBuffer=doubleBuffer; fxMesa->haveAlphaBuffer=alphaBuffer; fxMesa->haveGlobalPaletteTexture=GL_FALSE; - fxMesa->haveZBuffer=depthSize ? 1 : 0; fxMesa->verbose=verbose; fxMesa->board=glbCurrentBoard; @@ -971,28 +959,83 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, goto errorhandler; } - /* Pixel tables are use during pixel read-back */ + /* + * Pixel tables are use during pixel read-back + * Either initialize them for RGB or BGR order. + */ #if FXMESA_USE_ARGB - fxInitPixelTables(fxMesa, GL_FALSE); /* Force RGB pixel order */ + useBGR = GL_FALSE; /* Force RGB pixel order */ + system = "FXMESA_USE_ARGB"; #else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) { - /* jk991130 - GROSS HACK!!! - Voodoo 3s don't use BGR!! - * the only way to tell if it's a Voodoo 3 at this stage of the - * ballgame (no Glide 3.x for linux *yet*) is to query the # of TMUs + /* jk991130 - Voodoo 3s don't use BGR. Query the # of TMUs * as Voodoo3s have 2 TMUs on board, Banshee has only 1 - * Thanks to Joseph Kain for that one + * bk000413 - another suggestion from Joseph Kain is using + * VendorID 0x121a for all 3dfx boards + * DeviceID VG 1/V2 2/VB 3/V3 5 + * For now we cehck for known BGR devices, and presume + * everything else to be a V3/RGB. */ - if (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx == 2) { - fxInitPixelTables(fxMesa, GL_FALSE); /* use RGB pixel order (Voodoo3) */ + GrVoodooConfig_t *voodoo; + voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig; + + if (voodoo->nTexelfx == 1) { + /* Voodoo1 or Banshee */ + useBGR = GL_TRUE; + system = "Voodoo1"; + } + else if (voodoo->nTexelfx == 2 && + voodoo->fbiRev == 260 && + voodoo->tmuConfig[0].tmuRev == 4 && + (voodoo->tmuConfig[0].tmuRam == 2 || + voodoo->tmuConfig[0].tmuRam == 4)) { + /* Voodoo 2 */ + useBGR = GL_TRUE; + system = "Voodoo2"; + } + else if (voodoo->nTexelfx == 2 && + voodoo->fbiRev == 2 && + voodoo->tmuConfig[0].tmuRev == 1 && + voodoo->tmuConfig[0].tmuRam == 4) { + /* Quantum3D Obsidian 50/100 */ + useBGR = GL_TRUE; + system = "Quantum3D Obsidian"; + } + else + /* Brian + * (voodoo->nTexelfx == 2 && + * voodoo->fbiRev == 0 && + * voodoo->tmuConfig[0].tmuRev == 148441048 && + * voodoo->tmuConfig[0].tmuRam == 3) + * Bernd + * (voodoo->nTexelfx == 2 && + * voodoo->fbiRev == 69634 && + * voodoo->tmuConfig[0].tmuRev == 69634 && + * voodoo->tmuConfig[0].tmuRam == 2 ) + */ + { + /* Presumed Voodoo3 */ + useBGR = GL_FALSE; + system = "Voodoo3"; } - else { - fxInitPixelTables(fxMesa, GL_TRUE); /* use BGR pixel order on Voodoo1/2 */ + if (getenv("MESA_FX_INFO")) { + printf("Voodoo: Texelfx: %d / FBI Rev.: %d / TMU Rev.: %d / TMU RAM: %d\n", + voodoo->nTexelfx, + voodoo->fbiRev, + voodoo->tmuConfig[0].tmuRev, + voodoo->tmuConfig[0].tmuRam ); } } else { - fxInitPixelTables(fxMesa, GL_FALSE); /* use RGB pixel order otherwise */ + useBGR = GL_FALSE; /* use RGB pixel order otherwise */ + system = "non-voodoo"; } -#endif +#endif /*FXMESA_USE_ARGB*/ + + if (getenv("MESA_FX_INFO")) + printf("Voodoo pixel order: %s (%s)\n", useBGR ? "BGR" : "RGB", system); + + fxInitPixelTables(fxMesa, useBGR); fxMesa->width=FX_grSstScreenWidth(); fxMesa->height=FX_grSstScreenHeight(); @@ -1011,7 +1054,7 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, fxMesa->needClip = 0; if(verbose) - fprintf(stderr,"Glide screen size: %dx%d\n", + fprintf(stderr,"Voodoo Glide screen size: %dx%d\n", (int)FX_grSstScreenWidth(),(int)FX_grSstScreenHeight()); fxMesa->glVis=gl_create_visual(GL_TRUE, /* RGB mode */ @@ -1046,7 +1089,7 @@ fxMesaContext GLAPIENTRY fxMesaCreateContext(GLuint win, fxMesa->glBuffer=gl_create_framebuffer(fxMesa->glVis, GL_FALSE, /* no software depth */ fxMesa->glVis->StencilBits > 0, - fxMesa->glVis->AccumBits > 0, + fxMesa->glVis->AccumRedBits > 0, fxMesa->glVis->AlphaBits > 0 ); if (!fxMesa->glBuffer) { errorstr = "gl_create_framebuffer"; @@ -1221,6 +1264,25 @@ void GLAPIENTRY fxMesaMakeCurrent(fxMesaContext fxMesa) } +#if 0 +static void QueryCounters(void) +{ + static GLuint prevPassed = 0; + static GLuint prevFailed = 0; + GLuint failed, passed; + GrSstPerfStats_t st; + + FX_grSstPerfStats(&st); + failed = st.zFuncFail - st.aFuncFail - st.chromaFail; + passed = st.pixelsIn - failed; + printf("failed: %d passed: %d\n", failed - prevFailed, passed - prevPassed); + + prevPassed = passed; + prevFailed = failed; +} +#endif + + /* * Swap front/back buffers for current context if double buffered. */ @@ -1233,7 +1295,7 @@ void GLAPIENTRY fxMesaSwapBuffers(void) if(fxMesaCurrentCtx) { FLUSH_VB( fxMesaCurrentCtx->glCtx, "swap buffers" ); - if(fxMesaCurrentCtx->haveDoubleBuffer) { + if (fxMesaCurrentCtx->glVis->DBflag) { grBufferSwap(fxMesaCurrentCtx->swapInterval); @@ -1263,40 +1325,45 @@ int GLAPIENTRY fxQueryHardware(void) fprintf(stderr,"fxmesa: fxQueryHardware() Start\n"); } - if(!glbGlideInitialized) { + if (!glbGlideInitialized) { grGlideInit(); - if(FX_grSstQueryHardware(&glbHWConfig)) { + if (FX_grSstQueryHardware(&glbHWConfig)) { grSstSelect(glbCurrentBoard); - glb3DfxPresent=1; + glb3DfxPresent = 1; - if(getenv("MESA_FX_INFO")) { + if (getenv("MESA_FX_INFO")) { char buf[80]; FX_grGlideGetVersion(buf); - fprintf(stderr,"Using Glide V%s\n",""); - fprintf(stderr,"Number of boards: %d\n",glbHWConfig.num_sst); - - if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_VOODOO) { - fprintf(stderr,"Framebuffer RAM: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect ? - (glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam*2) : - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.fbRam); - fprintf(stderr,"Number of TMUs: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.nTexelfx); - fprintf(stderr,"SLI detected: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig.sliDetect); - } else if(glbHWConfig.SSTs[glbCurrentBoard].type==GR_SSTTYPE_SST96) { - fprintf(stderr,"Framebuffer RAM: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.fbRam); - fprintf(stderr,"Number of TMUs: %d\n", - glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config.nTexelfx); + fprintf(stderr, "Voodoo Using Glide V%s\n", buf); + fprintf(stderr, "Voodoo Number of boards: %d\n", glbHWConfig.num_sst); + + if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_VOODOO) { + GrVoodooConfig_t *voodoo; + voodoo = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.VoodooConfig; + + fprintf(stderr, "Voodoo Framebuffer RAM: %d\n", + voodoo->sliDetect ? (voodoo->fbRam*2) : voodoo->fbRam); + fprintf(stderr, "Voodoo Number of TMUs: %d\n", voodoo->nTexelfx); + fprintf(stderr, "Voodoo fbRam: %d\n", voodoo->fbRam); + fprintf(stderr, "Voodoo fbiRev: %d\n", voodoo->fbiRev); + + fprintf(stderr,"Voodoo SLI detected: %d\n", voodoo->sliDetect); + } + else if (glbHWConfig.SSTs[glbCurrentBoard].type == GR_SSTTYPE_SST96) { + GrSst96Config_t *sst96; + sst96 = &glbHWConfig.SSTs[glbCurrentBoard].sstBoard.SST96Config; + fprintf(stderr, "Voodoo Framebuffer RAM: %d\n", sst96->fbRam); + fprintf(stderr, "Voodoo Number of TMUs: %d\n", sst96->nTexelfx); } } - } else - glb3DfxPresent=0; + } + else { + glb3DfxPresent = 0; + } - glbGlideInitialized=1; + glbGlideInitialized = 1; #if defined(__WIN32__) onexit((_onexit_t)cleangraphics); @@ -1308,17 +1375,11 @@ int GLAPIENTRY fxQueryHardware(void) #endif } - if(!glb3DfxPresent) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxQueryHardware() End (-1)\n"); - } - return(-1); - } - if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxQueryHardware() End (voodooo)\n"); } - return(glbHWConfig.SSTs[glbCurrentBoard].type); + + return glbHWConfig.SSTs[glbCurrentBoard].type; } @@ -1327,8 +1388,8 @@ int GLAPIENTRY fxQueryHardware(void) */ void GLAPIENTRY fxCloseHardware(void) { - if(glbGlideInitialized) { - if(getenv("MESA_FX_INFO")) { + if (glbGlideInitialized) { + if (getenv("MESA_FX_INFO")) { GrSstPerfStats_t st; FX_grSstPerfStats(&st); @@ -1340,9 +1401,9 @@ void GLAPIENTRY fxCloseHardware(void) fprintf(stderr," # pixels drawn (including buffer clears and LFB writes): %u\n",(unsigned)st.pixelsOut); } - if(glbTotNumCtx==0) { + if (glbTotNumCtx == 0) { grGlideShutdown(); - glbGlideInitialized=0; + glbGlideInitialized = 0; } } } @@ -1354,7 +1415,7 @@ void GLAPIENTRY fxCloseHardware(void) /* * Need this to provide at least one external definition. */ - +extern int gl_fx_dummy_function_api(void); int gl_fx_dummy_function_api(void) { return 0; diff --git a/xc/extras/Mesa/src/FX/fxdd.c b/xc/extras/Mesa/src/FX/fxdd.c index b44ec4dbe..59a4bec93 100644 --- a/xc/extras/Mesa/src/FX/fxdd.c +++ b/xc/extras/Mesa/src/FX/fxdd.c @@ -52,6 +52,7 @@ #if defined(FX) +#include <dlfcn.h> #include "image.h" #include "types.h" #include "fxdrv.h" @@ -102,34 +103,20 @@ void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder) /***** Miscellaneous functions *****/ /**********************************************************************/ -/* Enalbe/Disable dithering */ -static void fxDDDither(GLcontext *ctx, GLboolean enable) -{ - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDDither()\n"); - } - - if (enable) { - FX_grDitherMode(GR_DITHER_4x4); - } else { - FX_grDitherMode(GR_DITHER_DISABLE); - } -} - /* Return buffer size information */ static void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + fxMesaContext fxMesa = FX_CONTEXT(ctx); - if (MESA_VERBOSE&VERBOSE_DRIVER) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDBufferSize(...) Start\n"); } - *width=fxMesa->width; - *height=fxMesa->height; + *width = fxMesa->width; + *height = fxMesa->height; - if (MESA_VERBOSE&VERBOSE_DRIVER) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDBufferSize(...) End\n"); } } @@ -139,15 +126,13 @@ static void fxDDBufferSize(GLcontext *ctx, GLuint *width, GLuint *height) static void fxDDSetColor(GLcontext *ctx, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + fxMesaContext fxMesa = FX_CONTEXT(ctx); GLubyte col[4]; ASSIGN_4V( col, red, green, blue, alpha ); - - if (MESA_VERBOSE&VERBOSE_DRIVER) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDSetColor(%d,%d,%d,%d)\n",red,green,blue,alpha); } - - fxMesa->color=FXCOLOR4(col); + fxMesa->color = FXCOLOR4(col); } @@ -155,19 +140,14 @@ static void fxDDSetColor(GLcontext *ctx, GLubyte red, GLubyte green, static void fxDDClearColor(GLcontext *ctx, GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha ) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + fxMesaContext fxMesa = FX_CONTEXT(ctx); GLubyte col[4]; - - - ASSIGN_4V( col, red, green, blue, 255 ); - - if (MESA_VERBOSE&VERBOSE_DRIVER) { + if (MESA_VERBOSE & VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDClearColor(%d,%d,%d,%d)\n",red,green,blue,alpha); } - - fxMesa->clearC=FXCOLOR4( col ); - fxMesa->clearA=alpha; + fxMesa->clearC = FXCOLOR4( col ); + fxMesa->clearA = alpha; } @@ -177,8 +157,18 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; const GLuint colorMask = *((GLuint *) &ctx->Color.ColorMask); - const FxU16 clearD = (FxU16) (ctx->Depth.Clear * 0xffff); - GLbitfield softwareMask = mask & (DD_STENCIL_BIT | DD_ACCUM_BIT); + const FxU32 clearD = (FxU32) (ctx->Depth.Clear * fxMesa->depthClear); + const FxU32 clearS = (FxU32) (ctx->Stencil.Clear); + GLbitfield softwareMask = mask & (DD_ACCUM_BIT); + + /* we can't clear accum buffers */ + mask &= ~(DD_ACCUM_BIT); + + if ((mask & DD_STENCIL_BIT) && !fxMesa->haveHwStencil) { + /* software stencil buffer */ + mask &= ~(DD_STENCIL_BIT); + softwareMask |= DD_STENCIL_BIT; + } if (MESA_VERBOSE & VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDClear(%d,%d,%d,%d)\n", (int) x, (int) y, @@ -186,21 +176,40 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, } if (colorMask != 0xffffffff) { - /* do color buffer clears in software */ + /* do masked color buffer clears in software */ softwareMask |= (mask & (DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT)); mask &= ~(DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT); } + + /* disable stencil ops if enabled (it screws up clearing) */ + if (ctx->Stencil.Enabled) + FX_grDisable(GR_STENCIL_MODE_EXT); + + if (fxMesa->haveHwStencil) { + if (mask & DD_STENCIL_BIT) { + FX_grStencilMask(0xff); + /* set stencil ref value = desired clear value */ + FX_grStencilFunc(GR_CMP_ALWAYS, ctx->Stencil.Clear, 0xff); + } + else { + FX_grStencilMask(0x00); + } + } + /* * This could probably be done fancier but doing each possible case * explicitly is less error prone. */ - switch (mask) { + switch (mask & ~DD_STENCIL_BIT) { case DD_BACK_LEFT_BIT | DD_DEPTH_BIT: /* back buffer & depth */ FX_grDepthMask(FXTRUE); FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); if (!ctx->Depth.Mask) { FX_grDepthMask(FXFALSE); } @@ -211,75 +220,114 @@ static GLbitfield fxDDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, * This is a work-around/ */ /* clear depth */ + FX_grDepthMask(FXTRUE); FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); FX_grColorMask(FXFALSE,FXFALSE); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); /* clear front */ FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); break; case DD_BACK_LEFT_BIT: /* back buffer only */ FX_grDepthMask(FXFALSE); FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); - if (!ctx->Depth.Mask) { - FX_grDepthMask(FXFALSE); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (ctx->Depth.Mask) { + FX_grDepthMask(FXTRUE); } break; case DD_FRONT_LEFT_BIT: /* front buffer only */ FX_grDepthMask(FXFALSE); FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); - if (!ctx->Depth.Mask) { - FX_grDepthMask(FXFALSE); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (ctx->Depth.Mask) { + FX_grDepthMask(FXTRUE); } break; case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT: /* front and back */ FX_grDepthMask(FXFALSE); FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); - if (!ctx->Depth.Mask) { - FX_grDepthMask(FXFALSE); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (ctx->Depth.Mask) { + FX_grDepthMask(FXTRUE); } break; case DD_FRONT_LEFT_BIT | DD_BACK_LEFT_BIT | DD_DEPTH_BIT: /* clear front */ FX_grDepthMask(FXFALSE); FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); /* clear back and depth */ FX_grDepthMask(FXTRUE); FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); if (!ctx->Depth.Mask) { FX_grDepthMask(FXFALSE); } break; case DD_DEPTH_BIT: /* just the depth buffer */ + FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); FX_grColorMask(FXFALSE,FXFALSE); - FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, - (FxU16)(ctx->Depth.Clear*0xffff)); + FX_grDepthMask(FXTRUE); + if (mask & DD_STENCIL_BIT) + FX_grBufferClearExt(fxMesa->clearC, fxMesa->clearA, clearD, clearS); + else + FX_grBufferClear(fxMesa->clearC, fxMesa->clearA, clearD); FX_grColorMask(FXTRUE, ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); + if (ctx->Color.DrawDestMask & FRONT_LEFT_BIT) + FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); break; default: /* error */ ; } + if (ctx->Stencil.Enabled) { + /* restore stencil state to as it was before the clear */ + FX_grEnable(GR_STENCIL_MODE_EXT); + FX_grStencilMask(ctx->Stencil.WriteMask); + FX_grStencilFunc(ctx->Stencil.Function - GL_NEVER, + ctx->Stencil.Ref, ctx->Stencil.ValueMask); + } + return softwareMask; } /* Set the buffer used for drawing */ /* XXX support for separate read/draw buffers hasn't been tested */ -static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode ) +static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; @@ -297,6 +345,10 @@ static GLboolean fxDDSetDrawBuffer(GLcontext *ctx, GLenum mode ) FX_grRenderBuffer(fxMesa->currentFB); return GL_TRUE; } + else if (mode == GL_NONE) { + FX_grColorMask(FXFALSE,FXFALSE); + return GL_TRUE; + } else { return GL_FALSE; } @@ -326,6 +378,58 @@ static void fxDDSetReadBuffer(GLcontext *ctx, GLframebuffer *buffer, } +/* + * These functions just set new-state flags. The exact state + * values will be evaluated later. + */ +static void +fxDDStencilFunc(GLcontext *ctx, GLenum func, GLint ref, GLuint mask) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + (void) func; (void) ref; (void) mask; + fxMesa->new_state |= FX_NEW_STENCIL; + ctx->Driver.RenderStart = fxSetupFXUnits; +} + +static void +fxDDStencilMask(GLcontext *ctx, GLuint mask) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + (void) mask; + fxMesa->new_state |= FX_NEW_STENCIL; + ctx->Driver.RenderStart = fxSetupFXUnits; +} + +static void +fxDDStencilOp(GLcontext *ctx, GLenum sfail, GLenum zfail, GLenum zpass) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + (void) sfail; (void) zfail; (void) zpass; + fxMesa->new_state |= FX_NEW_STENCIL; + ctx->Driver.RenderStart = fxSetupFXUnits; +} + +static void +fxDDDepthFunc(GLcontext *ctx, GLenum func) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + (void) func; + fxMesa->new_state |= FX_NEW_DEPTH; + ctx->Driver.RenderStart = fxSetupFXUnits; +} + +static void +fxDDDepthMask(GLcontext *ctx, GLboolean mask) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + (void) mask; + fxMesa->new_state |= FX_NEW_DEPTH; + ctx->Driver.RenderStart = fxSetupFXUnits; +} + + + + #ifdef XF86DRI /* test if window coord (px,py) is visible */ static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py) @@ -342,10 +446,12 @@ static GLboolean inClipRects(fxMesaContext fxMesa, int px, int py) #endif -static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py, - GLsizei width, GLsizei height, - const struct gl_pixelstore_attrib *unpack, - const GLubyte *bitmap) + +static GLboolean +bitmap_R5G6B5(GLcontext *ctx, GLint px, GLint py, + GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GrLfbInfo_t info; @@ -463,7 +569,7 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py, + (winX + px); for (row = 0; row < height; row++) { - const GLubyte *src = (const GLubyte *) gl_pixel_addr_in_image( finalUnpack, + const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack, bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); if (finalUnpack->LsbFirst) { /* least significan bit first */ @@ -515,6 +621,303 @@ static GLboolean fxDDDrawBitMap(GLcontext *ctx, GLint px, GLint py, return GL_TRUE; } + +static GLboolean +bitmap_R8G8B8A8(GLcontext *ctx, GLint px, GLint py, + GLsizei width, GLsizei height, + const struct gl_pixelstore_attrib *unpack, + const GLubyte *bitmap) +{ + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + GrLfbInfo_t info; + GrLfbWriteMode_t mode; + /*FxU16 color;*/ + GLuint color; + const struct gl_pixelstore_attrib *finalUnpack; + struct gl_pixelstore_attrib scissoredUnpack; + + /* check if there's any raster operations enabled which we can't handle */ + if (ctx->RasterMask & (ALPHATEST_BIT | + BLEND_BIT | + DEPTH_BIT | + FOG_BIT | + LOGIC_OP_BIT | + SCISSOR_BIT | + STENCIL_BIT | + MASKING_BIT | + ALPHABUF_BIT | + MULTI_DRAW_BIT)) + return GL_FALSE; + + if (ctx->Scissor.Enabled) { + /* This is a bit tricky, but by carefully adjusting the px, py, + * width, height, skipPixels and skipRows values we can do + * scissoring without special code in the rendering loop. + */ + + /* we'll construct a new pixelstore struct */ + finalUnpack = &scissoredUnpack; + scissoredUnpack = *unpack; + if (scissoredUnpack.RowLength == 0) + scissoredUnpack.RowLength = width; + + /* clip left */ + if (px < ctx->Scissor.X) { + scissoredUnpack.SkipPixels += (ctx->Scissor.X - px); + width -= (ctx->Scissor.X - px); + px = ctx->Scissor.X; + } + /* clip right */ + if (px + width >= ctx->Scissor.X + ctx->Scissor.Width) { + width -= (px + width - (ctx->Scissor.X + ctx->Scissor.Width)); + } + /* clip bottom */ + if (py < ctx->Scissor.Y) { + scissoredUnpack.SkipRows += (ctx->Scissor.Y - py); + height -= (ctx->Scissor.Y - py); + py = ctx->Scissor.Y; + } + /* clip top */ + if (py + height >= ctx->Scissor.Y + ctx->Scissor.Height) { + height -= (py + height - (ctx->Scissor.Y + ctx->Scissor.Height)); + } + + if (width <= 0 || height <= 0) + return GL_TRUE; /* totally scissored away */ + } + else { + finalUnpack = unpack; + } + + /* compute pixel value */ + { + GLint r = (GLint) (ctx->Current.RasterColor[0] * 255.0f); + GLint g = (GLint) (ctx->Current.RasterColor[1] * 255.0f); + GLint b = (GLint) (ctx->Current.RasterColor[2] * 255.0f); + GLint a = (GLint) (ctx->Current.RasterColor[3] * 255.0f); + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + color = PACK_BGRA32(r, g, b, a); + else + color = PACK_RGBA32(r, g, b, a); + } + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + mode = GR_LFBWRITEMODE_8888; + else + mode = GR_LFBWRITEMODE_888; + + info.size = sizeof(info); + if (!FX_grLfbLock(GR_LFB_WRITE_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { +#ifndef FX_SILENT + fprintf(stderr,"fx Driver: error locking the linear frame buffer\n"); +#endif + return GL_TRUE; + } + +#ifdef XF86DRI +#define INSIDE(c, x, y) inClipRects((c), (x), (y)) +#else +#define INSIDE(c, x, y) (1) +#endif + + { + const GLint winX = fxMesa->x_offset; + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + GLint dstStride; + GLuint *dst; + GLint row; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + dstStride = fxMesa->screen_width; + dst = (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX + px); + } + else { + dstStride = info.strideInBytes / 4; + dst = (GLuint *) info.lfbPtr + (winY - py) * dstStride + (winX + px); + } + + /* compute dest address of bottom-left pixel in bitmap */ + for (row = 0; row < height; row++) { + const GLubyte *src = (const GLubyte *) _mesa_image_address( finalUnpack, + bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); + if (finalUnpack->LsbFirst) { + /* least significan bit first */ + GLubyte mask = 1U << (finalUnpack->SkipPixels & 0x7); + GLint col; + for (col=0; col<width; col++) { + if (*src & mask) { + if (INSIDE(fxMesa, winX + px + col, winY - py - row)) + dst[col] = color; + } + if (mask == 128U) { + src++; + mask = 1U; + } + else { + mask = mask << 1; + } + } + if (mask != 1) + src++; + } + else { + /* most significan bit first */ + GLubyte mask = 128U >> (finalUnpack->SkipPixels & 0x7); + GLint col; + for (col=0; col<width; col++) { + if (*src & mask) { + if (INSIDE(fxMesa, winX + px + col, winY - py - row)) + dst[col] = color; + } + if (mask == 1U) { + src++; + mask = 128U; + } + else { + mask = mask >> 1; + } + } + if (mask != 128) + src++; + } + dst -= dstStride; + } + } + +#undef INSIDE + + FX_grLfbUnlock(GR_LFB_WRITE_ONLY,fxMesa->currentFB); + return GL_TRUE; +} + + +static GLboolean +readpixels_R5G6B5( GLcontext *ctx, GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *packing, + GLvoid *dstImage ) +{ + if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) { + return GL_FALSE; /* can't do this */ + } + else { + fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + GrLfbInfo_t info; + GLboolean result = GL_FALSE; + + BEGIN_BOARD_LOCK(); + info.size=sizeof(info); + if (grLfbLock(GR_LFB_READ_ONLY, + fxMesa->currentFB, + GR_LFBWRITEMODE_ANY, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winX = fxMesa->x_offset; + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; +#ifdef XF86DRI + const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + ? (fxMesa->screen_width) : (info.strideInBytes / 2); +#else + const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ +#endif + const GLushort *src = (const GLushort *) info.lfbPtr + + (winY - y) * srcStride + (winX + x); + GLubyte *dst = (GLubyte *) _mesa_image_address(packing, dstImage, + width, height, format, type, 0, 0, 0); + GLint dstStride = _mesa_image_row_stride(packing, width, format, type); + + if (format == GL_RGB && type == GL_UNSIGNED_BYTE) { + /* convert 5R6G5B into 8R8G8B */ + GLint row, col; + const GLint halfWidth = width >> 1; + const GLint extraPixel = (width & 1); + for (row = 0; row < height; row++) { + GLubyte *d = dst; + for (col = 0; col < halfWidth; col++) { + const GLuint pixel = ((const GLuint *) src)[col]; + const GLint pixel0 = pixel & 0xffff; + const GLint pixel1 = pixel >> 16; + *d++ = FX_PixelToR[pixel0]; + *d++ = FX_PixelToG[pixel0]; + *d++ = FX_PixelToB[pixel0]; + *d++ = FX_PixelToR[pixel1]; + *d++ = FX_PixelToG[pixel1]; + *d++ = FX_PixelToB[pixel1]; + } + if (extraPixel) { + GLushort pixel = src[width-1]; + *d++ = FX_PixelToR[pixel]; + *d++ = FX_PixelToG[pixel]; + *d++ = FX_PixelToB[pixel]; + } + dst += dstStride; + src -= srcStride; + } + result = GL_TRUE; + } + else if (format == GL_RGBA && type == GL_UNSIGNED_BYTE) { + /* convert 5R6G5B into 8R8G8B8A */ + GLint row, col; + const GLint halfWidth = width >> 1; + const GLint extraPixel = (width & 1); + for (row = 0; row < height; row++) { + GLubyte *d = dst; + for (col = 0; col < halfWidth; col++) { + const GLuint pixel = ((const GLuint *) src)[col]; + const GLint pixel0 = pixel & 0xffff; + const GLint pixel1 = pixel >> 16; + *d++ = FX_PixelToR[pixel0]; + *d++ = FX_PixelToG[pixel0]; + *d++ = FX_PixelToB[pixel0]; + *d++ = 255; + *d++ = FX_PixelToR[pixel1]; + *d++ = FX_PixelToG[pixel1]; + *d++ = FX_PixelToB[pixel1]; + *d++ = 255; + } + if (extraPixel) { + const GLushort pixel = src[width-1]; + *d++ = FX_PixelToR[pixel]; + *d++ = FX_PixelToG[pixel]; + *d++ = FX_PixelToB[pixel]; + *d++ = 255; + } + dst += dstStride; + src -= srcStride; + } + result = GL_TRUE; + } + else if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) { + /* directly memcpy 5R6G5B pixels into client's buffer */ + const GLint widthInBytes = width * 2; + GLint row; + for (row = 0; row < height; row++) { + MEMCPY(dst, src, widthInBytes); + dst += dstStride; + src -= srcStride; + } + result = GL_TRUE; + } + else { + result = GL_FALSE; + } + + grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); + } + END_BOARD_LOCK(); + return result; + } +} + + + static void fxDDFinish(GLcontext *ctx) { FX_grFlush(); @@ -568,7 +971,7 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name) } } /* now make the GL_RENDERER string */ - sprintf(buffer, "Mesa DRI %s 20000224", hardware); + sprintf(buffer, "Mesa DRI %s 20000608", hardware); return buffer; } case GL_VENDOR: @@ -625,6 +1028,19 @@ static const GLubyte *fxDDGetString(GLcontext *ctx, GLenum name) int fxDDInitFxMesaContext( fxMesaContext fxMesa ) { + /* Get Glide3vn function pointers */ + { + void *handle; + handle = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); + if (!handle) + return 0; + grStencilFuncPtr = dlsym(handle, "grStencilFunc"); + grStencilMaskPtr = dlsym(handle, "grStencilMask"); + grStencilOpPtr = dlsym(handle, "grStencilOp"); + grBufferClearExtPtr = dlsym(handle, "grBufferClearExt"); + /* call dlclose()? */ + } + FX_setupGrVertexLayout(); @@ -651,6 +1067,8 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) else fxMesa->verbose=GL_FALSE; + fxMesa->depthClear = FX_grGetInteger(FX_ZDEPTH_MAX); + fxMesa->color=0xffffffff; fxMesa->clearC=0; fxMesa->clearA=0; @@ -661,7 +1079,6 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) fxMesa->stats.memTexUpload=0; fxMesa->tmuSrc=FX_TMU_NONE; - fxMesa->lastUnitsMode=FX_UM_NONE; fxTMInit(fxMesa); /* FX units setup */ @@ -676,16 +1093,19 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) fxMesa->unitsState.blendSrcFuncAlpha=GR_BLEND_ONE; fxMesa->unitsState.blendDstFuncAlpha=GR_BLEND_ZERO; + /* fxMesa->unitsState.depthTestEnabled =GL_FALSE; fxMesa->unitsState.depthMask =GL_TRUE; fxMesa->unitsState.depthTestFunc =GR_CMP_LESS; + */ FX_grColorMask(FXTRUE, fxMesa->haveAlphaBuffer ? FXTRUE : FXFALSE); - if(fxMesa->haveDoubleBuffer) { - fxMesa->currentFB=GR_BUFFER_BACKBUFFER; + if (fxMesa->glVis->DBflag) { + fxMesa->currentFB = GR_BUFFER_BACKBUFFER; FX_grRenderBuffer(GR_BUFFER_BACKBUFFER); - } else { - fxMesa->currentFB=GR_BUFFER_FRONTBUFFER; + } + else { + fxMesa->currentFB = GR_BUFFER_FRONTBUFFER; FX_grRenderBuffer(GR_BUFFER_FRONTBUFFER); } @@ -701,7 +1121,7 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) return 0; } - if(fxMesa->haveZBuffer) + if (fxMesa->glVis->DepthBits > 0) FX_grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER); #if (!FXMESA_USE_ARGB) @@ -714,7 +1134,7 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) fxMesa->glCtx->Const.MaxTextureUnits=fxMesa->emulateTwoTMUs ? 2 : 1; fxMesa->glCtx->NewState|=NEW_DRVSTATE1; fxMesa->new_state = NEW_ALL; - + fxDDSetupInit(); fxDDCvaInit(); fxDDClipInit(); @@ -744,6 +1164,10 @@ int fxDDInitFxMesaContext( fxMesaContext fxMesa ) fxMesa->glCtx->PipelineStage, fxMesa->glCtx->NrPipelineStages); + /* this little bit ensures that all Glide state gets initialized */ + fxMesa->new_state = NEW_ALL; + fxMesa->glCtx->Driver.RenderStart = fxSetupFXUnits; + /* Run the config file */ gl_context_initialize( fxMesa->glCtx ); @@ -768,10 +1192,8 @@ void fxDDInitExtensions( GLcontext *ctx ) gl_extensions_disable(ctx, "GL_EXT_blend_minmax"); gl_extensions_disable(ctx, "GL_EXT_blend_subtract"); gl_extensions_disable(ctx, "GL_EXT_blend_color"); - gl_extensions_disable(ctx, "GL_EXT_paletted_texture"); gl_extensions_add(ctx, DEFAULT_ON, "3DFX_set_global_palette", 0); - gl_extensions_add(ctx, DEFAULT_ON, "GL_FXMESA_global_texture_lod_bias", 0); if (!fxMesa->haveTwoTMUs) gl_extensions_disable(ctx, "GL_EXT_texture_env_add"); @@ -816,8 +1238,7 @@ static GLboolean fxIsInHardware(GLcontext *ctx) if (!ctx->Hint.AllowDrawMem) return GL_TRUE; /* you'll take it and like it */ - if((ctx->RasterMask & STENCIL_BIT) || - ((ctx->Color.BlendEnabled) && (ctx->Color.BlendEquation!=GL_FUNC_ADD_EXT)) || + if(((ctx->Color.BlendEnabled) && (ctx->Color.BlendEquation!=GL_FUNC_ADD_EXT)) || ((ctx->Color.ColorLogicOpEnabled) && (ctx->Color.LogicOp!=GL_COPY)) || (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR) || (!((ctx->Color.ColorMask[RCOMP]==ctx->Color.ColorMask[GCOMP]) && @@ -838,17 +1259,26 @@ static GLboolean fxIsInHardware(GLcontext *ctx) return GL_FALSE; } - if((ctx->Texture.ReallyEnabled & TEXTURE0_2D) && - (ctx->Texture.Unit[0].EnvMode==GL_BLEND)) { - return GL_FALSE; + if (ctx->Texture.ReallyEnabled & TEXTURE0_2D) { + if (ctx->Texture.Unit[0].EnvMode == GL_BLEND && + (ctx->Texture.ReallyEnabled & TEXTURE1_2D || + ctx->Texture.Unit[0].EnvColor[0] != 0 || + ctx->Texture.Unit[0].EnvColor[1] != 0 || + ctx->Texture.Unit[0].EnvColor[2] != 0 || + ctx->Texture.Unit[0].EnvColor[3] != 1)) { + return GL_FALSE; + } + if (ctx->Texture.Unit[0].Current->Image[0]->Border > 0) + return GL_FALSE; } - if((ctx->Texture.ReallyEnabled & TEXTURE1_2D) && - (ctx->Texture.Unit[1].EnvMode==GL_BLEND)) { - return GL_FALSE; + if (ctx->Texture.ReallyEnabled & TEXTURE1_2D) { + if (ctx->Texture.Unit[1].EnvMode == GL_BLEND) + return GL_FALSE; + if (ctx->Texture.Unit[0].Current->Image[0]->Border > 0) + return GL_FALSE; } - if (MESA_VERBOSE & (VERBOSE_DRIVER|VERBOSE_TEXTURE)) fprintf(stderr, "fxMesa: fxIsInHardware, envmode is %s/%s\n", gl_lookup_enum_by_nr(ctx->Texture.Unit[0].EnvMode), @@ -892,6 +1322,9 @@ static GLboolean fxIsInHardware(GLcontext *ctx) } } + if (ctx->Stencil.Enabled && !fxMesa->haveHwStencil) + return GL_FALSE; + return GL_TRUE; } @@ -943,58 +1376,68 @@ static void fxDDReducedPrimitiveChange(GLcontext *ctx, GLenum prim) } } + void fxSetupDDPointers(GLcontext *ctx) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxSetupDDPointers()\n"); - } + fxMesaContext fxMesa = FX_CONTEXT(ctx); - ctx->Driver.UpdateState=fxDDUpdateDDPointers; + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxSetupDDPointers()\n"); + } + ctx->Driver.UpdateState = fxDDUpdateDDPointers; + ctx->Driver.ClearIndex = NULL; + ctx->Driver.ClearColor = fxDDClearColor; + ctx->Driver.Clear = fxDDClear; + ctx->Driver.Index = NULL; + ctx->Driver.Color = fxDDSetColor; + ctx->Driver.SetDrawBuffer = fxDDSetDrawBuffer; + ctx->Driver.SetReadBuffer = fxDDSetReadBuffer; + ctx->Driver.GetBufferSize = fxDDBufferSize; + ctx->Driver.Finish = fxDDFinish; + ctx->Driver.Flush = NULL; + ctx->Driver.GetString = fxDDGetString; + ctx->Driver.NearFar = fxDDSetNearFar; + ctx->Driver.GetParameteri = fxDDGetParameteri; ctx->Driver.WriteDepthSpan=fxDDWriteDepthSpan; ctx->Driver.WriteDepthPixels=fxDDWriteDepthPixels; ctx->Driver.ReadDepthSpan=fxDDReadDepthSpan; ctx->Driver.ReadDepthPixels=fxDDReadDepthPixels; - ctx->Driver.GetString=fxDDGetString; - - ctx->Driver.Dither=fxDDDither; - - ctx->Driver.NearFar=fxDDSetNearFar; - - ctx->Driver.GetParameteri=fxDDGetParameteri; - - ctx->Driver.ClearIndex=NULL; - ctx->Driver.ClearColor=fxDDClearColor; - ctx->Driver.Clear=fxDDClear; - - ctx->Driver.Index=NULL; - ctx->Driver.Color=fxDDSetColor; - - ctx->Driver.SetDrawBuffer=fxDDSetDrawBuffer; - ctx->Driver.SetReadBuffer=fxDDSetReadBuffer; - ctx->Driver.GetBufferSize=fxDDBufferSize; - - ctx->Driver.Bitmap=fxDDDrawBitMap; - ctx->Driver.DrawPixels=NULL; - - ctx->Driver.Finish=fxDDFinish; - ctx->Driver.Flush=NULL; + if (ctx->Visual->RedBits == 8 && + ctx->Visual->GreenBits == 8 && + ctx->Visual->BlueBits == 8 && + ctx->Visual->AlphaBits == 8) { + ctx->Driver.Bitmap = bitmap_R8G8B8A8; + ctx->Driver.DrawPixels = NULL; + ctx->Driver.ReadPixels = NULL; + } + else { + ctx->Driver.Bitmap = bitmap_R5G6B5; + ctx->Driver.DrawPixels = NULL; + ctx->Driver.ReadPixels = readpixels_R5G6B5; + } ctx->Driver.RenderStart=NULL; ctx->Driver.RenderFinish=NULL; + ctx->Driver.TexImage2D = fxDDTexImage2D; + ctx->Driver.TexSubImage2D = fxDDTexSubImage2D; + ctx->Driver.GetTexImage = fxDDGetTexImage; ctx->Driver.TexEnv=fxDDTexEnv; - ctx->Driver.TexImage=fxDDTexImg; - ctx->Driver.TexSubImage=fxDDTexSubImg; ctx->Driver.TexParameter=fxDDTexParam; ctx->Driver.BindTexture=fxDDTexBind; ctx->Driver.DeleteTexture=fxDDTexDel; ctx->Driver.UpdateTexturePalette=fxDDTexPalette; - ctx->Driver.UseGlobalTexturePalette=fxDDTexUseGlbPalette; ctx->Driver.RectFunc=NULL; + if (fxMesa->haveHwStencil) { + ctx->Driver.StencilFunc = fxDDStencilFunc; + ctx->Driver.StencilMask = fxDDStencilMask; + ctx->Driver.StencilOp = fxDDStencilOp; + } + ctx->Driver.AlphaFunc=fxDDAlphaFunc; ctx->Driver.BlendFunc=fxDDBlendFunc; ctx->Driver.DepthFunc=fxDDDepthFunc; @@ -1031,6 +1474,7 @@ void fxSetupDDPointers(GLcontext *ctx) } + #else diff --git a/xc/extras/Mesa/src/FX/fxddspan.c b/xc/extras/Mesa/src/FX/fxddspan.c index ec5513480..2c53da8d3 100644 --- a/xc/extras/Mesa/src/FX/fxddspan.c +++ b/xc/extras/Mesa/src/FX/fxddspan.c @@ -46,33 +46,193 @@ /* fxdd.c - 3Dfx VooDoo Mesa span and pixel functions */ -#ifdef HAVE_CONFIG_H -#include "conf.h" -#endif +#include "fxdrv.h" -#if defined(FX) -#include "fxdrv.h" -#ifdef _MSC_VER -#ifdef _WIN32 -#pragma warning( disable : 4090 4022 ) -/* 4101 : "different 'const' qualifier" - * 4022 : "pointer mistmatch for actual parameter 'n' +/* + * Examine the cliprects to generate an array of flags to indicate + * which pixels in a span are visible. Note: (x,y) is a screen + * coordinate. */ -#endif -#endif +static void +generate_vismask(const fxMesaContext fxMesa, GLint x, GLint y, GLint n, + GLubyte vismask[]) +{ + GLboolean initialized = GL_FALSE; + GLint i, j; + + /* turn on flags for all visible pixels */ + for (i = 0; i < fxMesa->numClipRects; i++) { + const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i]; + + if (y >= rect->y1 && y < rect->y2) { + if (x >= rect->x1 && x + n <= rect->x2) { + /* common case, whole span inside cliprect */ + MEMSET(vismask, 1, n); + return; + } + if (x < rect->x2 && x + n >= rect->x1) { + /* some of the span is inside the rect */ + GLint start, end; + if (!initialized) { + MEMSET(vismask, 0, n); + initialized = GL_TRUE; + } + if (x < rect->x1) + start = rect->x1 - x; + else + start = 0; + if (x + n > rect->x2) + end = rect->x2 - x; + else + end = n; + assert(start >= 0); + assert(end <= n); + for (j = start; j < end; j++) + vismask[j] = 1; + } + } + } +} -#if !defined(FXMESA_USE_ARGB) +/* + * Examine cliprects and determine if the given screen pixel is visible. + */ +static GLboolean +visible_pixel(const fxMesaContext fxMesa, int scrX, int scrY) +{ + int i; + for (i = 0; i < fxMesa->numClipRects; i++) { + const XF86DRIClipRectPtr rect = &fxMesa->pClipRects[i]; + if (scrX >= rect->x1 && + scrX < rect->x2 && + scrY >= rect->y1 && + scrY < rect->y2) + return GL_TRUE; + } + return GL_FALSE; +} -#if defined(FX_GLIDE3) && defined(XF86DRI) + +typedef enum { FBS_READ, FBS_WRITE } FBS_DIRECTION; +/* + * Read or write a single span from the frame buffer. + * Input Parameters: + * fxMesa: The context + * target_buffer: Which buffer to read from. + * xpos, ypos: Starting Coordinates. + * xlength: Length of the span. + * data_size: Size of data elements: 1, 2, or 4. + * buffer: Pointer to the buffer to read + * to or write from. This needs + * to be turned into a pointer. + * direction: Read or Write. + */ +static void +rw_fb_span(fxMesaContext fxMesa, + GrBuffer_t target_buffer, + FxU32 xpos, + FxU32 ypos, + FxU32 xlength, + FxU32 data_size, + void *buffer, + FBS_DIRECTION direction) +{ + GrLfbInfo_t info; + BEGIN_BOARD_LOCK(); + info.size=sizeof(info); + + if (grLfbLock(direction == FBS_READ ? GR_LFB_READ_ONLY : GR_LFB_WRITE_ONLY, + target_buffer, + GR_LFBWRITEMODE_ANY, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winX = fxMesa->x_offset; + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; +#ifdef XF86DRI + /* stride in data elements */ + const GLint srcStride = + (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + ? (fxMesa->screen_width) + : (info.strideInBytes / data_size); +#else + /* stride in data elements */ + const GLint srcStride = info.strideInBytes / data_size; +#endif + GLushort *data16 = (GLushort *) info.lfbPtr + + (winY - ypos) * srcStride + + (winX + xpos); + GLubyte *target16 = (GLubyte *) buffer; + GLubyte *data8 = (GLubyte *) data16; + GLubyte *target8 = (GLubyte *) buffer; + GLuint *data32 = (GLuint *) data16; + GLuint *target32 = (GLuint *) buffer; + GLuint i, j; + + for (i = j = 0; i < xlength; i += 1, j += 1) { + switch (data_size) { + case 1: + switch (direction) { + case FBS_READ: + *target8++ = *data8++; + break; + case FBS_WRITE: + *data8++ = *target8++; + break; + } + break; + case 2: + switch (direction) { + case FBS_READ: + *target16++ = *data16++; + break; + case FBS_WRITE: + *data16++ = *target16++; + break; + } + break; + case 4: + switch (direction) { + case FBS_READ: + *target32++ = *data32++; + break; + case FBS_WRITE: + *data32++ = *target32++; + break; + } + break; + } + } + grLfbUnlock(direction == FBS_READ ? GR_LFB_READ_ONLY : GR_LFB_WRITE_ONLY, + target_buffer); + } + END_BOARD_LOCK(); +} + +static FxBool +fb_point_is_clipped(fxMesaContext fxMesa, + FxU32 dst_x, FxU32 dst_y) +{ + int i; + for (i=0; i<fxMesa->numClipRects; i++) { + if ((dst_x>=fxMesa->pClipRects[i].x1) && + (dst_x<fxMesa->pClipRects[i].x2) && + (dst_y>=fxMesa->pClipRects[i].y1) && + (dst_y<fxMesa->pClipRects[i].y2)) { + return GL_FALSE; + } + } + return GL_TRUE; +} static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, - FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, - FxU32 src_width, FxU32 src_height, FxI32 src_stride, - void *src_data) + FxU32 dst_x, FxU32 dst_y, GrLfbSrcFmt_t src_format, + FxU32 src_width, FxU32 src_height, FxI32 src_stride, + void *src_data) { int i, x, w, srcElt; void *data; @@ -80,12 +240,12 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, if (src_width==1 && src_height==1) { /* Easy case writing a point */ for (i=0; i<fxMesa->numClipRects; i++) { if ((dst_x>=fxMesa->pClipRects[i].x1) && - (dst_x<fxMesa->pClipRects[i].x2) && - (dst_y>=fxMesa->pClipRects[i].y1) && - (dst_y<fxMesa->pClipRects[i].y2)) { - FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format, - 1, 1, src_stride, src_data); - return GL_TRUE; + (dst_x<fxMesa->pClipRects[i].x2) && + (dst_y>=fxMesa->pClipRects[i].y1) && + (dst_y<fxMesa->pClipRects[i].y2)) { + FX_grLfbWriteRegion(dst_buffer, dst_x, dst_y, src_format, + 1, 1, src_stride, src_data); + return GL_TRUE; } } } else if (src_height==1) { /* Writing a span */ @@ -97,20 +257,20 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, } for (i=0; i<fxMesa->numClipRects; i++) { if (dst_y>=fxMesa->pClipRects[i].y1 && dst_y<fxMesa->pClipRects[i].y2) { - if (dst_x<fxMesa->pClipRects[i].x1) { - x=fxMesa->pClipRects[i].x1; - data=((char*)src_data)+srcElt*(dst_x-x); - w=src_width-(x-dst_x); - } else { - x=dst_x; - data=src_data; - w=src_width; - } - if (x+w>fxMesa->pClipRects[i].x2) { - w=fxMesa->pClipRects[i].x2-x; - } - FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, 1, - src_stride, data); + if (dst_x<fxMesa->pClipRects[i].x1) { + x=fxMesa->pClipRects[i].x1; + data=((char*)src_data)+srcElt*(x - dst_x); + w=src_width-(x-dst_x); + } else { + x=dst_x; + data=src_data; + w=src_width; + } + if (x+w>fxMesa->pClipRects[i].x2) { + w=fxMesa->pClipRects[i].x2-x; + } + FX_grLfbWriteRegion(dst_buffer, x, dst_y, src_format, w, 1, + src_stride, data); } } } else { /* Punt on the case of arbitrary rectangles */ @@ -119,88 +279,42 @@ static FxBool writeRegionClipped(fxMesaContext fxMesa, GrBuffer_t dst_buffer, return GL_TRUE; } -#else - -#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ - FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) - -#endif /* KW: Rearranged the args in the call to grLfbWriteRegion(). */ -#define LFB_WRITE_SPAN_MESA(dst_buffer, \ - dst_x, \ - dst_y, \ - src_width, \ - src_stride, \ - src_data) \ - writeRegionClipped(fxMesa, dst_buffer, \ - dst_x, \ - dst_y, \ - GR_LFB_SRC_FMT_8888, \ - src_width, \ - 1, \ - src_stride, \ - src_data) \ - - -#else /* !defined(FXMESA_USE_RGBA) */ - -#define writeRegionClipped(fxm,dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \ - FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) - - -#define MESACOLOR_TO_ARGB(c) ( \ - ( ((unsigned int)(c[ACOMP]))<<24 ) | \ - ( ((unsigned int)(c[RCOMP]))<<16 ) | \ - ( ((unsigned int)(c[GCOMP]))<<8 ) | \ - ( (unsigned int)(c[BCOMP])) ) - -inline void LFB_WRITE_SPAN_MESA(GrBuffer_t dst_buffer, - FxU32 dst_x, - FxU32 dst_y, - FxU32 src_width, - FxI32 src_stride, - void *src_data ) -{ - /* Covert to ARGB */ - GLubyte (*rgba)[4] = src_data; - GLuint argb[MAX_WIDTH]; - int i; - - for (i = 0; i < src_width; i++) - { - argb[i] = MESACOLOR_TO_ARGB(rgba[i]); - } - writeRegionClipped( /*fxMesa,*/ NULL, dst_buffer, - dst_x, - dst_y, - GR_LFB_SRC_FMT_8888, - src_width, - 1, - src_stride, - (void*)argb); -} - -#endif /* !defined(FXMESA_USE_RGBA) */ +#define LFB_WRITE_SPAN_MESA(dst_buffer, \ + dst_x, \ + dst_y, \ + src_width, \ + src_stride, \ + src_data) \ + writeRegionClipped(fxMesa, dst_buffer, \ + dst_x, \ + dst_y, \ + GR_LFB_SRC_FMT_8888, \ + src_width, \ + 1, \ + src_stride, \ + src_data) \ -/************************************************************************/ -/***** Span functions *****/ -/************************************************************************/ -static void fxDDWriteRGBASpan(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte rgba[][4], const GLubyte mask[]) +/* + * 16bpp span/pixel functions + */ + +static void +write_R5G6B5_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n"); + fprintf(stderr,"fxmesa: fxDDWriteRGBASpan(...)\n"); } x+=fxMesa->x_offset; @@ -213,7 +327,7 @@ static void fxDDWriteRGBASpan(const GLcontext *ctx, } else { if (span > 0) { LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y, - /* GR_LFB_SRC_FMT_8888,*/ span, /*1,*/ 0, (void *) rgba[i-span] ); + /* GR_LFB_SRC_FMT_8888,*/ span, /*1,*/ 0, (void *) rgba[i-span] ); span = 0; } } @@ -221,16 +335,16 @@ static void fxDDWriteRGBASpan(const GLcontext *ctx, if (span > 0) LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y, - /* GR_LFB_SRC_FMT_8888, */ span, /*1,*/ 0, (void *) rgba[n-span] ); + /* GR_LFB_SRC_FMT_8888, */ span, /*1,*/ 0, (void *) rgba[n-span] ); } else LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/ - n,/* 1,*/ 0, (void *) rgba ); + n,/* 1,*/ 0, (void *) rgba ); } -static void fxDDWriteRGBSpan(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte rgb[][3], const GLubyte mask[]) +static void +write_R5G6B5_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgb[][3], const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; @@ -238,7 +352,7 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx, GLubyte rgba[MAX_WIDTH][4]; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n"); + fprintf(stderr,"fxmesa: fxDDWriteRGBSpan()\n"); } x+=fxMesa->x_offset; @@ -255,7 +369,7 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx, } else { if (span > 0) { LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+i-span, bottom-y, - /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba ); + /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba ); span = 0; } } @@ -263,7 +377,7 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx, if (span > 0) LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x+n-span, bottom-y, - /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba ); + /*GR_LFB_SRC_FMT_8888,*/ span,/* 1,*/ 0, (void *) rgba ); } else { for (i=0;i<n;i++) { rgba[i][RCOMP]=rgb[i][0]; @@ -273,14 +387,14 @@ static void fxDDWriteRGBSpan(const GLcontext *ctx, } LFB_WRITE_SPAN_MESA( fxMesa->currentFB, x, bottom-y,/* GR_LFB_SRC_FMT_8888,*/ - n,/* 1,*/ 0, (void *) rgba ); + n,/* 1,*/ 0, (void *) rgba ); } } -static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, - GLuint n, GLint x, GLint y, - const GLubyte mask[]) +static void +write_R5G6B5_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; @@ -288,7 +402,7 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, GLuint data[MAX_WIDTH]; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n"); + fprintf(stderr,"fxmesa: fxDDWriteMonoRGBASpan(...)\n"); } x+=fxMesa->x_offset; @@ -302,8 +416,8 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, } else { if (span > 0) { writeRegionClipped(fxMesa, fxMesa->currentFB, x+i-span, bottom-y, - GR_LFB_SRC_FMT_8888, span, 1, 0, - (void *) data ); + GR_LFB_SRC_FMT_8888, span, 1, 0, + (void *) data ); span = 0; } } @@ -311,95 +425,129 @@ static void fxDDWriteMonoRGBASpan(const GLcontext *ctx, if (span > 0) writeRegionClipped(fxMesa, fxMesa->currentFB, x+n-span, bottom-y, - GR_LFB_SRC_FMT_8888, span, 1, 0, - (void *) data ); + GR_LFB_SRC_FMT_8888, span, 1, 0, + (void *) data ); } else { for (i=0;i<n;i++) { data[i]=(GLuint) fxMesa->color; } writeRegionClipped(fxMesa, fxMesa->currentFB, x, bottom-y, GR_LFB_SRC_FMT_8888, - n, 1, 0, (void *) data ); + n, 1, 0, (void *) data ); } } -static void fxDDReadRGBASpan(const GLcontext *ctx, - GLuint n, GLint x, GLint y, GLubyte rgba[][4]) +/* + * Read a span of 16-bit RGB pixels. Note, we don't worry about cliprects + * since OpenGL says obscured pixels have undefined values. + */ +static void +read_R5G6B5_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLushort data[MAX_WIDTH]; - GLuint i; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; - - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDReadRGBASpan(...)\n"); - } - - assert(n < MAX_WIDTH); - - x+=fxMesa->x_offset; - FX_grLfbReadRegion( fxMesa->currentFB, x, bottom-y, n, 1, 0, data); + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbInfo_t info; + BEGIN_BOARD_LOCK(); + info.size=sizeof(info); + if (grLfbLock(GR_LFB_READ_ONLY, + fxMesa->currentFB, + GR_LFBWRITEMODE_ANY, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winX = fxMesa->x_offset; + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; +#ifdef XF86DRI + const GLint srcStride = (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + ? (fxMesa->screen_width) : (info.strideInBytes / 2); +#else + const GLint srcStride = info.strideInBytes / 2; /* stride in GLushorts */ +#endif + const GLushort *data16 = (const GLushort *) info.lfbPtr + + (winY - y) * srcStride + + (winX + x); + const GLuint *data32 = (const GLuint *) data16; + GLuint i, j; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = j = 0; i < n; i += 2, j++) { + GLuint pixel = data32[j]; + GLuint pixel0 = pixel & 0xffff; + GLuint pixel1 = pixel >> 16; + rgba[i][RCOMP] = FX_PixelToR[pixel0]; + rgba[i][GCOMP] = FX_PixelToG[pixel0]; + rgba[i][BCOMP] = FX_PixelToB[pixel0]; + rgba[i][ACOMP] = 255; + rgba[i+1][RCOMP] = FX_PixelToR[pixel1]; + rgba[i+1][GCOMP] = FX_PixelToG[pixel1]; + rgba[i+1][BCOMP] = FX_PixelToB[pixel1]; + rgba[i+1][ACOMP] = 255; + } + if (extraPixel) { + GLushort pixel = data16[n]; + rgba[n][RCOMP] = FX_PixelToR[pixel]; + rgba[n][GCOMP] = FX_PixelToG[pixel]; + rgba[n][BCOMP] = FX_PixelToB[pixel]; + rgba[n][ACOMP] = 255; + } - for (i=0;i<n;i++) { - GLushort pixel = data[i]; - rgba[i][RCOMP] = FX_PixelToR[pixel]; - rgba[i][GCOMP] = FX_PixelToG[pixel]; - rgba[i][BCOMP] = FX_PixelToB[pixel]; - rgba[i][ACOMP] = 255; + grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); } + END_BOARD_LOCK(); } -/************************************************************************/ -/***** Pixel functions *****/ -/************************************************************************/ -static void fxDDWriteRGBAPixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - CONST GLubyte rgba[][4], const GLubyte mask[]) +static void +write_R5G6B5_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n"); + fprintf(stderr,"fxmesa: fxDDWriteRGBAPixels(...)\n"); } for(i=0;i<n;i++) if(mask[i]) - LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i], - 1, 1, (void *)rgba[i]); + LFB_WRITE_SPAN_MESA(fxMesa->currentFB, x[i]+fxMesa->x_offset, bottom-y[i], + 1, 1, (void *)rgba[i]); } -static void fxDDWriteMonoRGBAPixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - const GLubyte mask[]) + +static void +write_R5G6B5_mono_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n"); + fprintf(stderr,"fxmesa: fxDDWriteMonoRGBAPixels(...)\n"); } for(i=0;i<n;i++) if(mask[i]) writeRegionClipped(fxMesa, fxMesa->currentFB,x[i]+fxMesa->x_offset,bottom-y[i], - GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color); + GR_LFB_SRC_FMT_8888,1,1,0,(void *) &fxMesa->color); } -static void fxDDReadRGBAPixels(const GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[]) +static void +read_R5G6B5_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[]) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; GLuint i; - GLint bottom=fxMesa->y_delta-1; + GLint bottom=fxMesa->height+fxMesa->y_offset-1; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n"); + fprintf(stderr,"fxmesa: fxDDReadRGBAPixels(...)\n"); } for(i=0;i<n;i++) { @@ -415,19 +563,663 @@ static void fxDDReadRGBAPixels(const GLcontext *ctx, } -/************************************************************************/ -/***** Depth functions *****/ -/************************************************************************/ +/* + * 24bpp span/pixel functions + */ + +static void +write_R8G8B8_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgb[][3], const GLubyte mask[]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + mode = GR_LFBWRITEMODE_888; + else + mode = GR_LFBWRITEMODE_888; + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_WRITE_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x; + const GLint scrY = winY - y; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + /*GLint dstStride = fxMesa->screen_width * 3;*/ + GLint dstStride = info.strideInBytes / 1; + GLubyte *dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 1; + GLuint *dst32 = (GLuint *) dst; + GLubyte visMask[MAX_WIDTH]; + GLuint i; + generate_vismask(fxMesa, scrX, scrY, n, visMask); + for (i = 0; i < n; i++) { + if (visMask[i] && (!mask || mask[i])) { + dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255); + } + } + } + else { + /* back buffer */ + GLint dstStride = info.strideInBytes; + GLubyte *dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 4; + GLuint *dst32 = (GLuint *) dst; + if (mask) { + GLuint i; + for (i = 0; i < n; i++) { + if (mask[i]) { + dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255); + } + } + } + else { + GLuint i; + for (i = 0; i < n; i++) { + dst32[i] = PACK_RGBA32(rgb[i][2], rgb[i][1], rgb[i][0], 255); + } + } + } + grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); + } + END_BOARD_LOCK(); +} + + + +static void +write_R8G8B8_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], const GLubyte mask[]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + mode = GR_LFBWRITEMODE_8888; + else + mode = GR_LFBWRITEMODE_888 /*565*/; + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_WRITE_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x; + const GLint scrY = winY - y; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + /* XXX have to do cliprect clipping! */ + GLint dstStride = fxMesa->screen_width * 4; + GLubyte *dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 4; + GLuint *dst32 = (GLuint *) dst; + GLubyte visMask[MAX_WIDTH]; + GLuint i; + generate_vismask(fxMesa, scrX, scrY, n, visMask); + for (i = 0; i < n; i++) { + if (visMask[i] && (!mask || mask[i])) { + dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]); + } + } + } + else { + /* back buffer */ + GLint dstStride = info.strideInBytes; + GLubyte *dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 4; + if (mask) { + const GLuint *src32 = (const GLuint *) rgba; + GLuint *dst32 = (GLuint *) dst; + GLuint i; + for (i = 0; i < n; i++) { + if (mask[i]) { + dst32[i] = src32[i]; + } + } + } + else { + /* no mask, write all pixels */ + MEMCPY(dst, rgba, 4 * n); + } + } + grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); + } + END_BOARD_LOCK(); +} + + +static void +write_R8G8B8_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte mask[]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GLubyte rgba[MAX_WIDTH][4]; + GLuint *data = (GLuint *) rgba; + GLuint i; + + /* XXX this is a simple-minded implementation but good enough for now */ + for (i = 0; i < n; i++) { + data[i] = (GLuint) fxMesa->color; + } + write_R8G8B8_rgba_span(ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask); +} + + +static void +read_R8G8B8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; + + if (1 || fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + mode = GR_LFBWRITEMODE_8888; + } + else { + mode = GR_LFBWRITEMODE_565; /*888*/ /*565*/; + } + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_READ_ONLY, + fxMesa->currentFB, + mode, /*GR_LFBWRITEMODE_ANY,*/ + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + GLint srcStride = fxMesa->screen_width * 4; + const GLubyte *src = (const GLubyte *) info.lfbPtr + + (winY - y) * srcStride + (winX + x) * 4; + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][0] = src[i * 4 + 2]; + rgba[i][1] = src[i * 4 + 1]; + rgba[i][2] = src[i * 4 + 0]; + rgba[i][3] = src[i * 4 + 3]; + } + } + else { + /* back buffer */ + GLint srcStride = /*info.strideInBytes;*/ 8192 / 2; /* XXX a hack! */ + const GLubyte *src = (const GLubyte *) info.lfbPtr + + (winY - y) * srcStride + (winX + x) * 4; + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][0] = src[i * 4 + 2]; + rgba[i][1] = src[i * 4 + 1]; + rgba[i][2] = src[i * 4 + 0]; + rgba[i][3] = src[i * 4 + 3]; + } + } + grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); + } + END_BOARD_LOCK(); +} + + +static void +write_R8G8B8_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[]) +{ +#if 00 + GLuint i; + for (i = 0; i < n; i++) { + write_R8G8B8_rgba_span(ctx, 1, x[i], y[i], rgba + i, mask + i); + } + +#else + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + mode = GR_LFBWRITEMODE_8888; + else + mode = GR_LFBWRITEMODE_888 /*565*/; + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_WRITE_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + GLuint i; + for (i = 0; i < n; i++) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x[i]; + const GLint scrY = winY - y[i]; + if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) { + GLint dstStride = fxMesa->screen_width * 4; + GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4; + GLuint *dst32 = (GLuint *) dst; + *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1], + rgba[i][2], rgba[i][3]); + } + } + } + else { + /* back buffer */ + GLuint i; + for (i = 0; i < n; i++) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x[i]; + const GLint scrY = winY - y[i]; + if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) { + GLint dstStride = info.strideInBytes; + GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4; + GLuint *dst32 = (GLuint *) dst; + const GLuint *src32 = (const GLuint *) rgba; + *dst32 = src32[i]; + } + } + } + grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); + } + END_BOARD_LOCK(); +#endif +} + + +static void +write_R8G8B8_mono_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[]) +{ +} + + +static void +read_R8G8B8_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[]) +{ + printf("read_R8G8B8_pixels %d\n", n); +} + + + +/* + * 32bpp span/pixel functions + */ + +static void +write_R8G8B8A8_rgb_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgb[][3], const GLubyte mask[]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + mode = GR_LFBWRITEMODE_8888; + else + mode = GR_LFBWRITEMODE_888 /*565*/; + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_WRITE_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x; + const GLint scrY = winY - y; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + GLint dstStride = fxMesa->screen_width * 4; + GLubyte * dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 4; + GLuint *dst32 = (GLuint *) dst; + GLubyte visMask[MAX_WIDTH]; + GLuint i; + generate_vismask(fxMesa, scrX, scrY, n, visMask); + for (i = 0; i < n; i++) { + if (visMask[i] && (!mask || mask[i])) { + dst32[i] = PACK_BGRA32(rgb[i][0], rgb[i][1], rgb[i][2], 255); + } + } + } + else { + /* back buffer */ + GLint dstStride = info.strideInBytes; + GLubyte *dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 4; + if (mask) { + GLuint *dst32 = (GLuint *) dst; + GLuint i; + for (i = 0; i < n; i++) { + if (mask[i]) { + dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255); + } + } + } + else { + GLuint *dst32 = (GLuint *) dst; + GLuint i; + for (i = 0; i < n; i++) { + dst32[i] = PACK_RGBA32(rgb[i][0], rgb[i][1], rgb[i][2], 255); + } + } + } + grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); + } + END_BOARD_LOCK(); +} + + +/* + *XXX test of grLfbWriteRegion in 32bpp mode. Doesn't seem to work! + */ +#if 0 +static void +write_R8G8B8A8_rgb_span2(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgb[][3], const GLubyte mask[]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; + GLint x2 = fxMesa->x_offset +x; + GLint y2 = bottom - y; + + FX_grLfbWriteRegion(fxMesa->currentFB, x2, y2, GR_LFB_SRC_FMT_888, + n, 1, 0, rgb); +} +#endif + + +static void +write_R8G8B8A8_rgba_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], const GLubyte mask[]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + mode = GR_LFBWRITEMODE_8888; + else + mode = GR_LFBWRITEMODE_888 /*565*/; + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_WRITE_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x; + const GLint scrY = winY - y; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + GLint dstStride = fxMesa->screen_width * 4; + GLubyte *dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 4; + GLuint *dst32 = (GLuint *) dst; + GLubyte visMask[MAX_WIDTH]; + GLuint i; + generate_vismask(fxMesa, scrX, scrY, n, visMask); + for (i = 0; i < n; i++) { + if (visMask[i] && (!mask || mask[i])) { + dst32[i] = PACK_BGRA32(rgba[i][0], rgba[i][1], rgba[i][2], rgba[i][3]); + } + } + } + else { + /* back buffer */ + GLint dstStride = 8192; /* XXX a hack info.strideInBytes; */ + GLubyte *dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 4; + if (mask) { + const GLuint *src32 = (const GLuint *) rgba; + GLuint *dst32 = (GLuint *) dst; + GLuint i; + for (i = 0; i < n; i++) { + if (mask[i]) { + dst32[i] = src32[i]; + } + } + } + else { + /* no mask, write all pixels */ + MEMCPY(dst, rgba, 4 * n); + } + } + grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); + } + else { + info.strideInBytes = -1; + } + END_BOARD_LOCK(); +} + + +static void +write_R8G8B8A8_mono_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLubyte mask[]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GLubyte rgba[MAX_WIDTH][4]; + GLuint *data = (GLuint *) rgba; + GLuint i; + + /* XXX this is a simple-minded implementation but good enough for now */ + for (i = 0; i < n; i++) { + data[i] = (GLuint) fxMesa->color; + } + write_R8G8B8A8_rgba_span(ctx, n, x, y, (const GLubyte (*)[4]) rgba, mask); +} + + +static void +read_R8G8B8A8_span(const GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + mode = GR_LFBWRITEMODE_8888; + } + else { + mode = GR_LFBWRITEMODE_8888; /*565;*/ + } + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_READ_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + GLint srcStride = fxMesa->screen_width; + const GLuint *src32 = (const GLuint *) info.lfbPtr + + (winY - y) * srcStride + (winX + x); + GLuint i; + for (i = 0; i < n; i++) { + const GLuint p = src32[i]; + rgba[i][0] = (p >> 16) & 0xff; + rgba[i][1] = (p >> 8) & 0xff; + rgba[i][2] = (p >> 0) & 0xff; + rgba[i][3] = (p >> 24) & 0xff; + } + } + else { + /* back buffer */ + GLint srcStride = 1024; /* XXX a hack */ + const GLuint *src32 = (const GLuint *) info.lfbPtr + + (winY - y) * srcStride + (winX + x); + GLuint i; + for (i = 0; i < n; i++) { + GLuint p = src32[i]; + rgba[i][0] = (p >> 16) & 0xff; + rgba[i][1] = (p >> 8) & 0xff; + rgba[i][2] = (p >> 0) & 0xff; + rgba[i][3] = (p >> 24) & 0xff; + } + } + grLfbUnlock(GR_LFB_READ_ONLY, fxMesa->currentFB); + } + else + info.strideInBytes = -1; + END_BOARD_LOCK(); +} + + +static void +write_R8G8B8A8_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[]) +{ +#if 00 + GLuint i; + for (i = 0; i < n; i++) { + write_R8G8B8A8_rgba_span(ctx, 1, x[i], y[i], rgba + i, mask + i); + } + +#else + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbWriteMode_t mode; + GrLfbInfo_t info; + + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) + mode = GR_LFBWRITEMODE_8888; + else + mode = GR_LFBWRITEMODE_888 /*565*/; + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_WRITE_ONLY, + fxMesa->currentFB, + mode, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + if (fxMesa->glCtx->Color.DrawBuffer == GL_FRONT) { + GLuint i; + for (i = 0; i < n; i++) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x[i]; + const GLint scrY = winY - y[i]; + if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) { + GLint dstStride = fxMesa->screen_width * 4; + GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4; + GLuint *dst32 = (GLuint *) dst; + *dst32 = PACK_BGRA32(rgba[i][0], rgba[i][1], + rgba[i][2], rgba[i][3]); + } + } + } + else { + /* back buffer */ + GLuint i; + for (i = 0; i < n; i++) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x[i]; + const GLint scrY = winY - y[i]; + if (mask[i] && visible_pixel(fxMesa, scrX, scrY)) { + GLint dstStride = info.strideInBytes; + GLubyte *dst = (GLubyte *) info.lfbPtr + scrY * dstStride + scrX * 4; + GLuint *dst32 = (GLuint *) dst; + const GLuint *src32 = (const GLuint *) rgba; + *dst32 = src32[i]; + } + } + } + grLfbUnlock(GR_LFB_WRITE_ONLY, fxMesa->currentFB); + } + END_BOARD_LOCK(); +#endif +} + + +static void +write_R8G8B8A8_mono_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[]) +{ + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLuint i; + GLuint color = fxMesa->color; + for (i = 0; i < n; i++) { + if (mask[i]) { + write_R8G8B8A8_rgba_span(ctx, 1, x[i], y[i], + (const GLubyte (*)[4]) &color, mask + i); + } + } +} + + + +static void +read_R8G8B8A8_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[]) +{ + GLuint i; + for (i = 0; i < n; i++) { + if (mask[i]) { + read_R8G8B8A8_span(ctx, 1, x[i], y[i], rgba + i); + } + } + printf("read_R8G8B8A8_pixels %d\n", n); +} + + + +/* + * Depth buffer read/write functions. + */ void fxDDWriteDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth depth[], const GLubyte mask[]) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; + GLuint depth_size = fxMesa->glVis->DepthBits; + GLuint stencil_size = fxMesa->glVis->StencilBits; - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n"); + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDWriteDepthSpan(...)\n"); } x += fxMesa->x_offset; @@ -436,14 +1228,77 @@ void fxDDWriteDepthSpan(GLcontext *ctx, GLint i; for (i = 0; i < n; i++) { if (mask[i]) { - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom-y, - GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &depth[i]); + GLshort d16; + GLuint d32; + switch (depth_size) { + case 16: + d16 = depth[i]; + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x + i, bottom - y, + GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &d16); + break; + case 32: + if (!fb_point_is_clipped(fxMesa, x+i, bottom-y)) { + if (stencil_size > 0) { + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + x + i, bottom - y, + 1, + sizeof(GLdepth), + &d32, + FBS_READ); + d32 = depth[i] & 0xFF000000; + break; + } else { + d32 = depth[i]; + } + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + x + i, bottom - y, + 1, + sizeof(GLdepth), + &d32, + FBS_WRITE); + } + } } } - } - else { - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom-y, - GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth); + } else { + GLushort depth16[MAX_WIDTH]; + GLint i; + GLuint d32; + switch (depth_size) { + case 16: + for (i = 0; i < n; i++) { + depth16[i] = depth[i]; + } + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, x, bottom - y, + GR_LFB_SRC_FMT_ZA16, n, 1, 0, (void *) depth16); + break; + case 32: + for (i = 0; i < n; i++) { + if (fb_point_is_clipped(fxMesa, x+i, bottom-y)) { + if (stencil_size > 0) { + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + x + i, bottom - y, + 1, + sizeof(GLdepth), + &d32, + FBS_READ); + d32 = (d32 & 0xFF0000) | (depth[i] & 0x00FFFFFF); + } else { + d32 = depth[i]; + } + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + x + i, bottom - y, + 1, + sizeof(GLdepth), + &d32, + FBS_WRITE); + } + } + } } } @@ -451,15 +1306,39 @@ void fxDDWriteDepthSpan(GLcontext *ctx, void fxDDReadDepthSpan(GLcontext *ctx, GLuint n, GLint x, GLint y, GLdepth depth[]) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; + GLushort depth16[MAX_WIDTH]; + GLuint i; + GLuint depth_size = fxMesa->glVis->DepthBits; + GLuint stencil_size = fxMesa->glVis->StencilBits; - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n"); + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDReadDepthSpan(...)\n"); } - x+=fxMesa->x_offset; - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,x,bottom-y,n,1,0,depth); + x += fxMesa->x_offset; + switch (depth_size) { + case 16: + FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, x, bottom - y, n, 1, 0, depth16); + for (i = 0; i < n; i++) { + depth[i] = depth16[i]; + } + break; + case 32: + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + x, bottom - y, + n, + sizeof(GLdepth), + depth, + FBS_READ); + if (stencil_size > 0) { + for (i = 0; i < n; i++) { + depth[i] &= 0xFFFFFF; + } + } + } } @@ -468,20 +1347,56 @@ void fxDDWriteDepthPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLdepth depth[], const GLubyte mask[]) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; GLuint i; + GLuint d32; + GLuint depth_size = fxMesa->glVis->DepthBits; + GLuint stencil_size = fxMesa->glVis->StencilBits; - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n"); + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDWriteDepthPixels(...)\n"); } for (i = 0; i < n; i++) { if (mask[i]) { int xpos = x[i] + fxMesa->x_offset; int ypos = bottom - y[i]; - writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos, - GR_LFB_SRC_FMT_ZA16, 1, 1, 0, (void *) &depth[i]); + GLushort d16 = depth[i]; + switch (depth_size) { + case 16: + writeRegionClipped(fxMesa, GR_BUFFER_AUXBUFFER, xpos, ypos, + GR_LFB_SRC_FMT_ZA16, 1, 1, 0, + (void *) &d16); + break; + case 32: + if (!fb_point_is_clipped(fxMesa, xpos, ypos)) { + if (stencil_size > 0) { + /* + * Should I sign extend this? I don't + * believe so, since GLdepth is unsigned. + */ + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + sizeof(GLdepth), + &d32, + FBS_READ); + d32 = (d32 &~ 0xFF000000) | (depth[i] & 0x00FFFFFF); + } else { + d32 = depth[i]; + } + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + sizeof(GLdepth), + &d32, + FBS_WRITE); + } + break; + } } } } @@ -490,60 +1405,420 @@ void fxDDWriteDepthPixels(GLcontext *ctx, void fxDDReadDepthPixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], GLdepth depth[]) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - GLint bottom=fxMesa->height+fxMesa->y_offset-1; + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; GLuint i; - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDReadDepthSpanInt(...)\n"); + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDReadDepthPixels(...)\n"); } - for (i = 0; i < n; i++) { int xpos = x[i] + fxMesa->x_offset; int ypos = bottom - y[i]; - FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER,xpos,ypos,1,1,0,&depth[i]); + GLushort d16; + GLuint d32; + GLuint depth_size = fxMesa->glVis->DepthBits; + GLuint stencil_size = fxMesa->glVis->StencilBits; + + assert((depth_size == 16) || (depth_size == 32)); + switch (depth_size) { + case 16: + FX_grLfbReadRegion(GR_BUFFER_AUXBUFFER, xpos, ypos, 1, 1, 0, &d16); + depth[i] = d16; + break; + case 32: + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + depth_size/8, + &d32, + FBS_READ); + /* + * Get rid of the stencil bits. Should I sign + * extend this? I don't believe so, since GLdepth + * is unsigned. + */ + if (stencil_size > 0) { + d32 &= 0xFFFFFF; + } + depth[i] = d32; + break; + default: + assert(0); + } } } +/* + * Stencil buffer read/write functions. + */ +#define DEPTH_VALUE_TO_STENCIL_VALUE(d) (((d) >> 24) & 0xFF) +#define STENCIL_VALUE_TO_DEPTH_VALUE(s,d) \ + ((((s) & 0xFF) << 24) | ((d) & 0xFFFFFF)) +#define ASSEMBLE_STENCIL_VALUE(os, ns, mask) \ + (((os) &~ (mask)) | ((ns) & (mask))) -/************************************************************************/ +#if 00 +/* + * Read a horizontal span of stencil values from the stencil buffer. + */ +void +fxDDReadStencilSpan( GLcontext *ctx, + GLuint n, + GLint x, + GLint y, + GLstencil stencil[] ) +{ + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; + GLuint i; + int xpos = x + fxMesa->x_offset; + int ypos = bottom - y; + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDReadStencilSpan(...)\n"); + } -void fxSetupDDSpanPointers(GLcontext *ctx) -{ - ctx->Driver.WriteRGBASpan =fxDDWriteRGBASpan; - ctx->Driver.WriteRGBSpan =fxDDWriteRGBSpan; - ctx->Driver.WriteMonoRGBASpan =fxDDWriteMonoRGBASpan; - ctx->Driver.WriteRGBAPixels =fxDDWriteRGBAPixels; - ctx->Driver.WriteMonoRGBAPixels =fxDDWriteMonoRGBAPixels; + for (i = 0; i < n; i++, ypos += 1) { + GLuint d; + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + sizeof(GLdepth), + &d, + FBS_READ); + stencil[i] = DEPTH_VALUE_TO_STENCIL_VALUE(d); + } +} - ctx->Driver.WriteCI8Span =NULL; - ctx->Driver.WriteCI32Span =NULL; - ctx->Driver.WriteMonoCISpan =NULL; - ctx->Driver.WriteCI32Pixels =NULL; - ctx->Driver.WriteMonoCIPixels =NULL; +/* + * Write a horizontal span of stencil values into the stencil buffer. + * If mask is NULL, write all stencil values. + * Else, only write stencil[i] if mask[i] is non-zero. + */ +void +fxDDWriteStencilSpan( GLcontext *ctx, + GLuint n, + GLint x, + GLint y, + const GLstencil stencil[], + const GLubyte mask[] ) +{ + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; + GLuint i; + int xpos = x + fxMesa->x_offset; + int ypos = bottom - y; - ctx->Driver.ReadRGBASpan =fxDDReadRGBASpan; - ctx->Driver.ReadRGBAPixels =fxDDReadRGBAPixels; + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDWriteStencilSpan(...)\n"); + } - ctx->Driver.ReadCI32Span =NULL; - ctx->Driver.ReadCI32Pixels =NULL; + for (i = 0; i < n; i++, ypos += 1) { + GLdepth d; + GLstencil ns; + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + sizeof(GLdepth), + &d, + FBS_READ); + /* + * Find the old stencil value, and strip off the bits + * we are going to write. + */ + ns = ASSEMBLE_STENCIL_VALUE(DEPTH_VALUE_TO_STENCIL_VALUE(d), + stencil[i], + mask[i]); + /* + * Now, assemble the new StenDepth value, with the old + * depth value, the old stencil value in the bits + * where mask is 0, and the new stencil value in the bits + * where mask is 1. + */ + d = STENCIL_VALUE_TO_DEPTH_VALUE(ns, d); + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + sizeof(GLdepth), + &d, + FBS_WRITE); + } } +/* Write an array of stencil values into the stencil buffer. + * If mask is NULL, write all stencil values. + * Else, only write stencil[i] if mask[i] is non-zero. + */ +void +fxDDReadStencilPixels( GLcontext *ctx, + GLuint n, + const GLint x[], + const GLint y[], + GLstencil stencil[]) +{ + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; + GLuint i; -#else + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDReadStencilPixels(...)\n"); + } + for (i = 0; i < n; i++) { + int xpos = x[i] + fxMesa->x_offset; + int ypos = bottom - y[i]; + GLuint d; + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + sizeof(GLdepth), + &d, + FBS_READ); + stencil[i] = DEPTH_VALUE_TO_STENCIL_VALUE(d); + } +} /* - * Need this to provide at least one external definition. + * Read an array of stencil values from the stencil buffer. */ +void +fxDDWriteStencilPixels( GLcontext *ctx, + GLuint n, + const GLint x[], + const GLint y[], + const GLstencil stencil[], + const GLstencil mask[]) +{ + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; + GLint bottom = fxMesa->height + fxMesa->y_offset - 1; + GLuint i; + + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDWriteStencilPixels(...)\n"); + } + + for (i = 0; i < n; i++) { + int xpos = x[i] + fxMesa->x_offset; + int ypos = bottom - y[i]; + GLuint d; + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + sizeof(GLdepth), + &d, + FBS_READ); + d = STENCIL_VALUE_TO_DEPTH_VALUE(stencil[i], d); + rw_fb_span(fxMesa, + GR_BUFFER_AUXBUFFER, + xpos, ypos, + 1, + sizeof(GLdepth), + &d, + FBS_WRITE); + } +} +#endif /* disable fxddStencil* funcs */ + + +#define EXTRACT_S_FROM_ZS(zs) (((zs) >> 24) & 0xFF) +#define EXTRACT_Z_FROM_ZS(zs) ((zs) & 0xffffff) +#define BUILD_ZS(z, s) (((s) << 24) | (z)) + +static void write_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y, + const GLstencil stencil[], + const GLubyte mask[] ) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbInfo_t info; + int s; + void *d; + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_WRITE_ONLY, + GR_BUFFER_AUXBUFFER, + GR_LFBWRITEMODE_Z32, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + const GLint scrX = winX + x; + const GLint scrY = winY - y; + + GLint dstStride = info.strideInBytes; + GLubyte *dst = (GLubyte *) info.lfbPtr + + (winY - y) * dstStride + (winX + x) * 4; + GLuint *dst32 = (GLuint *) dst; + GLubyte visMask[MAX_WIDTH]; + GLuint i; + generate_vismask(fxMesa, scrX, scrY, n, visMask); + s = dstStride; + d = dst32; + for (i = 0; i < n; i++) { + if (visMask[i] && (!mask || mask[i])) { + GLuint zs = dst32[i]; + GLuint z = EXTRACT_Z_FROM_ZS(zs); + zs = BUILD_ZS(z, stencil[i]); + dst32[i] = /*zs;*/ stencil[i]; + } + } + grLfbUnlock(GR_LFB_WRITE_ONLY, GR_BUFFER_AUXBUFFER); + } + else { + s = -1; + d = 0; + } + END_BOARD_LOCK(); + /* + printf("write stencil span %d %p\n", s, d); + printf("info: size=%d lfbPtr=%p stride=%x writeMode=%x origin=%x\n", + info.size, info.lfbPtr, info.strideInBytes, info.writeMode, info.origin); + */ +} + + +static void +read_stencil_span(GLcontext *ctx, GLuint n, GLint x, GLint y, + GLstencil stencil[]) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + GrLfbInfo_t info; + /* + int s; + void *d; + */ + + BEGIN_BOARD_LOCK(); + info.size = sizeof(info); + if (grLfbLock(GR_LFB_READ_ONLY, + GR_BUFFER_AUXBUFFER, + GR_LFBWRITEMODE_Z32, + GR_ORIGIN_UPPER_LEFT, + FXFALSE, + &info)) { + const GLint winY = fxMesa->y_offset + fxMesa->height - 1; + const GLint winX = fxMesa->x_offset; + GLint srcStride = /*info.strideInBytes;*/ 8192 ; /* XXX a hack! */ + const GLubyte *src = (const GLubyte *) info.lfbPtr + + (winY - y) * srcStride + (winX + x) * 4; + const GLuint *src32 = (const GLuint *) src; + GLuint i; + /* + s = srcStride; + d = src32; + */ + for (i = 0; i < n; i++) { + stencil[i] = EXTRACT_S_FROM_ZS(src32[i]); + } + grLfbUnlock(GR_LFB_READ_ONLY, GR_BUFFER_AUXBUFFER); + } + END_BOARD_LOCK(); + /* + printf("read stencil span %d %p\n", s, d); + printf("info: size=%d lfbPtr=%p stride=%x writeMode=%x origin=%x\n", + info.size, info.lfbPtr, info.strideInBytes, info.writeMode, info.origin); + */ +} + + +static void +write_stencil_pixels( GLcontext *ctx, GLuint n, + const GLint x[], const GLint y[], + const GLstencil stencil[], const GLubyte mask[]) +{ + /* XXX optimize this */ + GLuint i; + for (i = 0; i < n; i++) { + if (mask[i]) { + write_stencil_span(ctx, 1, x[i], y[i], stencil + i, mask + i); + } + } +} -int gl_fx_dummy_function_span(void) + +static void +read_stencil_pixels(GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], + GLstencil stencil[]) { - return 0; + /* XXX optimize this */ + GLuint i; + for (i = 0; i < n; i++) { + read_stencil_span(ctx, 1, x[i], y[i], stencil + i); + } } -#endif /* FX */ + + +void fxSetupDDSpanPointers(GLcontext *ctx) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + + if (ctx->Visual->RedBits == 5 && + ctx->Visual->GreenBits == 6 && + ctx->Visual->BlueBits == 5 && + ctx->Visual->AlphaBits == 0) { + /* 16bpp mode */ + ctx->Driver.WriteRGBASpan = write_R5G6B5_rgba_span; + ctx->Driver.WriteRGBSpan = write_R5G6B5_rgb_span; + ctx->Driver.WriteMonoRGBASpan = write_R5G6B5_mono_span; + ctx->Driver.WriteRGBAPixels = write_R5G6B5_pixels; + ctx->Driver.WriteMonoRGBAPixels = write_R5G6B5_mono_pixels; + ctx->Driver.ReadRGBASpan = read_R5G6B5_span; + ctx->Driver.ReadRGBAPixels = read_R5G6B5_pixels; + } + else if (ctx->Visual->RedBits == 8 && + ctx->Visual->GreenBits == 8 && + ctx->Visual->BlueBits == 8 && + ctx->Visual->AlphaBits == 0) { + /* 24bpp mode */ + ctx->Driver.WriteRGBASpan = write_R8G8B8_rgba_span; + ctx->Driver.WriteRGBSpan = write_R8G8B8_rgb_span; + ctx->Driver.WriteMonoRGBASpan = write_R8G8B8_mono_span; + ctx->Driver.WriteRGBAPixels = write_R8G8B8_pixels; + ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8_mono_pixels; + ctx->Driver.ReadRGBASpan = read_R8G8B8_span; + ctx->Driver.ReadRGBAPixels = read_R8G8B8_pixels; + } + else if (ctx->Visual->RedBits == 8 && + ctx->Visual->GreenBits == 8 && + ctx->Visual->BlueBits == 8 && + ctx->Visual->AlphaBits == 8) { + /* 32bpp mode */ + ctx->Driver.WriteRGBASpan = write_R8G8B8A8_rgba_span; + ctx->Driver.WriteRGBSpan = write_R8G8B8A8_rgb_span; + ctx->Driver.WriteMonoRGBASpan = write_R8G8B8A8_mono_span; + ctx->Driver.WriteRGBAPixels = write_R8G8B8A8_pixels; + ctx->Driver.WriteMonoRGBAPixels = write_R8G8B8A8_mono_pixels; + ctx->Driver.ReadRGBASpan = read_R8G8B8A8_span; + ctx->Driver.ReadRGBAPixels = read_R8G8B8A8_pixels; + } + else { + abort(); + } + + if (fxMesa->haveHwStencil) { + ctx->Driver.WriteStencilSpan = write_stencil_span; + ctx->Driver.ReadStencilSpan = read_stencil_span; + ctx->Driver.WriteStencilPixels = write_stencil_pixels; + ctx->Driver.ReadStencilPixels = read_stencil_pixels; + } + + ctx->Driver.WriteCI8Span = NULL; + ctx->Driver.WriteCI32Span = NULL; + ctx->Driver.WriteMonoCISpan = NULL; + ctx->Driver.WriteCI32Pixels = NULL; + ctx->Driver.WriteMonoCIPixels = NULL; + ctx->Driver.ReadCI32Span = NULL; + ctx->Driver.ReadCI32Pixels = NULL; +} diff --git a/xc/extras/Mesa/src/FX/fxddtex.c b/xc/extras/Mesa/src/FX/fxddtex.c index 71d1e97ad..69ceebaa9 100644 --- a/xc/extras/Mesa/src/FX/fxddtex.c +++ b/xc/extras/Mesa/src/FX/fxddtex.c @@ -50,6 +50,9 @@ #if defined(FX) #include "fxdrv.h" +#include "image.h" +#include "texutil.h" + void fxPrintTextureData(tfxTexInfo *ti) { @@ -63,17 +66,18 @@ void fxPrintTextureData(tfxTexInfo *ti) } else fprintf(stderr, "\tName: UNNAMED\n"); fprintf(stderr, "\tLast used: %d\n", ti->lastTimeUsed); - fprintf(stderr, "\tTMU: %d\n", ti->whichTMU); + fprintf(stderr, "\tTMU: %ld\n", ti->whichTMU); fprintf(stderr, "\t%s\n", (ti->isInTM)?"In TMU":"Not in TMU"); if (ti->tm[0]) - fprintf(stderr, "\tMem0: %x-%x\n", ti->tm[0]->startAddr, - ti->tm[0]->endAddr); + fprintf(stderr, "\tMem0: %x-%x\n", (unsigned) ti->tm[0]->startAddr, + (unsigned) ti->tm[0]->endAddr); if (ti->tm[1]) - fprintf(stderr, "\tMem1: %x-%x\n", ti->tm[1]->startAddr, - ti->tm[1]->endAddr); + fprintf(stderr, "\tMem1: %x-%x\n", (unsigned) ti->tm[1]->startAddr, + (unsigned) ti->tm[1]->endAddr); fprintf(stderr, "\tMipmaps: %d-%d\n", ti->minLevel, ti->maxLevel); - fprintf(stderr, "\tFilters: min %d min %d\n", ti->minFilt, ti->maxFilt); - fprintf(stderr, "\tClamps: s %d t %d\n", ti->sClamp, ti->tClamp); + fprintf(stderr, "\tFilters: min %d min %d\n", + (int) ti->minFilt, (int) ti->maxFilt); + fprintf(stderr, "\tClamps: s %d t %d\n", (int) ti->sClamp, (int) ti->tClamp); fprintf(stderr, "\tScales: s %f t %f\n", ti->sScale, ti->tScale); fprintf(stderr, "\tInt Scales: s %d t %d\n", ti->int_sScale/0x800000, ti->int_tScale/0x800000); @@ -86,14 +90,14 @@ void fxPrintTextureData(tfxTexInfo *ti) /*************************** Texture Mapping ****************************/ /************************************************************************/ -void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj) +static void fxTexInvalidate(GLcontext *ctx, struct gl_texture_object *tObj) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; tfxTexInfo *ti; - fxTMMoveOutTM(fxMesa,tObj); /* TO DO: SLOW but easy to write */ - ti=fxTMGetTexInfo(tObj); + if (ti->isInTM) fxTMMoveOutTM(fxMesa,tObj); /* TO DO: SLOW but easy to write */ + ti->validated=GL_FALSE; fxMesa->new_state|=FX_NEW_TEXTURING; ctx->Driver.RenderStart = fxSetupFXUnits; @@ -128,7 +132,6 @@ static tfxTexInfo *fxAllocTexObjData(fxMesaContext fxMesa) ti->LODblend=FXFALSE; for(i=0;i<MAX_TEXTURE_LEVELS;i++) { - ti->mipmapLevel[i].used=GL_FALSE; ti->mipmapLevel[i].data=NULL; } @@ -160,7 +163,7 @@ void fxDDTexBind(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj) ctx->Driver.RenderStart = fxSetupFXUnits; } -void fxDDTexEnv(GLcontext *ctx, GLenum pname, const GLfloat *param) +void fxDDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, const GLfloat *param) { fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; @@ -171,6 +174,16 @@ void fxDDTexEnv(GLcontext *ctx, GLenum pname, const GLfloat *param) fprintf(stderr,"fxmesa: texenv(%x)\n",pname); } + /* apply any lod biasing right now */ + if (pname==GL_TEXTURE_LOD_BIAS_EXT) { + FX_grTexLodBiasValue(GR_TMU0,*param); + + if(fxMesa->haveTwoTMUs) { + FX_grTexLodBiasValue(GR_TMU1,*param); + } + + } + fxMesa->new_state|=FX_NEW_TEXTURING; ctx->Driver.RenderStart = fxSetupFXUnits; } @@ -312,124 +325,154 @@ void fxDDTexParam(GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, void fxDDTexDel(GLcontext *ctx, struct gl_texture_object *tObj) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxTexInfo *ti=fxTMGetTexInfo(tObj); + fxMesaContext fxMesa = FX_CONTEXT(ctx); + tfxTexInfo *ti = fxTMGetTexInfo(tObj); - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDTexDel(%d,%x)\n",tObj->Name,(GLuint)ti); + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDTexDel(%d,%p)\n", tObj->Name, ti); } - if(!ti) + if (!ti) return; - fxTMFreeTexture(fxMesa,tObj); + fxTMFreeTexture(fxMesa, tObj); FREE(ti); - tObj->DriverData=NULL; + tObj->DriverData = NULL; - ctx->NewState|=NEW_TEXTURING; + ctx->NewState |= NEW_TEXTURING; } -void fxDDTexPalette(GLcontext *ctx, struct gl_texture_object *tObj) -{ - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - int i; - FxU32 r,g,b,a; - tfxTexInfo *ti; - if(tObj) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDTexPalette(%d,%x)\n",tObj->Name,(GLuint)tObj->DriverData); - } - if(tObj->Palette.Format!=GL_RGBA) { -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: unsupported palette format in texpalette()\n"); -#endif - return; - } - - if(tObj->Palette.Size>256) { -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: unsupported palette size in texpalette()\n"); -#endif - return; - } - - if (!tObj->DriverData) - tObj->DriverData=fxAllocTexObjData(fxMesa); - - ti=fxTMGetTexInfo(tObj); - - for(i=0;i<tObj->Palette.Size;i++) { - r=tObj->Palette.Table[i*4]; - g=tObj->Palette.Table[i*4+1]; - b=tObj->Palette.Table[i*4+2]; - a=tObj->Palette.Table[i*4+3]; - ti->palette.data[i]=(a<<24)|(r<<16)|(g<<8)|b; - } +/* + * Convert a gl_color_table texture palette to Glide's format. + */ +static void +convertPalette(FxU32 data[256], const struct gl_color_table *table) +{ + const GLubyte *tableUB = (const GLubyte *) table->Table; + GLint width = table->Size; + FxU32 r, g, b, a; + GLint i; + + ASSERT(table->TableType == GL_UNSIGNED_BYTE); + + switch (table->Format) { + case GL_INTENSITY: + for (i = 0; i < width; i++) { + r = tableUB[i]; + g = tableUB[i]; + b = tableUB[i]; + a = tableUB[i]; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_LUMINANCE: + for (i = 0; i < width; i++) { + r = tableUB[i]; + g = tableUB[i]; + b = tableUB[i]; + a = 255; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_ALPHA: + for (i = 0; i < width; i++) { + r = g = b = 255; + a = tableUB[i]; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_LUMINANCE_ALPHA: + for (i = 0; i < width; i++) { + r = g = b = tableUB[i*2+0]; + a = tableUB[i*2+1]; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_RGB: + for (i = 0; i < width; i++) { + r = tableUB[i*3+0]; + g = tableUB[i*3+1]; + b = tableUB[i*3+2]; + a = 255; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + case GL_RGBA: + for (i = 0; i < width; i++) { + r = tableUB[i*4+0]; + g = tableUB[i*4+1]; + b = tableUB[i*4+2]; + a = tableUB[i*4+3]; + data[i] = (a << 24) | (r << 16) | (g << 8) | b; + } + break; + } +} - fxTexInvalidate(ctx,tObj); - } else { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDTexPalette(global)\n"); - } - if(ctx->Texture.Palette.Format!=GL_RGBA) { -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: unsupported palette format in texpalette()\n"); -#endif - return; - } - if(ctx->Texture.Palette.Size>256) { -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: unsupported palette size in texpalette()\n"); -#endif - return; +void fxDDTexPalette(GLcontext *ctx, struct gl_texture_object *tObj) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + + if (tObj) { + /* per-texture palette */ + tfxTexInfo *ti; + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDTexPalette(%d,%x)\n", + tObj->Name, (GLuint) tObj->DriverData); } - - for(i=0;i<ctx->Texture.Palette.Size;i++) { - r=ctx->Texture.Palette.Table[i*4]; - g=ctx->Texture.Palette.Table[i*4+1]; - b=ctx->Texture.Palette.Table[i*4+2]; - a=ctx->Texture.Palette.Table[i*4+3]; - fxMesa->glbPalette.data[i]=(a<<24)|(r<<16)|(g<<8)|b; + if (!tObj->DriverData) + tObj->DriverData = fxAllocTexObjData(fxMesa); + ti = fxTMGetTexInfo(tObj); + convertPalette(ti->palette.data, &tObj->Palette); + fxTexInvalidate(ctx, tObj); + } + else { + /* global texture palette */ + if (MESA_VERBOSE & VERBOSE_DRIVER) { + fprintf(stderr, "fxmesa: fxDDTexPalette(global)\n"); } - - fxMesa->new_state|=FX_NEW_TEXTURING; + convertPalette(fxMesa->glbPalette.data, &ctx->Texture.Palette); + fxMesa->new_state |= FX_NEW_TEXTURING; ctx->Driver.RenderStart = fxSetupFXUnits; } } + void fxDDTexUseGlbPalette(GLcontext *ctx, GLboolean state) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + fxMesaContext fxMesa = FX_CONTEXT(ctx); if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"fxmesa: fxDDTexUseGlbPalette(%d)\n",state); } - if(state) { - fxMesa->haveGlobalPaletteTexture=1; + if (state) { + fxMesa->haveGlobalPaletteTexture = 1; - FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE,&(fxMesa->glbPalette)); + FX_grTexDownloadTable(GR_TMU0,GR_TEXTABLE_PALETTE, &(fxMesa->glbPalette)); if (fxMesa->haveTwoTMUs) - FX_grTexDownloadTable(GR_TMU1,GR_TEXTABLE_PALETTE,&(fxMesa->glbPalette)); - } else { - fxMesa->haveGlobalPaletteTexture=0; + FX_grTexDownloadTable(GR_TMU1, GR_TEXTABLE_PALETTE, &(fxMesa->glbPalette)); + } + else { + fxMesa->haveGlobalPaletteTexture = 0; - if((ctx->Texture.Unit[0].Current==ctx->Texture.Unit[0].CurrentD[2]) && - (ctx->Texture.Unit[0].Current!=NULL)) { - struct gl_texture_object *tObj=ctx->Texture.Unit[0].Current; + if ((ctx->Texture.Unit[0].Current == ctx->Texture.Unit[0].CurrentD[2]) && + (ctx->Texture.Unit[0].Current != NULL)) { + struct gl_texture_object *tObj = ctx->Texture.Unit[0].Current; if (!tObj->DriverData) - tObj->DriverData=fxAllocTexObjData(fxMesa); + tObj->DriverData = fxAllocTexObjData(fxMesa); - fxTexInvalidate(ctx,tObj); + fxTexInvalidate(ctx, tObj); } } } + static int logbase2(int n) { GLint i = 1; @@ -453,209 +496,68 @@ static int logbase2(int n) /* Need different versions for different cpus. */ -#define INT_TRICK(l2) (0x800000 * l2) - - -int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel, GrAspectRatio_t *ar, +#define INT_TRICK(l2) (0x800000 * (l2)) +int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel, + GrAspectRatio_t *aspectratio, float *sscale, float *tscale, int *i_sscale, int *i_tscale, int *wscale, int *hscale) { - - static GrLOD_t lod[9]={GR_LOD_256,GR_LOD_128,GR_LOD_64,GR_LOD_32, - GR_LOD_16,GR_LOD_8,GR_LOD_4,GR_LOD_2,GR_LOD_1}; - - int logw,logh,ws,hs; - GrLOD_t l; - GrAspectRatio_t aspectratio; - float s,t; - int is,it; + int logw, logh, ar, l, is, it, ws, hs; + float s, t; logw=logbase2(w); logh=logbase2(h); - - switch(logw-logh) { - case 0: - aspectratio=GR_ASPECT_1x1; - l=lod[8-logw]; - s=t=256.0f; - is=it=INT_TRICK(8); - ws=hs=1; - break; - case 1: - aspectratio=GR_ASPECT_2x1; - l=lod[8-logw]; - s=256.0f; - t=128.0f; - is=INT_TRICK(8);it=INT_TRICK(7); - ws=1; - hs=1; - break; - case 2: - aspectratio=GR_ASPECT_4x1; - l=lod[8-logw]; - s=256.0f; - t=64.0f; - is=INT_TRICK(8);it=INT_TRICK(6); - ws=1; - hs=1; - break; - case 3: - aspectratio=GR_ASPECT_8x1; - l=lod[8-logw]; - s=256.0f; - t=32.0f; - is=INT_TRICK(8);it=INT_TRICK(5); - ws=1; - hs=1; - break; - case 4: - aspectratio=GR_ASPECT_8x1; - l=lod[8-logw]; - s=256.0f; - t=32.0f; - is=INT_TRICK(8);it=INT_TRICK(5); - ws=1; - hs=2; - break; - case 5: - aspectratio=GR_ASPECT_8x1; - l=lod[8-logw]; - s=256.0f; - t=32.0f; - is=INT_TRICK(8);it=INT_TRICK(5); + ar=logw-logh; + /* Hardware only allows a maximum aspect ratio of 8x1, so handle + |ar|>3 by scaling the image and using an 8x1 aspect ratio */ + if (ar>=0) { + l=logw; + s=256.0; + is=INT_TRICK(8); ws=1; - hs=4; - break; - case 6: - aspectratio=GR_ASPECT_8x1; - l=lod[8-logw]; - s=256.0f; - t=32.0f; - is=INT_TRICK(8);it=INT_TRICK(5); - ws=1; - hs=8; - break; - case 7: - aspectratio=GR_ASPECT_8x1; - l=lod[8-logw]; - s=256.0f; - t=32.0f; - is=INT_TRICK(8);it=INT_TRICK(5); - ws=1; - hs=16; - break; - case 8: - aspectratio=GR_ASPECT_8x1; - l=lod[8-logw]; - s=256.0f; - t=32.0f; - is=INT_TRICK(8);it=INT_TRICK(5); - ws=1; - hs=32; - break; - case -1: - aspectratio=GR_ASPECT_1x2; - l=lod[8-logh]; - s=128.0f; - t=256.0f; - is=INT_TRICK(7);it=INT_TRICK(8); - ws=1; - hs=1; - break; - case -2: - aspectratio=GR_ASPECT_1x4; - l=lod[8-logh]; - s=64.0f; - t=256.0f; - is=INT_TRICK(6);it=INT_TRICK(8); - ws=1; - hs=1; - break; - case -3: - aspectratio=GR_ASPECT_1x8; - l=lod[8-logh]; - s=32.0f; - t=256.0f; - is=INT_TRICK(5);it=INT_TRICK(8); - ws=1; - hs=1; - break; - case -4: - aspectratio=GR_ASPECT_1x8; - l=lod[8-logh]; - s=32.0f; - t=256.0f; - is=INT_TRICK(5);it=INT_TRICK(8); - ws=2; - hs=1; - break; - case -5: - aspectratio=GR_ASPECT_1x8; - l=lod[8-logh]; - s=32.0f; - t=256.0f; - is=INT_TRICK(5);it=INT_TRICK(8); - ws=4; - hs=1; - break; - case -6: - aspectratio=GR_ASPECT_1x8; - l=lod[8-logh]; - s=32.0f; - t=256.0f; - is=INT_TRICK(5);it=INT_TRICK(8); - ws=8; - hs=1; - break; - case -7: - aspectratio=GR_ASPECT_1x8; - l=lod[8-logh]; - s=32.0f; - t=256.0f; - is=INT_TRICK(5);it=INT_TRICK(8); - ws=16; - hs=1; - break; - case -8: - aspectratio=GR_ASPECT_1x8; - l=lod[8-logh]; - s=32.0f; - t=256.0f; - is=INT_TRICK(5);it=INT_TRICK(8); - ws=32; + if (ar<3) { + t=256>>ar; + it=INT_TRICK(8-ar); + hs=1; + } else { + t=32.0; + it=INT_TRICK(5); + hs=1<<(ar-3); + } + } else { + l=logh; + t=256.0; + it=INT_TRICK(8); hs=1; - break; - default: - return 0; - break; + if (-ar<3) { + s=256>>-ar; + is=INT_TRICK(8+ar); + ws=1; + } else { + s=32.0; + is=INT_TRICK(5); + ws=1<<(-ar-3); + } } - - if(lodlevel) - (*lodlevel)=l; - - if(ar) - (*ar)=aspectratio; - - if(sscale) - (*sscale)=s; - - if(tscale) - (*tscale)=t; - - if(wscale) - (*wscale)=ws; - - if(hscale) - (*hscale)=hs; - - if (i_sscale) - *i_sscale = is; - - if (i_tscale) - *i_tscale = it; - - + if (ar<-3) ar=-3; + if (ar>3) ar=3; + + /* The above numbers are calculated sensibly and work for Glide3, but + we change them to the whacky glide2 values if needed. */ +#ifdef FX_GLIDE3 + if (lodlevel) *lodlevel=l; + if (aspectratio) *aspectratio=ar; +#else + if (lodlevel) *lodlevel=8-l; + if (aspectratio) *aspectratio=3-ar; +#endif + if (sscale) *sscale=s; + if (tscale) *tscale=t; + if (wscale) *wscale=ws; + if (hscale) *hscale=hs; + if (i_sscale) *i_sscale = is; + if (i_tscale) *i_tscale = it; return 1; } @@ -666,752 +568,506 @@ int fxTexGetInfo(int w, int h, GrLOD_t *lodlevel, GrAspectRatio_t *ar, void fxTexGetFormat(GLenum glformat, GrTextureFormat_t *tfmt, GLint *ifmt) { switch(glformat) { - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - if(tfmt) - (*tfmt)=GR_TEXFMT_INTENSITY_8; - if(ifmt) - (*ifmt)=GL_LUMINANCE; - break; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - if(tfmt) - (*tfmt)=GR_TEXFMT_ALPHA_INTENSITY_88; - if(ifmt) - (*ifmt)=GL_LUMINANCE_ALPHA; - break; - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - if(tfmt) - (*tfmt)=GR_TEXFMT_ALPHA_8; - if(ifmt) - (*ifmt)=GL_INTENSITY; - break; - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - if(tfmt) - (*tfmt)=GR_TEXFMT_ALPHA_8; - if(ifmt) - (*ifmt)=GL_ALPHA; - break; - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - if(tfmt) - (*tfmt)=GR_TEXFMT_RGB_565; - if(ifmt) - (*ifmt)=GL_RGB; - break; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - if(tfmt) - (*tfmt)=GR_TEXFMT_ARGB_4444; - if(ifmt) - (*ifmt)=GL_RGBA; - break; - case GL_RGB5_A1: - if(tfmt) - (*tfmt)=GR_TEXFMT_ARGB_1555; - if(ifmt) - (*ifmt)=GL_RGBA; - break; - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - if(tfmt) - (*tfmt)=GR_TEXFMT_P_8; - if(ifmt) - (*ifmt)=GL_RGBA; - break; - default: - fprintf(stderr,"fx Driver: unsupported internalFormat in fxTexGetFormat()\n"); - fxCloseHardware(); - exit(-1); - break; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + if(tfmt) + (*tfmt)=GR_TEXFMT_INTENSITY_8; + if(ifmt) + (*ifmt)=GL_LUMINANCE; + break; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + if(tfmt) + (*tfmt)=GR_TEXFMT_ALPHA_INTENSITY_88; + if(ifmt) + (*ifmt)=GL_LUMINANCE_ALPHA; + break; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + if(tfmt) + (*tfmt)=GR_TEXFMT_ALPHA_8; + if(ifmt) + (*ifmt)=GL_INTENSITY; + break; + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + if(tfmt) + (*tfmt)=GR_TEXFMT_ALPHA_8; + if(ifmt) + (*ifmt)=GL_ALPHA; + break; + case 3: + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + if(tfmt) + (*tfmt)=GR_TEXFMT_RGB_565; + if(ifmt) + (*ifmt)=GL_RGB; + break; + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + if(tfmt) + (*tfmt)=GR_TEXFMT_ARGB_8888; + if(ifmt) + (*ifmt)=GL_RGB; + break; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + if(tfmt) + (*tfmt)=GR_TEXFMT_ARGB_4444; + if(ifmt) + (*ifmt)=GL_RGBA; + break; + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + if(tfmt) + (*tfmt)=GR_TEXFMT_ARGB_8888; + if(ifmt) + (*ifmt)=GL_RGBA; + break; + case GL_RGB5_A1: + if(tfmt) + (*tfmt)=GR_TEXFMT_ARGB_1555; + if(ifmt) + (*ifmt)=GL_RGBA; + break; + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + if(tfmt) + (*tfmt)=GR_TEXFMT_P_8; + if(ifmt) + (*ifmt)=GL_RGBA; /* XXX why is this RGBA? */ + break; + default: + fprintf(stderr, + "fx Driver: unsupported internalFormat in fxTexGetFormat()\n"); + fxCloseHardware(); + exit(-1); + break; } } -static int fxIsTexSupported(GLenum target, GLint internalFormat, - const struct gl_texture_image *image) +static GLboolean fxIsTexSupported(GLenum target, GLint internalFormat, + const struct gl_texture_image *image) { - if(target!=GL_TEXTURE_2D) - return GL_FALSE; - - switch(internalFormat) { - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGB5_A1: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - break; - default: - return GL_FALSE; - } - - if(image->Width>256) - return GL_FALSE; - - if(image->Height>256) + if(target != GL_TEXTURE_2D) return GL_FALSE; if(!fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL)) return GL_FALSE; + if (image->Border > 0) + return GL_FALSE; + return GL_TRUE; } -static void fxTexBuildImageMap(const struct gl_texture_image *image, - GLint internalFormat, unsigned short **dest, - GLboolean *istranslate) -{ - unsigned short *src; - unsigned char *data; - int x,y,w,h,wscale,hscale,idx; - - fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL, - &wscale,&hscale); - w=image->Width*wscale; - h=image->Height*hscale; - - data=image->Data; - switch(internalFormat) { - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - /* Optimized for GLQuake */ - - if(wscale==hscale==1) { - (*istranslate)=GL_FALSE; - - (*dest)=(unsigned short *)data; - } else { - unsigned char *srcb; - - (*istranslate)=GL_TRUE; - - if(!(*dest)) { - if(!((*dest)=src=(unsigned short *)MALLOC(sizeof(unsigned char)*w*h))) { - fprintf(stderr,"fx Driver: out of memory !\n"); - fxCloseHardware(); - exit(-1); - } - } else - src=(*dest); - - srcb=(unsigned char *)src; - - for(y=0;y<h;y++) - for(x=0;x<w;x++) { - idx=(x/wscale+(y/hscale)*(w/wscale)); - srcb[x+y*w]=data[idx]; - } - } - break; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - (*istranslate)=GL_TRUE; - - if(!(*dest)) { - if(!((*dest)=src=(unsigned short *)MALLOC(sizeof(unsigned short)*w*h))) { - fprintf(stderr,"fx Driver: out of memory !\n"); - fxCloseHardware(); - exit(-1); - } - } else - src=(*dest); - - if(wscale==hscale==1) { - int i=0; - int lenght=h*w; - unsigned short a,l; - - while(i++<lenght) { - l=*data++; - a=*data++; - - *src++=(a << 8) | l; - } - } else { - unsigned short a,l; - for(y=0;y<h;y++) - for(x=0;x<w;x++) { - idx=(x/wscale+(y/hscale)*(w/wscale))*2; - l=data[idx]; - a=data[idx+1]; - - src[x+y*w]=(a << 8) | l; - } - } - break; - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - (*istranslate)=GL_TRUE; - - if(!(*dest)) { - if(!((*dest)=src=(unsigned short *)MALLOC(sizeof(unsigned short)*w*h))) { - fprintf(stderr,"fx Driver: out of memory !\n"); - fxCloseHardware(); - exit(-1); - } - } else - src=(*dest); - - if(wscale==hscale==1) { - int i=0; - int lenght=h*w; - unsigned int r,g,b; - - while(i++<lenght) { - r=*data++; - g=*data++; - b=*data++; - - *src++=((0xf8 & r) << (11-3)) | - ((0xfc & g) << (5-3+1)) | - ((0xf8 & b) >> 3); - } - } else { - unsigned int r,g,b; - - for(y=0;y<h;y++) - for(x=0;x<w;x++) { - idx=(x/wscale+(y/hscale)*(w/wscale))*3; - r=data[idx]; - g=data[idx+1]; - b=data[idx+2]; - - src[x+y*w]=((0xf8 & r) << (11-3)) | - ((0xfc & g) << (5-3+1)) | - ((0xf8 & b) >> 3); - } - } - break; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - (*istranslate)=GL_TRUE; - - if(!(*dest)) { - if(!((*dest)=src=(unsigned short *)MALLOC(sizeof(unsigned short)*w*h))) { - fprintf(stderr,"fx Driver: out of memory !\n"); - fxCloseHardware(); - exit(-1); - } - } else - src=(*dest); - - if(wscale==hscale==1) { - int i=0; - int lenght=h*w; - unsigned int r,g,b,a; - - while(i++<lenght) { - r=*data++; - g=*data++; - b=*data++; - a=*data++; - - *src++=((0xf0 & a) << 8) | - ((0xf0 & r) << 4) | - (0xf0 & g) | - ((0xf0 & b) >> 4); - } - } else { - unsigned int r,g,b,a; - - for(y=0;y<h;y++) - for(x=0;x<w;x++) { - idx=(x/wscale+(y/hscale)*(w/wscale))*4; - r=data[idx]; - g=data[idx+1]; - b=data[idx+2]; - a=data[idx+3]; - - src[x+y*w]=((0xf0 & a) << 8) | - ((0xf0 & r) << 4) | - (0xf0 & g) | - ((0xf0 & b) >> 4); - } - } - break; - case GL_RGB5_A1: - (*istranslate)=GL_TRUE; - - if(!(*dest)) { - if(!((*dest)=src=(unsigned short *)malloc(sizeof(unsigned short)*w*h))) { - fprintf(stderr,"fx Driver: out of memory !\n"); - fxCloseHardware(); - exit(-1); - } - } else - src=(*dest); - - if(wscale==hscale==1) { - int i=0; - int lenght=h*w; - unsigned r,g,b,a; - - while(i++<lenght) { - r=*data++; - g=*data++; - b=*data++; - a=*data++; - *src++=((0x80 & a) << 8) | - ((0xf8 & r) << 7) | - ((0xf8 & g) << 2) | - ((0xf8 & b) >> 3); - } - } else { - unsigned r,g,b,a; - - for(y=0;y<h;y++) - for(x=0;x<w;x++) { - idx=(x/wscale+(y/hscale)*(w/wscale))*4; - r=data[idx]; - g=data[idx+1]; - b=data[idx+2]; - a=data[idx+3]; - - src[x+y*w]=((0x80 & a) << 8) | - ((0xf8 & r) << 7) | - ((0xf8 & g) << 2) | - ((0xf8 & b) >> 3); - } - } - break; - default: - fprintf(stderr,"fx Driver: wrong internalFormat in texbuildimagemap()\n"); - fxCloseHardware(); - exit(-1); - break; - } -} +/**********************************************************************/ +/**** NEW TEXTURE IMAGE FUNCTIONS ****/ +/**********************************************************************/ -void fxDDTexImg(GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, GLint internalFormat, - const struct gl_texture_image *image) +GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLboolean *retainInternalCopy) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxTexInfo *ti; + fxMesaContext fxMesa = (fxMesaContext)ctx->DriverCtx; - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr, - "fxmesa: (%d) fxDDTexImg(...,level=%d,target=%d,format=%x,width=%d,height=%d...)\n", - tObj->Name, level, target, internalFormat, image->Width, - image->Height); - } - - if(target!=GL_TEXTURE_2D) - return; + if (target != GL_TEXTURE_2D) + return GL_FALSE; - if (!tObj->DriverData) - tObj->DriverData=fxAllocTexObjData(fxMesa); + if (!texObj->DriverData) + texObj->DriverData = fxAllocTexObjData(fxMesa); - ti=fxTMGetTexInfo(tObj); - - if(fxIsTexSupported(target,internalFormat,image)) { + if (fxIsTexSupported(target, texImage->IntFormat, texImage)) { GrTextureFormat_t gldformat; - tfxMipMapLevel *mml=&ti->mipmapLevel[level]; + tfxTexInfo *ti = fxTMGetTexInfo(texObj); + tfxMipMapLevel *mml = &ti->mipmapLevel[level]; + GLint dstWidth, dstHeight, wScale, hScale, texelSize, dstStride; + MesaIntTexFormat intFormat; + + fxTexGetFormat(texImage->IntFormat, &gldformat, NULL); - fxTexGetFormat(internalFormat,&gldformat,NULL); + fxTexGetInfo(texImage->Width, texImage->Height, NULL,NULL,NULL,NULL, + NULL,NULL, &wScale, &hScale); - if(mml->used) { - if((mml->glideFormat==gldformat) && - (mml->width==image->Width) && - (mml->height==image->Height)) { - fxTexBuildImageMap(image,internalFormat,&(mml->data), - &(mml->translated)); - - if(ti->validated && ti->isInTM) - fxTMReloadMipMapLevel(fxMesa,tObj,level); - else - fxTexInvalidate(ctx,tObj); - - return; - } else { - if(mml->translated) - FREE(mml->data); - mml->data=NULL; - } + dstWidth = texImage->Width * wScale; + dstHeight = texImage->Height * hScale; + + switch (texImage->IntFormat) { + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + texelSize = 1; + intFormat = MESA_I8; + break; + case 1: + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + texelSize = 1; + intFormat = MESA_L8; + break; + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + texelSize = 1; + intFormat = MESA_A8; + break; + case GL_COLOR_INDEX: + case GL_COLOR_INDEX1_EXT: + case GL_COLOR_INDEX2_EXT: + case GL_COLOR_INDEX4_EXT: + case GL_COLOR_INDEX8_EXT: + case GL_COLOR_INDEX12_EXT: + case GL_COLOR_INDEX16_EXT: + texelSize = 1; + intFormat = MESA_C8; + break; + case 2: + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + texelSize = 2; + intFormat = MESA_A8_L8; + break; + case 3: + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + texelSize = 2; + intFormat = MESA_R5_G6_B5; + break; + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + texelSize = 4; + intFormat = MESA_A8_R8_G8_B8; + break; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + texelSize = 2; + intFormat = MESA_A4_R4_G4_B4; + break; + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + texelSize = 4; + intFormat = MESA_A8_R8_G8_B8; + break; + case GL_RGB5_A1: + texelSize = 2; + intFormat = MESA_A1_R5_G5_B5; + break; + default: + gl_problem(NULL, "tdfx driver: texbuildimagemap() bad format"); + return GL_FALSE; } - mml->glideFormat=gldformat; - mml->width=image->Width; - mml->height=image->Height; - mml->used=GL_TRUE; - - fxTexBuildImageMap(image,internalFormat,&(mml->data), - &(mml->translated)); + _mesa_set_teximage_component_sizes(intFormat, texImage); + + /*printf("teximage:\n");*/ + /* allocate new storage for texture image, if needed */ + if (!mml->data || mml->glideFormat != gldformat || + mml->width != dstWidth || mml->height != dstHeight) { + if (mml->data) + FREE(mml->data); + mml->data = MALLOC(dstWidth * dstHeight * texelSize); + if (!mml->data) + return GL_FALSE; + mml->texelSize = texelSize; + mml->glideFormat = gldformat; + mml->width = dstWidth; + mml->height = dstHeight; + fxTexInvalidate(ctx, texObj); + } - fxTexInvalidate(ctx,tObj); - } -#ifndef FX_SILENT - else - fprintf(stderr,"fx Driver: unsupported texture in fxDDTexImg()\n"); -#endif -} + dstStride = dstWidth * texelSize; -static void fxTexBuildSubImageMap(const struct gl_texture_image *image, - GLint internalFormat, - GLint xoffset, GLint yoffset, GLint width, GLint height, - unsigned short *destimg) -{ - fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL, - NULL,NULL); - - switch(internalFormat) { - case GL_INTENSITY: - case GL_INTENSITY4: - case GL_INTENSITY8: - case GL_INTENSITY12: - case GL_INTENSITY16: - case 1: - case GL_LUMINANCE: - case GL_LUMINANCE4: - case GL_LUMINANCE8: - case GL_LUMINANCE12: - case GL_LUMINANCE16: - case GL_ALPHA: - case GL_ALPHA4: - case GL_ALPHA8: - case GL_ALPHA12: - case GL_ALPHA16: - case GL_COLOR_INDEX: - case GL_COLOR_INDEX1_EXT: - case GL_COLOR_INDEX2_EXT: - case GL_COLOR_INDEX4_EXT: - case GL_COLOR_INDEX8_EXT: - case GL_COLOR_INDEX12_EXT: - case GL_COLOR_INDEX16_EXT: - { - - int y; - unsigned char *bsrc,*bdst; - - bsrc=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)); - bdst=((unsigned char *)destimg)+(yoffset*image->Width+xoffset); - - for(y=0;y<height;y++) { - MEMCPY(bdst,bsrc,width); - bsrc += image->Width; - bdst += image->Width; - } - } - break; - case 2: - case GL_LUMINANCE_ALPHA: - case GL_LUMINANCE4_ALPHA4: - case GL_LUMINANCE6_ALPHA2: - case GL_LUMINANCE8_ALPHA8: - case GL_LUMINANCE12_ALPHA4: - case GL_LUMINANCE12_ALPHA12: - case GL_LUMINANCE16_ALPHA16: - { - int x,y; - unsigned char *src; - unsigned short *dst,a,l; - int simgw,dimgw; - - src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*2); - dst=destimg+(yoffset*image->Width+xoffset); - - simgw=(image->Width-width)*2; - dimgw=image->Width-width; - for(y=0;y<height;y++) { - for(x=0;x<width;x++) { - l=*src++; - a=*src++; - *dst++=(a << 8) | l; - } - - src += simgw; - dst += dimgw; - } + /* store the texture image */ + if (!_mesa_convert_teximage(intFormat, dstWidth, dstHeight, mml->data, + dstStride, + texImage->Width, texImage->Height, + format, type, pixels, packing)) { + return GL_FALSE; } - break; - case 3: - case GL_RGB: - case GL_R3_G3_B2: - case GL_RGB4: - case GL_RGB5: - case GL_RGB8: - case GL_RGB10: - case GL_RGB12: - case GL_RGB16: - { - int x,y; - unsigned char *src; - unsigned short *dst,r,g,b; - int simgw,dimgw; - - src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*3); - dst=destimg+(yoffset*image->Width+xoffset); - simgw=(image->Width-width)*3; - dimgw=image->Width-width; - for(y=0;y<height;y++) { - for(x=0;x<width;x++) { - r=*src++; - g=*src++; - b=*src++; - *dst++=((0xf8 & r) << (11-3)) | - ((0xfc & g) << (5-3+1)) | - ((0xf8 & b) >> 3); - } - - src += simgw; - dst += dimgw; - } + if (ti->validated && ti->isInTM) { + /*printf("reloadmipmaplevels\n");*/ + fxTMReloadMipMapLevel(fxMesa, texObj, level); } - break; - case 4: - case GL_RGBA: - case GL_RGBA2: - case GL_RGBA4: - case GL_RGBA8: - case GL_RGB10_A2: - case GL_RGBA12: - case GL_RGBA16: - { - int x,y; - unsigned char *src; - unsigned short *dst,r,g,b,a; - int simgw,dimgw; - - src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*4); - dst=destimg+(yoffset*image->Width+xoffset); - - simgw=(image->Width-width)*4; - dimgw=image->Width-width; - for(y=0;y<height;y++) { - for(x=0;x<width;x++) { - r=*src++; - g=*src++; - b=*src++; - a=*src++; - *dst++=((0xf0 & a) << 8) | - ((0xf0 & r) << 4) | - (0xf0 & g) | - ((0xf0 & b) >> 4); - } - - src += simgw; - dst += dimgw; - } + else { + /*printf("invalidate2\n");*/ + fxTexInvalidate(ctx,texObj); } - break; - case GL_RGB5_A1: - { - int x,y; - unsigned char *src; - unsigned short *dst,r,g,b,a; - int simgw,dimgw; - - src=(unsigned char *)(image->Data+(yoffset*image->Width+xoffset)*4); - dst=destimg+(yoffset*image->Width+xoffset); - - simgw=(image->Width-width)*4; - dimgw=image->Width-width; - for(y=0;y<height;y++) { - for(x=0;x<width;x++) { - r=*src++; - g=*src++; - b=*src++; - a=*src++; - *dst++= - ((0x80 & a) << 8) | - ((0xf8 & r) << 7) | - ((0xf8 & g) << 2) | - ((0xf8 & b) >> 3); - } - - src += simgw; - dst += dimgw; - } - } - break; - default: - fprintf(stderr,"fx Driver: wrong internalFormat in fxTexBuildSubImageMap()\n"); - fxCloseHardware(); - exit(-1); - break; + + *retainInternalCopy = GL_FALSE; + return GL_TRUE; + } + else { + gl_problem(NULL, "fx Driver: unsupported texture in fxDDTexImg()\n"); + return GL_FALSE; } } - -void fxDDTexSubImg(GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, GLint level, - GLint xoffset, GLint yoffset, GLint width, GLint height, - GLint internalFormat, const struct gl_texture_image *image) + +GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; + fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx; tfxTexInfo *ti; - GrTextureFormat_t gldformat; - int wscale,hscale; + GLint wscale, hscale, dstStride; tfxMipMapLevel *mml; + GLboolean result; - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr, - "fxmesa: (%d) fxDDTexSubImg(level=%d,target=%d,format=%x,width=%d,height=%d)\n", - tObj->Name, level, target, internalFormat, image->Width, - image->Height); - } + if (target != GL_TEXTURE_2D) + return GL_FALSE; - if(target!=GL_TEXTURE_2D) - return; + if (!texObj->DriverData) + return GL_FALSE; - if (!tObj->DriverData) - return; + ti = fxTMGetTexInfo(texObj); + mml = &ti->mipmapLevel[level]; - ti=fxTMGetTexInfo(tObj); - mml=&ti->mipmapLevel[level]; + fxTexGetInfo( texImage->Width, texImage->Height, NULL,NULL,NULL,NULL, + NULL,NULL, &wscale, &hscale); - fxTexGetFormat(internalFormat,&gldformat,NULL); + assert(mml->data); /* must have an existing texture image! */ - if(mml->glideFormat!=gldformat) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: ti->info.format!=format in fxDDTexSubImg()\n"); - } - fxDDTexImg(ctx,target,tObj,level,internalFormat,image); + switch (mml->glideFormat) { + case GR_TEXFMT_INTENSITY_8: + dstStride = mml->width; + result = _mesa_convert_texsubimage(MESA_I8, xoffset, yoffset, + mml->width, mml->height, mml->data, + dstStride, width, height, + texImage->Width, texImage->Height, + format, type, pixels, packing); + break; + case GR_TEXFMT_ALPHA_8: + dstStride = mml->width; + result = _mesa_convert_texsubimage(MESA_A8, xoffset, yoffset, + mml->width, mml->height, mml->data, + dstStride, width, height, + texImage->Width, texImage->Height, + format, type, pixels, packing); + break; + case GR_TEXFMT_P_8: + dstStride = mml->width; + result = _mesa_convert_texsubimage(MESA_C8, xoffset, yoffset, + mml->width, mml->height, mml->data, + dstStride, width, height, + texImage->Width, texImage->Height, + format, type, pixels, packing); + break; + case GR_TEXFMT_ALPHA_INTENSITY_88: + dstStride = mml->width * 2; + result = _mesa_convert_texsubimage(MESA_A8_L8, xoffset, yoffset, + mml->width, mml->height, mml->data, + dstStride, width, height, + texImage->Width, texImage->Height, + format, type, pixels, packing); + break; + case GR_TEXFMT_RGB_565: + dstStride = mml->width * 2; + result = _mesa_convert_texsubimage(MESA_R5_G6_B5, xoffset, yoffset, + mml->width, mml->height, mml->data, + dstStride, width, height, + texImage->Width, texImage->Height, + format, type, pixels, packing); + break; + case GR_TEXFMT_ARGB_4444: + dstStride = mml->width * 2; + result = _mesa_convert_texsubimage(MESA_A4_R4_G4_B4, xoffset, yoffset, + mml->width, mml->height, mml->data, + dstStride, width, height, + texImage->Width, texImage->Height, + format, type, pixels, packing); + break; + case GR_TEXFMT_ARGB_8888: + dstStride = mml->width * 4; + result = _mesa_convert_texsubimage(MESA_A8_R8_G8_B8, xoffset, yoffset, + mml->width, mml->height, mml->data, + dstStride, width, height, + texImage->Width, texImage->Height, + format, type, pixels, packing); + break; + case GR_TEXFMT_ARGB_1555: + dstStride = mml->width * 2; + result = _mesa_convert_texsubimage(MESA_A1_R5_G5_B5, xoffset, yoffset, + mml->width, mml->height, mml->data, + dstStride, width, height, + texImage->Width, texImage->Height, + format, type, pixels, packing); + break; + default: + gl_problem(NULL, "tdfx driver: fxTexBuildSubImageMap() bad format"); + result = GL_FALSE; + } - return; + if (!result) { + return GL_FALSE; } - fxTexGetInfo(image->Width,image->Height,NULL,NULL,NULL,NULL,NULL,NULL,&wscale,&hscale); + if (ti->validated && ti->isInTM) + fxTMReloadSubMipMapLevel(fxMesa, texObj, level, yoffset, height); + else + fxTexInvalidate(ctx, texObj); - if((wscale!=1) || (hscale!=1)) { - if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: (wscale!=1) || (hscale!=1) in fxDDTexSubImg()\n"); - } - fxDDTexImg(ctx,target,tObj,level,internalFormat,image); + return GL_TRUE; +} - return; + +static void PrintTexture(int w, int h, int c, const GLubyte *data) +{ + int i, j; + for (i = 0; i < h; i++) { + for (j = 0; j < w; j++) { + if (c==2) + printf("%02x %02x ", data[0], data[1]); + else if (c==3) + printf("%02x %02x %02x ", data[0], data[1], data[2]); + data += c; + } + printf("\n"); } +} - if(mml->translated) - fxTexBuildSubImageMap(image,internalFormat,xoffset,yoffset, - width,height,mml->data); - if(ti->validated && ti->isInTM) - fxTMReloadSubMipMapLevel(fxMesa,tObj,level,yoffset,height); - else - fxTexInvalidate(ctx,tObj); +GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level, + const struct gl_texture_object *texObj, + GLenum *formatOut, GLenum *typeOut, + GLboolean *freeImageOut ) +{ + tfxTexInfo *ti; + tfxMipMapLevel *mml; + + if (target != GL_TEXTURE_2D) + return NULL; + + if (!texObj->DriverData) + return NULL; + + ti = fxTMGetTexInfo(texObj); + mml = &ti->mipmapLevel[level]; + if (mml->data) { + MesaIntTexFormat mesaFormat; + GLenum glFormat; + struct gl_texture_image *texImage = texObj->Image[level]; + GLint srcStride; + + GLubyte *data = (GLubyte *) MALLOC(texImage->Width * texImage->Height * 4); + if (!data) + return NULL; + + switch (mml->glideFormat) { + case GR_TEXFMT_INTENSITY_8: + mesaFormat = MESA_I8; + glFormat = GL_INTENSITY; + srcStride = mml->width; + break; + case GR_TEXFMT_ALPHA_INTENSITY_88: + mesaFormat = MESA_A8_L8; + glFormat = GL_LUMINANCE_ALPHA; + srcStride = mml->width; + break; + case GR_TEXFMT_ALPHA_8: + mesaFormat = MESA_A8; + glFormat = GL_ALPHA; + srcStride = mml->width; + break; + case GR_TEXFMT_RGB_565: + mesaFormat = MESA_R5_G6_B5; + glFormat = GL_RGB; + srcStride = mml->width * 2; + break; + case GR_TEXFMT_ARGB_8888: + mesaFormat = MESA_A8_R8_G8_B8; + glFormat = GL_RGBA; + srcStride = mml->width * 4; + break; + case GR_TEXFMT_ARGB_4444: + mesaFormat = MESA_A4_R4_G4_B4; + glFormat = GL_RGBA; + srcStride = mml->width * 2; + break; + case GR_TEXFMT_ARGB_1555: + mesaFormat = MESA_A1_R5_G5_B5; + glFormat = GL_RGBA; + srcStride = mml->width * 2; + break; + case GR_TEXFMT_P_8: + mesaFormat = MESA_C8; + glFormat = GL_COLOR_INDEX; + srcStride = mml->width; + break; + default: + gl_problem(NULL, "Bad glideFormat in fxDDGetTexImage"); + return NULL; + } + _mesa_unconvert_teximage(mesaFormat, mml->width, mml->height, mml->data, + srcStride, texImage->Width, texImage->Height, + glFormat, data); + *formatOut = glFormat; + *typeOut = GL_UNSIGNED_BYTE; + *freeImageOut = GL_TRUE; + return data; + } + else { + return NULL; + } } diff --git a/xc/extras/Mesa/src/FX/fxdrv.h b/xc/extras/Mesa/src/FX/fxdrv.h index e12a3244f..eea75fc56 100644 --- a/xc/extras/Mesa/src/FX/fxdrv.h +++ b/xc/extras/Mesa/src/FX/fxdrv.h @@ -50,14 +50,10 @@ * you turn debugging on/off from the debugger. */ -#ifndef XFree86Server -#include <math.h> -#include <stdio.h> -#include <stdlib.h> -#include <limits.h> -#include <assert.h> -#else +#ifdef XFree86Server #include "GL/xf86glx.h" +#else +#include "glheader.h" #endif @@ -87,8 +83,8 @@ typedef struct tfxMesaContext *fxMesaContext; -#if defined(MESA_DEBUG) && 0 extern void fx_sanity_triangle( GrVertex *, GrVertex *, GrVertex * ); +#if defined(MESA_DEBUG) && 0 #define grDrawTriangle fx_sanity_triangle #endif @@ -166,6 +162,7 @@ typedef struct { #endif #endif + #define FX_VB_COLOR(fxm, color) \ do { \ if (sizeof(GLint) == 4*sizeof(GLubyte)) { \ @@ -187,9 +184,9 @@ typedef struct { } #if FX_USE_PARGB -#define GOURAUD2(v, c) { \ - GLubyte *col = c; \ - v->argb=MESACOLOR2PARGB(col); \ +#define GOURAUD2(v, c) { \ + GLubyte *col = c; \ + v->argb=MESACOLOR2PARGB(col); \ } #else #define GOURAUD2(v, c) { \ @@ -230,13 +227,13 @@ typedef struct { #define FX_UM_E0_MODULATE 0x00000002 #define FX_UM_E0_DECAL 0x00000004 #define FX_UM_E0_BLEND 0x00000008 -#define FX_UM_E0_ADD 0x00000010 +#define FX_UM_E0_ADD 0x00000010 #define FX_UM_E1_REPLACE 0x00000020 #define FX_UM_E1_MODULATE 0x00000040 #define FX_UM_E1_DECAL 0x00000080 #define FX_UM_E1_BLEND 0x00000100 -#define FX_UM_E1_ADD 0x00000200 +#define FX_UM_E1_ADD 0x00000200 #define FX_UM_E_ENVMODE 0x000003ff @@ -261,6 +258,20 @@ typedef struct { #define FX_UM_ALPHA_ITERATED 0x04000000 #define FX_UM_ALPHA_CONSTANT 0x08000000 + +#define PACK_BGRA32(R, G, B, A) \ + ( (((GLuint) (R)) << 16) | \ + (((GLuint) (G)) << 8) | \ + (((GLuint) (B)) ) | \ + (((GLuint) (A)) << 24) ) + +#define PACK_RGBA32(R, G, B, A) \ + ( (((GLuint) (R)) ) | \ + (((GLuint) (G)) << 8) | \ + (((GLuint) (B)) << 16) | \ + (((GLuint) (A)) << 24) ) + + typedef void (*tfxRenderVBFunc)(GLcontext *); /* @@ -272,11 +283,10 @@ typedef struct MemRange_t { } MemRange; typedef struct { - GLsizei width, height; - GLint glideFormat; - - unsigned short *data; - GLboolean translated, used; + GLsizei width, height; /* image size */ + GLint texelSize; /* How many bytes to a texel */ + GrTextureFormat_t glideFormat; /* Glide image format */ + unsigned short *data; /* Glide-formated texture image */ } tfxMipMapLevel; typedef struct tfxTexInfo_t { @@ -345,27 +355,20 @@ extern tfxLineClipFunc fxLineClipTab[0x8]; typedef struct { /* Alpha test */ - GLboolean alphaTestEnabled; GrCmpFnc_t alphaTestFunc; GrAlpha_t alphaTestRefValue; /* Blend function */ - GLboolean blendEnabled; GrAlphaBlendFnc_t blendSrcFuncRGB; GrAlphaBlendFnc_t blendDstFuncRGB; GrAlphaBlendFnc_t blendSrcFuncAlpha; GrAlphaBlendFnc_t blendDstFuncAlpha; - - /* Depth test */ - - GLboolean depthTestEnabled; - GLboolean depthMask; - GrCmpFnc_t depthTestFunc; } tfxUnitsState; + /* Flags for render_index. */ #define FX_OFFSET 0x1 @@ -386,6 +389,7 @@ typedef struct { #define FX_NEW_SCISSOR 0x20 #define FX_NEW_COLOR_MASK 0x40 #define FX_NEW_CULL 0x80 +#define FX_NEW_STENCIL 0x100 /* FX struct stored in VB->driver_data. */ @@ -427,8 +431,6 @@ extern GLubyte FX_PixelToB[0x10000]; struct tfxMesaContext { - GuTexPalette glbPalette; - GLcontext *glCtx; /* the core Mesa context */ GLvisual *glVis; /* describes the color buffer */ GLframebuffer *glBuffer; /* the ancillary buffers */ @@ -439,6 +441,7 @@ struct tfxMesaContext { GrBuffer_t currentFB; GLboolean bgrOrder; + GLuint depthClear; GrColor_t color; GrColor_t clearC; GrAlpha_t clearA; @@ -448,6 +451,8 @@ struct tfxMesaContext { tfxUnitsState unitsState; tfxUnitsState restoreUnitsState; /* saved during multipass */ + GuTexPalette glbPalette; + GLuint tmu_source[FX_NUM_TMU]; GLuint tex_dest[MAX_TEXTURE_UNITS]; GLuint setupindex; @@ -471,7 +476,6 @@ struct tfxMesaContext { GLuint texBindNumber; GLint tmuSrc; - GLuint lastUnitsMode; GLuint freeTexMem[FX_NUM_TMU]; MemRange *tmPool; MemRange *tmFree[FX_NUM_TMU]; @@ -506,8 +510,7 @@ struct tfxMesaContext { GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */ GLboolean emulateTwoTMUs; /* True if we present 2 tmu's to mesa. */ GLboolean haveAlphaBuffer; - GLboolean haveZBuffer; - GLboolean haveDoubleBuffer; + GLboolean haveHwStencil; GLboolean haveGlobalPaletteTexture; GLint swapInterval; GLint maxPendingSwapBuffers; @@ -534,6 +537,7 @@ typedef void (*tfxSetupFunc)(struct vertex_buffer *, GLuint, GLuint); extern GrHwConfiguration glbHWConfig; extern int glbCurrentBoard; +extern void fxPrintSetupFlags( const char *msg, GLuint flags ); extern void fxSetupFXUnits(GLcontext *); extern void fxSetupDDPointers(GLcontext *); extern void fxDDSetNearFar(GLcontext *, GLfloat, GLfloat); @@ -567,24 +571,34 @@ extern void fxUpdateDDSpanPointers(GLcontext *); extern void fxSetupDDSpanPointers(GLcontext *); extern void fxPrintTextureData(tfxTexInfo *ti); -extern void fxDDTexEnv(GLcontext *, GLenum, const GLfloat *); -extern void fxDDTexImg(GLcontext *, GLenum, struct gl_texture_object *, - GLint, GLint, const struct gl_texture_image *); +extern GLboolean fxDDTexImage2D(GLcontext *ctx, GLenum target, GLint level, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLboolean *retainInternalCopy); +extern GLboolean fxDDTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage); +extern GLvoid *fxDDGetTexImage(GLcontext *ctx, GLenum target, GLint level, + const struct gl_texture_object *texObj, + GLenum *formatOut, GLenum *typeOut, + GLboolean *freeImageOut ); +extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *); extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *, GLenum, const GLfloat *); extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *); extern void fxDDTexDel(GLcontext *, struct gl_texture_object *); extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *); -extern void fxDDTexuseGlbPalette(GLcontext *, GLboolean); -extern void fxDDTexSubImg(GLcontext *, GLenum, struct gl_texture_object *, GLint, - GLint, GLint, GLint, GLint, GLint, const struct gl_texture_image *); extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean); extern void fxDDEnable(GLcontext *, GLenum, GLboolean); extern void fxDDAlphaFunc(GLcontext *, GLenum, GLclampf); extern void fxDDBlendFunc(GLcontext *, GLenum, GLenum); -extern void fxDDDepthMask(GLcontext *, GLboolean); -extern void fxDDDepthFunc(GLcontext *, GLenum); extern void fxDDRegisterVB( struct vertex_buffer *VB ); extern void fxDDUnregisterVB( struct vertex_buffer *VB ); @@ -619,6 +633,7 @@ extern void fxDDInitExtensions( GLcontext *ctx ); #define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData)) extern void fxTMInit(fxMesaContext ctx); extern void fxTMClose(fxMesaContext ctx); +extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx); extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint); extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *); #define fxTMMoveOutTM_NoLock fxTMMoveOutTM diff --git a/xc/extras/Mesa/src/FX/fxglidew.c b/xc/extras/Mesa/src/FX/fxglidew.c index 790e5c923..f01644a60 100644 --- a/xc/extras/Mesa/src/FX/fxglidew.c +++ b/xc/extras/Mesa/src/FX/fxglidew.c @@ -55,6 +55,13 @@ #include <stdlib.h> #include <string.h> + +grStencilFunc_t grStencilFuncPtr = NULL; +grStencilMask_t grStencilMaskPtr = NULL; +grStencilOp_t grStencilOpPtr = NULL; +grBufferClearExt_t grBufferClearExtPtr = NULL; + + FxI32 FX_grGetInteger_NoLock(FxU32 pname) { #if !defined(FX_GLIDE3) @@ -71,6 +78,8 @@ FxI32 FX_grGetInteger_NoLock(FxU32 pname) case FX_TEXTURE_ALIGN: /* This is a guess from reading the glide3 docs */ return 8; + case FX_ZDEPTH_MAX: + return 0xFFFF; default: if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n"); @@ -90,6 +99,12 @@ FxI32 FX_grGetInteger_NoLock(FxU32 pname) case FX_TEXTURE_ALIGN: grname = pname; break; + case FX_ZDEPTH_MAX: { + int zvals[2]; + + grGet(GR_ZDEPTH_MIN_MAX, 8, zvals); + return zvals[0]; + } default: if (MESA_VERBOSE&VERBOSE_DRIVER) { fprintf(stderr,"Wrong parameter in FX_grGetInteger!\n"); @@ -154,7 +169,17 @@ extern FxU32 FX_grTexMaxAddress(GrChipID_t tmu) { FxBool FX_grSstControl(FxU32 code) { #if defined(FX_GLIDE3) - (void) code; + /* The glide 3 sources call for grEnable/grDisable to be called in exchange + * for grSstControl. */ + switch(code) { + case GR_CONTROL_ACTIVATE: + grEnable(GR_PASSTHRU); + break; + case GR_CONTROL_DEACTIVATE: + grDisable(GR_PASSTHRU); + break; + } + /* Appearently GR_CONTROL_RESIZE can be ignored. */ return 1; /* OK? */ #else FxU32 result; @@ -225,12 +250,12 @@ void FX_grGlideGetVersion(char *buf) void FX_grSstPerfStats(GrSstPerfStats_t *st) { - /* ToDo */ - st->pixelsIn = 0; - st->chromaFail = 0; - st->zFuncFail = 0; - st->aFuncFail = 0; - st->pixelsOut = 0; + FxI32 n; + grGet(GR_STATS_PIXELS_IN, 4, &n); st->pixelsIn = n; + grGet(GR_STATS_PIXELS_CHROMA_FAIL, 4, &n); st->chromaFail = n; + grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &n); st->zFuncFail = n; + grGet(GR_STATS_PIXELS_AFUNC_FAIL, 4, &n); st->aFuncFail = n; + grGet(GR_STATS_PIXELS_OUT, 4, &n); st->pixelsOut = n; } void FX_grAADrawLine(GrVertex *a,GrVertex *b) @@ -385,6 +410,10 @@ int FX_grSstQueryHardware(GrHwConfiguration *c) return i; } + +#endif /* FX_GLIDE3 */ + +/* It appears to me that this function is needed either way. */ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd, GrScreenResolution_t screen_resolution, GrScreenRefresh_t refresh_rate, @@ -403,6 +432,7 @@ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd, nColBuffers, nAuxBuffers ); + /* fprintf(stderr, "grSstWinOpen( win %d res %d ref %d fmt %d\n" " org %d ncol %d naux %d )\n" @@ -415,13 +445,13 @@ FX_GrContext_t FX_grSstWinOpen( FxU32 hWnd, nColBuffers, nAuxBuffers, i); + */ END_BOARD_LOCK(); return i; } -#endif #else /* diff --git a/xc/extras/Mesa/src/FX/fxglidew.h b/xc/extras/Mesa/src/FX/fxglidew.h index 28556d8c5..4ad2942af 100644 --- a/xc/extras/Mesa/src/FX/fxglidew.h +++ b/xc/extras/Mesa/src/FX/fxglidew.h @@ -47,7 +47,51 @@ #define __FX_GLIDE_WARPER__ #include <glide.h> +#include <g3ext.h> +/* + * These are glide extension definitions. These are not + * defined in glide.h. They should really be defined in + * g3ext.h, but they are not. + */ +#if 0 +FX_ENTRY void FX_CALL +grStencilFunc(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask); + +FX_ENTRY void FX_CALL +grStencilMask(GrStencil_t write_mask); + +FX_ENTRY void FX_CALL +grStencilOp( + GrStencilOp_t stencil_fail, + GrStencilOp_t depth_fail, + GrStencilOp_t depth_pass); + +FX_ENTRY void FX_CALL +grBufferClearExt( + GrColor_t color, + GrAlpha_t alpha, + FxU32 depth, + GrStencil_t stencil); +#endif + + +typedef void (*grStencilFunc_t)(GrCmpFnc_t fnc, GrStencil_t ref, GrStencil_t mask); +typedef void (*grStencilMask_t)(GrStencil_t write_mask); +typedef void (*grStencilOp_t)(GrStencilOp_t stencil_fail, GrStencilOp_t depth_fail, GrStencilOp_t depth_pass); +typedef void (*grBufferClearExt_t)(GrColor_t color, GrAlpha_t alpha, FxU32 depth, GrStencil_t stencil); + +extern grStencilFunc_t grStencilFuncPtr; +extern grStencilMask_t grStencilMaskPtr; +extern grStencilOp_t grStencilOpPtr; +extern grBufferClearExt_t grBufferClearExtPtr; + + +FX_ENTRY void FX_CALL +grEnable(GrEnableMode_t mode); + +FX_ENTRY void FX_CALL +grEnable(GrEnableMode_t mode); /* * General context: */ @@ -74,12 +118,13 @@ #define FX_PENDING_BUFFERSWAPS GR_PENDING_BUFFERSWAPS #define FX_TEXTURE_ALIGN GR_TEXTURE_ALIGN #endif +#define FX_ZDEPTH_MAX 0x100 /* * Genral warper functions for Glide2/Glide3: */ -extern FxI32 FX_grGetInteger(FxU32 pname); extern FxI32 FX_grGetInteger_NoLock(FxU32 pname); +extern FxI32 FX_grGetInteger(FxU32 pname); /* * Glide2 emulation on Glide3: @@ -253,7 +298,6 @@ typedef struct #endif - /* * Glide2 functions for Glide3 */ @@ -567,6 +611,55 @@ extern void FX_grDrawPolygonVertexList(int n, GrVertex *v); END_CLIP_LOOP(); \ } while (0) +#define FX_grBufferClearExt(c, a, d, s) \ + do { \ + BEGIN_CLIP_LOOP(); \ + (*grBufferClearExtPtr)(c, a, d, s); \ + END_CLIP_LOOP(); \ + } while (0) + +/* + * Enable/Disable + */ +#define FX_grEnable(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grEnable(m); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grDisable(m) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grDisable(m); \ + END_BOARD_LOCK(); \ + } while (0) + +/* + * Stencil operations. + */ +#define FX_grStencilFunc(fnc, ref, mask) \ + do { \ + BEGIN_BOARD_LOCK(); \ + (*grStencilFuncPtr)((fnc), (ref), (mask)); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grStencilMask(write_mask) \ + do { \ + BEGIN_BOARD_LOCK(); \ + (*grStencilMaskPtr)(write_mask); \ + END_BOARD_LOCK(); \ + } while (0) + + +#define FX_grStencilOp(stencil_fail, depth_fail, depth_pass) \ + do { \ + BEGIN_BOARD_LOCK(); \ + (*grStencilOpPtr)((stencil_fail), (depth_fail), (depth_pass)); \ + END_BOARD_LOCK(); \ + } while (0) + #define FX_grDepthMask(m) \ do { \ BEGIN_BOARD_LOCK(); \ @@ -821,9 +914,18 @@ extern FxU32 FX_grTexTextureMemRequired(FxU32 evenOdd, GrTexInfo *info); #define FX_grGlideShutdown() \ do { \ - BEGIN_CLIP_LOOP(); \ + BEGIN_BOARD_LOCK(); \ grGlideShutdown(); \ - END_CLIP_LOOP(); \ + END_BOARD_LOCK(); \ + } while (0) + +#define FX_grTexLodBiasValue_NoLock(t, v) grTexLodBiasValue(t, v) + +#define FX_grTexLodBiasValue(t, v) \ + do { \ + BEGIN_BOARD_LOCK(); \ + grTexLodBiasValue(t, v); \ + END_BOARD_LOCK(); \ } while (0) #define FX_grGlideInit_NoLock grGlideInit diff --git a/xc/extras/Mesa/src/FX/fxsetup.c b/xc/extras/Mesa/src/FX/fxsetup.c index 8707aed1d..f07a2ecec 100644 --- a/xc/extras/Mesa/src/FX/fxsetup.c +++ b/xc/extras/Mesa/src/FX/fxsetup.c @@ -62,16 +62,11 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset); static void fxSetupDoubleTMU_NoLock(fxMesaContext fxMesa, struct gl_texture_object *tObj0, struct gl_texture_object *tObj1); -static void fxSetupTexture_NoLock(GLcontext *ctx); -static void fxSetupTexture(GLcontext *ctx); -static void fxSetupBlend(GLcontext *ctx); -static void fxSetupDepthTest(GLcontext *ctx); -static void fxSetupScissor(GLcontext *ctx); -static void fxSetupCull(GLcontext *ctx); static void gl_print_fx_state_flags( const char *msg, GLuint flags); -static GLboolean fxMultipassBlend(struct vertex_buffer *, GLuint); static GLboolean fxMultipassTexture( struct vertex_buffer *, GLuint ); + + static void fxTexValidate(GLcontext *ctx, struct gl_texture_object *tObj) { tfxTexInfo *ti=fxTMGetTexInfo(tObj); @@ -183,7 +178,7 @@ static GLuint fxGetTexSetConfiguration(GLcontext *ctx, GLuint envmode=0; GLuint ifmt=0; - if((ctx->Light.ShadeModel==GL_SMOOTH) || + if((ctx->Light.ShadeModel==GL_SMOOTH) || 1 || (ctx->Point.SmoothFlag) || (ctx->Line.SmoothFlag) || (ctx->Polygon.SmoothFlag)) @@ -191,11 +186,13 @@ static GLuint fxGetTexSetConfiguration(GLcontext *ctx, else unitsmode|=FX_UM_ALPHA_CONSTANT; - if(ctx->Light.ShadeModel==GL_SMOOTH) + if(ctx->Light.ShadeModel==GL_SMOOTH || 1) unitsmode|=FX_UM_COLOR_ITERATED; else unitsmode|=FX_UM_COLOR_CONSTANT; + + /* OpenGL Feeds Texture 0 into Texture 1 Glide Feeds Texture 1 into Texture 0 @@ -476,11 +473,6 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) else unitsmode=fxGetTexSetConfiguration(ctx,NULL,tObj); - if(fxMesa->lastUnitsMode==unitsmode) - return; - - fxMesa->lastUnitsMode=unitsmode; - fxMesa->stw_hint_state = 0; FX_grHints_NoLock(GR_HINT_STWHINT,0); @@ -555,9 +547,8 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) FXTRUE); ctx->Driver.MultipassFunc = fxMultipassBlend; #else -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: GL_BLEND not yet supported\n"); -#endif + if (MESA_VERBOSE&VERBOSE_DRIVER) + fprintf(stderr,"fx Driver: GL_BLEND not yet supported\n"); #endif break; case GL_REPLACE: @@ -588,9 +579,9 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) FXFALSE); break; default: -#ifndef FX_SILENT - fprintf(stderr,"fx Driver: %x Texture.EnvMode not yet supported\n",ctx->Texture.Unit[textureset].EnvMode); -#endif + if (MESA_VERBOSE&VERBOSE_DRIVER) + fprintf(stderr, "fx Driver: %x Texture.EnvMode not yet supported\n", + ctx->Texture.Unit[textureset].EnvMode); break; } @@ -599,7 +590,8 @@ static void fxSetupTextureSingleTMU_NoLock(GLcontext *ctx, GLuint textureset) } } -static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) { +static void fxSetupTextureSingleTMU(GLcontext *ctx, GLuint textureset) +{ BEGIN_BOARD_LOCK(); fxSetupTextureSingleTMU_NoLock(ctx, textureset); END_BOARD_LOCK(); @@ -764,11 +756,6 @@ static void fxSetupTextureDoubleTMU_NoLock(GLcontext *ctx) unitsmode=fxGetTexSetConfiguration(ctx,tObj0,tObj1); - if(fxMesa->lastUnitsMode==unitsmode) - return; - - fxMesa->lastUnitsMode=unitsmode; - fxMesa->stw_hint_state |= GR_STWHINT_ST_DIFF_TMU1; FX_grHints_NoLock(GR_HINT_STWHINT, fxMesa->stw_hint_state); @@ -1030,7 +1017,7 @@ static void fxSetupTextureNone_NoLock(GLcontext *ctx) fprintf(stderr,"fxmesa: fxSetupTextureNone(...)\n"); } - if((ctx->Light.ShadeModel==GL_SMOOTH) || + if((ctx->Light.ShadeModel==GL_SMOOTH) || 1 || (ctx->Point.SmoothFlag) || (ctx->Line.SmoothFlag) || (ctx->Polygon.SmoothFlag)) @@ -1038,7 +1025,7 @@ static void fxSetupTextureNone_NoLock(GLcontext *ctx) else locala=GR_COMBINE_LOCAL_CONSTANT; - if(ctx->Light.ShadeModel==GL_SMOOTH) + if(ctx->Light.ShadeModel==GL_SMOOTH || 1) localc=GR_COMBINE_LOCAL_ITERATED; else localc=GR_COMBINE_LOCAL_CONSTANT; @@ -1054,8 +1041,6 @@ static void fxSetupTextureNone_NoLock(GLcontext *ctx) localc, GR_COMBINE_OTHER_NONE, FXFALSE); - - fxMesa->lastUnitsMode=FX_UM_NONE; } /************************************************************************/ @@ -1106,7 +1091,8 @@ static void fxSetupTexture_NoLock(GLcontext *ctx) } } -static void fxSetupTexture(GLcontext *ctx) { +static void fxSetupTexture(GLcontext *ctx) +{ BEGIN_BOARD_LOCK(); fxSetupTexture_NoLock(ctx); END_BOARD_LOCK(); @@ -1239,15 +1225,19 @@ void fxDDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor) static void fxSetupBlend(GLcontext *ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; + fxMesaContext fxMesa = FX_CONTEXT(ctx); + tfxUnitsState *us = &fxMesa->unitsState; - if(us->blendEnabled) - FX_grAlphaBlendFunction(us->blendSrcFuncRGB,us->blendDstFuncRGB, - us->blendSrcFuncAlpha,us->blendDstFuncAlpha); + assert(us->blendEnabled == ctx->Color.BlendEnabled); + + if (us->blendEnabled) + FX_grAlphaBlendFunction(us->blendSrcFuncRGB, us->blendDstFuncRGB, + us->blendSrcFuncAlpha, us->blendDstFuncAlpha); else - FX_grAlphaBlendFunction(GR_BLEND_ONE,GR_BLEND_ZERO,GR_BLEND_ONE,GR_BLEND_ZERO); + FX_grAlphaBlendFunction(GR_BLEND_ONE, GR_BLEND_ZERO, + GR_BLEND_ONE, GR_BLEND_ZERO); } + /************************************************************************/ /************************** Alpha Test SetUp ****************************/ @@ -1255,8 +1245,8 @@ static void fxSetupBlend(GLcontext *ctx) void fxDDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; + fxMesaContext fxMesa = FX_CONTEXT(ctx); + tfxUnitsState *us = &fxMesa->unitsState; GrCmpFnc_t newfunc; switch(func) { @@ -1316,81 +1306,118 @@ static void fxSetupAlphaTest(GLcontext *ctx) FX_grAlphaTestFunction(GR_CMP_ALWAYS); } -/************************************************************************/ -/************************** Depth Test SetUp ****************************/ -/************************************************************************/ -void fxDDDepthFunc(GLcontext *ctx, GLenum func) +/* + * Evaluate all depth-test state and make the Glide calls. + */ +static void +fxSetupDepthTest(GLcontext *ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; - GrCmpFnc_t dfunc; - - switch(func) { - case GL_NEVER: - dfunc=GR_CMP_NEVER; - break; - case GL_LESS: - dfunc=GR_CMP_LESS; - break; - case GL_GEQUAL: - dfunc=GR_CMP_GEQUAL; - break; - case GL_LEQUAL: - dfunc=GR_CMP_LEQUAL; - break; - case GL_GREATER: - dfunc=GR_CMP_GREATER; - break; - case GL_NOTEQUAL: - dfunc=GR_CMP_NOTEQUAL; - break; - case GL_EQUAL: - dfunc=GR_CMP_EQUAL; - break; - case GL_ALWAYS: - dfunc=GR_CMP_ALWAYS; - break; - default: - fprintf(stderr,"fx Driver: internal error in fxDDDepthFunc()\n"); - fxCloseHardware(); - exit(-1); - break; + if (ctx->Depth.Test) { + GrCmpFnc_t dfunc; + switch (ctx->Depth.Func) { + case GL_NEVER: + dfunc = GR_CMP_NEVER; + break; + case GL_LESS: + dfunc = GR_CMP_LESS; + break; + case GL_GEQUAL: + dfunc = GR_CMP_GEQUAL; + break; + case GL_LEQUAL: + dfunc = GR_CMP_LEQUAL; + break; + case GL_GREATER: + dfunc = GR_CMP_GREATER; + break; + case GL_NOTEQUAL: + dfunc = GR_CMP_NOTEQUAL; + break; + case GL_EQUAL: + dfunc = GR_CMP_EQUAL; + break; + case GL_ALWAYS: + dfunc = GR_CMP_ALWAYS; + break; + default: + gl_problem(ctx, "bad depth mode in fxSetupDepthTest"); + dfunc = GR_CMP_ALWAYS; + } + FX_grDepthBufferFunction(dfunc); + FX_grDepthMask(ctx->Depth.Mask); } - - if(dfunc!=us->depthTestFunc) { - us->depthTestFunc=dfunc; - fxMesa->new_state |= FX_NEW_DEPTH; - ctx->Driver.RenderStart = fxSetupFXUnits; + else { + /* depth test always passes, don't update Z buffer */ + FX_grDepthBufferFunction(GR_CMP_ALWAYS); + FX_grDepthMask(FXFALSE); } - } -void fxDDDepthMask(GLcontext *ctx, GLboolean flag) -{ - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; - if(flag!=us->depthMask) { - us->depthMask=flag; - fxMesa->new_state |= FX_NEW_DEPTH; - ctx->Driver.RenderStart = fxSetupFXUnits; +/* + * Evaluate all stencil state and make the Glide calls. + */ +static GrStencil_t +fxConvertGLStencilOp(GLenum op) +{ + switch (op) { + case GL_KEEP: + return GR_STENCILOP_KEEP; + case GL_ZERO: + return GR_STENCILOP_ZERO; + case GL_REPLACE: + return GR_STENCILOP_REPLACE; + case GL_INCR: + return GR_STENCILOP_INCR_CLAMP; + case GL_DECR: + return GR_STENCILOP_DECR_CLAMP; + case GL_INVERT: + return GR_STENCILOP_INVERT; + default: + gl_problem(NULL, "bad stencil op in fxConvertGLStencilOp"); } + return GR_STENCILOP_KEEP; /* never get, silence compiler warning */ } -static void fxSetupDepthTest(GLcontext *ctx) +/* + * This function is called just before any rendering is done. + * It will validate the stencil parameters. + */ +static void +fxSetupStencilTest(GLcontext *ctx) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; + if (ctx->Stencil.Enabled) { + GrStencil_t sfail = fxConvertGLStencilOp(ctx->Stencil.FailFunc); + GrStencil_t zfail = fxConvertGLStencilOp(ctx->Stencil.ZFailFunc); + GrStencil_t zpass = fxConvertGLStencilOp(ctx->Stencil.ZPassFunc); + FX_grStencilOp(sfail, zfail, zpass); + FX_grStencilFunc(ctx->Stencil.Function - GL_NEVER, + ctx->Stencil.Ref, ctx->Stencil.ValueMask); + FX_grStencilMask(ctx->Stencil.WriteMask); + FX_grEnable(GR_STENCIL_MODE_EXT); + } + else { + FX_grDisable(GR_STENCIL_MODE_EXT); + } +} - if(us->depthTestEnabled) - FX_grDepthBufferFunction(us->depthTestFunc); - else - FX_grDepthBufferFunction(GR_CMP_ALWAYS); - FX_grDepthMask(us->depthMask); +/* + * Set the state so that stencil is either enabled or disabled. + * This is called from Mesa only. Glide is invoked at + * setup time, not now. + */ +static void +fxDDEnableStencil(GLcontext *ctx, GLboolean state) +{ + fxMesaContext fxMesa = FX_CONTEXT(ctx); + (void) state; + fxMesa->new_state |= FX_NEW_STENCIL; + ctx->Driver.RenderStart = fxSetupFXUnits; } + /************************************************************************/ /**************************** Color Mask SetUp **************************/ /************************************************************************/ @@ -1410,14 +1437,20 @@ static void fxSetupColorMask(GLcontext *ctx) { fxMesaContext fxMesa = FX_CONTEXT(ctx); - FX_grColorMask(ctx->Color.ColorMask[RCOMP] || - ctx->Color.ColorMask[GCOMP] || - ctx->Color.ColorMask[BCOMP], - ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); + if (ctx->Color.DrawBuffer == GL_NONE) { + FX_grColorMask(FXFALSE, FXFALSE); + } + else { + FX_grColorMask(ctx->Color.ColorMask[RCOMP] || + ctx->Color.ColorMask[GCOMP] || + ctx->Color.ColorMask[BCOMP], + ctx->Color.ColorMask[ACOMP] && fxMesa->haveAlphaBuffer); + } } + /************************************************************************/ /**************************** Fog Mode SetUp ****************************/ /************************************************************************/ @@ -1582,59 +1615,71 @@ static void fxSetupCull(GLcontext *ctx) void fxDDEnable(GLcontext *ctx, GLenum cap, GLboolean state) { - fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; - tfxUnitsState *us=&fxMesa->unitsState; + fxMesaContext fxMesa = FX_CONTEXT(ctx); + tfxUnitsState *us = &fxMesa->unitsState; if (MESA_VERBOSE&VERBOSE_DRIVER) { - fprintf(stderr,"fxmesa: fxDDEnable(...)\n"); + fprintf(stderr,"fxmesa: fxDDEnable(...)\n"); } switch(cap) { - case GL_ALPHA_TEST: - if(state!=us->alphaTestEnabled) { - us->alphaTestEnabled=state; - fxMesa->new_state |= FX_NEW_ALPHA; + case GL_ALPHA_TEST: + if(state!=us->alphaTestEnabled) { + us->alphaTestEnabled=state; + fxMesa->new_state |= FX_NEW_ALPHA; + ctx->Driver.RenderStart = fxSetupFXUnits; + } + break; + case GL_BLEND: + if(state!=us->blendEnabled) { + us->blendEnabled=state; + fxMesa->new_state |= FX_NEW_BLEND; + ctx->Driver.RenderStart = fxSetupFXUnits; + } + break; + case GL_DEPTH_TEST: + fxMesa->new_state |= FX_NEW_DEPTH; ctx->Driver.RenderStart = fxSetupFXUnits; - } - break; - case GL_BLEND: - if(state!=us->blendEnabled) { - us->blendEnabled=state; - fxMesa->new_state |= FX_NEW_BLEND; + break; + case GL_DITHER: + if (state) + FX_grDitherMode(GR_DITHER_4x4); + else + FX_grDitherMode(GR_DITHER_DISABLE); + break; + case GL_SCISSOR_TEST: + fxMesa->new_state |= FX_NEW_SCISSOR; ctx->Driver.RenderStart = fxSetupFXUnits; - } - break; - case GL_DEPTH_TEST: - if(state!=us->depthTestEnabled) { - us->depthTestEnabled=state; - fxMesa->new_state |= FX_NEW_DEPTH; + break; + case GL_SHARED_TEXTURE_PALETTE_EXT: + fxDDTexUseGlbPalette(ctx, state); + break; + case GL_FOG: + fxMesa->new_state |= FX_NEW_FOG; ctx->Driver.RenderStart = fxSetupFXUnits; - } - break; - case GL_SCISSOR_TEST: - fxMesa->new_state |= FX_NEW_SCISSOR; - ctx->Driver.RenderStart = fxSetupFXUnits; - break; - case GL_FOG: - fxMesa->new_state |= FX_NEW_FOG; - ctx->Driver.RenderStart = fxSetupFXUnits; - break; - case GL_CULL_FACE: - fxMesa->new_state |= FX_NEW_CULL; - ctx->Driver.RenderStart = fxSetupFXUnits; - break; - case GL_LINE_SMOOTH: - case GL_POINT_SMOOTH: - case GL_POLYGON_SMOOTH: - case GL_TEXTURE_2D: + break; + case GL_CULL_FACE: + fxMesa->new_state |= FX_NEW_CULL; + ctx->Driver.RenderStart = fxSetupFXUnits; + break; + case GL_LINE_SMOOTH: + case GL_LINE_STIPPLE: + case GL_POINT_SMOOTH: + case GL_POLYGON_SMOOTH: + case GL_TEXTURE_2D: fxMesa->new_state |= FX_NEW_TEXTURING; ctx->Driver.RenderStart = fxSetupFXUnits; break; - default: - ; /* XXX no-op??? */ + case GL_STENCIL_TEST: + fxMesa->new_state |= FX_NEW_STENCIL; + ctx->Driver.RenderStart = fxSetupFXUnits; + break; + default: + ; /* no-op */ } } + #if 0 /* Multipass to do GL_BLEND texture functions @@ -1663,11 +1708,17 @@ static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass) } fxDDDepthMask(ctx, FALSE); } + /* + * Disable stencil as well. + */ + if (ctx->Stencil.Enabled) { + fxDDEnableStencil(ctx, GL_FALSE); + } /* Enable Cc*Ct mode */ - /* ??? Set the Constant Color ??? */ + /* XXX Set the Constant Color ? */ fxDDEnable(ctx, GL_BLEND, GL_TRUE); - fxDDBlendFunc(ctx, ???, ???); - fxSetupTextureSingleTMU(ctx, ???); + fxDDBlendFunc(ctx, XXX, XXX); + fxSetupTextureSingleTMU(ctx, XXX); fxSetupBlend(ctx); fxSetupDepthTest(ctx); break; @@ -1675,10 +1726,11 @@ static GLboolean fxMultipassBlend(struct vertex_buffer *VB, GLuint pass) case 2: /* Reset everything back to normal */ fxMesa->unitsState = fxMesa->restoreUnitsState; - fxMesa->setupdone &= ???; - fxSetupTextureSingleTMU(ctx, ???); + fxMesa->setupdone &= XXX; + fxSetupTextureSingleTMU(ctx, XXX); fxSetupBlend(ctx); fxSetupDepthTest(ctx); + fxSetupStencilText(ctx); break; } @@ -1724,13 +1776,15 @@ static GLboolean fxMultipassTexture( struct vertex_buffer *VB, GLuint pass ) case GL_ALWAYS: break; default: - fxDDDepthFunc( ctx, GL_EQUAL ); + /*fxDDDepthFunc( ctx, GL_EQUAL );*/ + FX_grDepthBufferFunction(GR_CMP_EQUAL); break; } - fxDDDepthMask( ctx, GL_FALSE ); + /*fxDDDepthMask( ctx, GL_FALSE ); */ + FX_grDepthMask(FXFALSE); } - + fxDDEnableStencil(ctx, GL_FALSE); if (ctx->Texture.Unit[1].EnvMode == GL_MODULATE) { fxDDEnable( ctx, GL_BLEND, GL_TRUE ); fxDDBlendFunc( ctx, GL_DST_COLOR, GL_ZERO ); @@ -1750,6 +1804,7 @@ static GLboolean fxMultipassTexture( struct vertex_buffer *VB, GLuint pass ) fxSetupTextureSingleTMU( ctx, 0 ); fxSetupBlend( ctx ); fxSetupDepthTest( ctx ); + fxSetupStencilTest( ctx ); break; } @@ -1807,10 +1862,13 @@ void fxSetupFXUnits( GLcontext *ctx ) if (newstate & FX_NEW_ALPHA) fxSetupAlphaTest(ctx); - + if (newstate & FX_NEW_DEPTH) fxSetupDepthTest(ctx); + if (newstate & FX_NEW_STENCIL) + fxSetupStencilTest(ctx); + if (newstate & FX_NEW_FOG) fxSetupFog(ctx); @@ -1822,14 +1880,11 @@ void fxSetupFXUnits( GLcontext *ctx ) if (newstate & FX_NEW_CULL) fxSetupCull(ctx); - fxMesa->new_state = 0; /* ctx->Driver.RenderStart = 0; */ } } - - #else diff --git a/xc/extras/Mesa/src/FX/fxtexman.c b/xc/extras/Mesa/src/FX/fxtexman.c index 87f309adc..5066efa55 100644 --- a/xc/extras/Mesa/src/FX/fxtexman.c +++ b/xc/extras/Mesa/src/FX/fxtexman.c @@ -146,10 +146,10 @@ static void fxTMUInit(fxMesaContext fxMesa, int tmu) end=FX_grTexMaxAddress(tmu); if(fxMesa->verbose) { - fprintf(stderr,"%s configuration:",(tmu==FX_TMU0) ? "TMU0" : "TMU1"); - fprintf(stderr," Lower texture memory address (%u)\n",(unsigned int)start); - fprintf(stderr," Higher texture memory address (%u)\n",(unsigned int)end); - fprintf(stderr," Splitting Texture memory in 2b blocks:\n"); + fprintf(stderr,"Voodoo %s configuration:",(tmu==FX_TMU0) ? "TMU0" : "TMU1"); + fprintf(stderr,"Voodoo Lower texture memory address (%u)\n",(unsigned int)start); + fprintf(stderr,"Voodoo Higher texture memory address (%u)\n",(unsigned int)end); + fprintf(stderr,"Voodoo Splitting Texture memory in 2b blocks:\n"); } fxMesa->freeTexMem[tmu]=end-start; @@ -162,7 +162,7 @@ static void fxTMUInit(fxMesaContext fxMesa, int tmu) else blockend=blockstart+FX_2MB_SPLIT; if(fxMesa->verbose) - fprintf(stderr," %07u-%07u\n", + fprintf(stderr,"Voodoo %07u-%07u\n", (unsigned int)blockstart,(unsigned int)blockend); tmn=fxTMNewRangeNode(fxMesa, blockstart, blockend); @@ -545,12 +545,8 @@ void fxTMReloadSubMipMapLevel(fxMesaContext fxMesa, fxTexGetInfo(ti->mipmapLevel[0].width, ti->mipmapLevel[0].height, &lodlevel, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - if((ti->info.format==GR_TEXFMT_INTENSITY_8) || - (ti->info.format==GR_TEXFMT_P_8) || - (ti->info.format==GR_TEXFMT_ALPHA_8)) - data=ti->mipmapLevel[level].data+((yoffset*ti->mipmapLevel[level].width)>>1); - else - data=ti->mipmapLevel[level].data+yoffset*ti->mipmapLevel[level].width; + data=ti->mipmapLevel[level].data + + yoffset*ti->mipmapLevel[level].width*ti->mipmapLevel[level].texelSize; switch(tmu) { case FX_TMU0: @@ -651,12 +647,11 @@ void fxTMFreeTexture(fxMesaContext fxMesa, struct gl_texture_object *tObj) fxTMMoveOutTM(fxMesa, tObj); - for(i=0; i<MAX_TEXTURE_LEVELS; i++) { - if (ti->mipmapLevel[i].used && - ti->mipmapLevel[i].translated) + for (i=0; i<MAX_TEXTURE_LEVELS; i++) { + if (ti->mipmapLevel[i].data) { FREE(ti->mipmapLevel[i].data); - - (void)ti->mipmapLevel[i].data; + ti->mipmapLevel[i].data = NULL; + } } switch (ti->whichTMU) { case FX_TMU0: diff --git a/xc/extras/Mesa/src/FX/fxtritmp.h b/xc/extras/Mesa/src/FX/fxtritmp.h index 06df4dcd0..6411d167a 100644 --- a/xc/extras/Mesa/src/FX/fxtritmp.h +++ b/xc/extras/Mesa/src/FX/fxtritmp.h @@ -66,7 +66,9 @@ static void TAG(fx_tri)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, GLuint GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit; GLubyte (*color)[4] = VB->Color[facing]->data; if (IND & FX_FLAT) { - FX_VB_COLOR(fxMesa, color[pv]); + GOURAUD2(v1,color[pv]); + GOURAUD2(v2,color[pv]); + GOURAUD2(v3,color[pv]); } else { GOURAUD2(v1,color[e1]); GOURAUD2(v2,color[e2]); @@ -103,7 +105,9 @@ static void TAG(fx_tri)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, GLuint } else if (IND & FX_FLAT) { GLubyte (*color)[4] = VB->Color[0]->data; - FX_VB_COLOR(fxMesa, color[pv]); + GOURAUD2(v1,color[pv]); + GOURAUD2(v2,color[pv]); + GOURAUD2(v3,color[pv]); } if (IND & FX_FRONT_BACK) { @@ -168,7 +172,10 @@ static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, GLuint facing = (c<0.0) ^ ctx->Polygon.FrontBit; GLubyte (*color)[4] = VB->Color[facing]->data; if (IND & FX_FLAT) { - FX_VB_COLOR(fxMesa, color[pv]); + GOURAUD2(v1,color[pv]); + GOURAUD2(v2,color[pv]); + GOURAUD2(v3,color[pv]); + GOURAUD2(v4,color[pv]); } else { GOURAUD2(v1,color[e1]); GOURAUD2(v2,color[e2]); @@ -206,7 +213,10 @@ static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, } else if (IND & FX_FLAT) { GLubyte (*color)[4] = VB->Color[0]->data; - FX_VB_COLOR(fxMesa, color[pv]); + GOURAUD2(v1,color[pv]); + GOURAUD2(v2,color[pv]); + GOURAUD2(v3,color[pv]); + GOURAUD2(v4,color[pv]); } if (IND & FX_FRONT_BACK) { @@ -249,9 +259,10 @@ static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, } } -#define DRAW_LINE(tmp0, tmp1, width) \ - do { \ - GrVertex verts[4]; \ +#define DRAW_LINE(tmp0, tmp1, width) \ + do { \ + const float xoff = 0.125, yoff = 0.125; \ + GrVertex verts[4]; \ float dx, dy, wx, wy; \ \ dx = tmp0->x - tmp1->x; \ @@ -270,17 +281,17 @@ static void TAG(fx_quad)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint e3, verts[2] = *tmp1; \ verts[3] = *tmp1; \ \ - verts[0].x = tmp0->x - wx; \ - verts[0].y = tmp0->y - wy; \ + verts[0].x = tmp0->x - wx + xoff; \ + verts[0].y = tmp0->y - wy + yoff; \ \ - verts[1].x = tmp0->x + wx; \ - verts[1].y = tmp0->y + wy; \ + verts[1].x = tmp0->x + wx + xoff; \ + verts[1].y = tmp0->y + wy + yoff; \ \ - verts[2].x = tmp1->x + wx; \ - verts[2].y = tmp1->y + wy; \ + verts[2].x = tmp1->x + wx + xoff; \ + verts[2].y = tmp1->y + wy + yoff; \ \ - verts[3].x = tmp1->x - wx; \ - verts[3].y = tmp1->y - wy; \ + verts[3].x = tmp1->x - wx + xoff; \ + verts[3].y = tmp1->y - wy + yoff; \ \ FX_grDrawPolygonVertexList(4, verts); \ } while (0) @@ -291,28 +302,20 @@ static void TAG(fx_line)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint pv) fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx; struct vertex_buffer *VB=ctx->VB; fxVertex *gWin = FX_DRIVER_DATA(VB)->verts; - GLubyte (* const color)[4] = VB->Color[0]->data; + GLubyte (* const color)[4] = VB->ColorPtr->data; GrVertex *v1 = (GrVertex *)gWin[e1].f; GrVertex *v2 = (GrVertex *)gWin[e2].f; GLfloat w = ctx->Line.Width*.5; - if (IND & FX_FLAT) - { - FX_VB_COLOR(fxMesa, color[pv]); - if (IND & FX_ANTIALIAS) -#if FX_USE_PARGB - { - GLuint v1argb = v1->argb; - GLuint v2argb = v2->argb; - v1->argb = (color[pv][ACOMP] << 24) | (v1argb & 0x00FFFFFF); - v2->argb = (color[pv][ACOMP] << 24) | (v2argb & 0x00FFFFFF); - } -#else - v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]); -#endif + if (IND & FX_FLAT) { + v1->r = v2->r = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][0]); + v1->g = v2->g = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][1]); + v1->b = v2->b = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][2]); + v1->a = v2->a = UBYTE_COLOR_TO_FLOAT_255_COLOR(color[pv][3]); } else if (IND & FX_TWOSIDE) { + /* XXX use signed area of the polygon to determine front/back color choice */ GOURAUD2(v1,color[e1]); GOURAUD2(v2,color[e2]); } @@ -331,8 +334,7 @@ static void TAG(fx_line)(GLcontext *ctx, GLuint e1, GLuint e2, GLuint pv) else DRAW_LINE(v1,v2,w); - if (IND & FX_FRONT_BACK) - { + if (IND & FX_FRONT_BACK) { FX_grColorMask(ctx->Color.ColorMask[RCOMP] || ctx->Color.ColorMask[GCOMP] || ctx->Color.ColorMask[BCOMP], diff --git a/xc/extras/Mesa/src/OSmesa/osmesa.c b/xc/extras/Mesa/src/OSmesa/osmesa.c new file mode 100644 index 000000000..62b18f9e6 --- /dev/null +++ b/xc/extras/Mesa/src/OSmesa/osmesa.c @@ -0,0 +1,1637 @@ + +/* + * Mesa 3-D graphics library + * Version: 3.3 + * + * Copyright (C) 1999-2000 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. + */ + + +/* + * Off-Screen Mesa rendering / Rendering into client memory space + * + * Note on thread safety: this driver is thread safe. All + * functions are reentrant. The notion of current context is + * managed by the core gl_make_current() and gl_get_current_context() + * functions. Those functions are thread-safe. + */ + + +#ifdef PC_HEADER +#include "all.h" +#else +#include "glheader.h" +#include "GL/osmesa.h" +#include "context.h" +#include "depth.h" +#include "mem.h" +#include "matrix.h" +#include "types.h" +#include "vb.h" +#include "extensions.h" +#endif + + +/* + * This is the OS/Mesa context struct. + * Notice how it includes a GLcontext. By doing this we're mimicking + * C++ inheritance/derivation. + * Later, we can cast a GLcontext pointer into an OSMesaContext pointer + * or vice versa. + */ +struct osmesa_context { + GLcontext gl_ctx; /* The core GL/Mesa context */ + GLvisual *gl_visual; /* Describes the buffers */ + GLframebuffer *gl_buffer; /* Depth, stencil, accum, etc buffers */ + GLenum format; /* either GL_RGBA or GL_COLOR_INDEX */ + void *buffer; /* the image buffer */ + GLint width, height; /* size of image buffer */ + GLuint pixel; /* current color index or RGBA pixel value */ + GLuint clearpixel; /* pixel for clearing the color buffer */ + GLint rowlength; /* number of pixels per row */ + GLint userRowLength; /* user-specified number of pixels per row */ + GLint rshift, gshift; /* bit shifts for RGBA formats */ + GLint bshift, ashift; + GLint rind, gind, bind; /* index offsets for RGBA formats */ + void *rowaddr[MAX_HEIGHT]; /* address of first pixel in each image row */ + GLboolean yup; /* TRUE -> Y increases upward */ + /* FALSE -> Y increases downward */ +}; + + + +/* A forward declaration: */ +static void osmesa_update_state( GLcontext *ctx ); + + + +/**********************************************************************/ +/***** Public Functions *****/ +/**********************************************************************/ + + +/* + * Create an Off-Screen Mesa rendering context. The only attribute needed is + * an RGBA vs Color-Index mode flag. + * + * Input: format - either GL_RGBA or GL_COLOR_INDEX + * sharelist - specifies another OSMesaContext with which to share + * display lists. NULL indicates no sharing. + * Return: an OSMesaContext or 0 if error + */ +OSMesaContext GLAPIENTRY +OSMesaCreateContext( GLenum format, OSMesaContext sharelist ) +{ + OSMesaContext osmesa; + GLint rshift, gshift, bshift, ashift; + GLint rind, gind, bind; + GLint indexBits, alphaBits; + GLboolean rgbmode; + GLboolean swalpha; + GLuint i4 = 1; + GLubyte *i1 = (GLubyte *) &i4; + GLint little_endian = *i1; + + swalpha = GL_FALSE; + rind = gind = bind = 0; + if (format==OSMESA_COLOR_INDEX) { + indexBits = 8; + rshift = gshift = bshift = ashift = 0; + rgbmode = GL_FALSE; + } + else if (format==OSMESA_RGBA) { + indexBits = 0; + alphaBits = 8; + if (little_endian) { + rshift = 0; + gshift = 8; + bshift = 16; + ashift = 24; + } + else { + rshift = 24; + gshift = 16; + bshift = 8; + ashift = 0; + } + rgbmode = GL_TRUE; + } + else if (format==OSMESA_BGRA) { + indexBits = 0; + alphaBits = 8; + if (little_endian) { + ashift = 0; + rshift = 8; + gshift = 16; + bshift = 24; + } + else { + bshift = 24; + gshift = 16; + rshift = 8; + ashift = 0; + } + rgbmode = GL_TRUE; + } + else if (format==OSMESA_ARGB) { + indexBits = 0; + alphaBits = 8; + if (little_endian) { + bshift = 0; + gshift = 8; + rshift = 16; + ashift = 24; + } + else { + ashift = 24; + rshift = 16; + gshift = 8; + bshift = 0; + } + rgbmode = GL_TRUE; + } + else if (format==OSMESA_RGB) { + indexBits = 0; + alphaBits = 0; + bshift = 0; + gshift = 8; + rshift = 16; + ashift = 24; + bind = 2; + gind = 1; + rind = 0; + rgbmode = GL_TRUE; + swalpha = GL_TRUE; + } + else if (format==OSMESA_BGR) { + indexBits = 0; + alphaBits = 0; + bshift = 0; + gshift = 8; + rshift = 16; + ashift = 24; + bind = 0; + gind = 1; + rind = 2; + rgbmode = GL_TRUE; + swalpha = GL_TRUE; + } + else { + return NULL; + } + + + osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context); + if (osmesa) { + osmesa->gl_visual = gl_create_visual( rgbmode, + swalpha, /* software alpha */ + GL_FALSE, /* double buffer */ + GL_FALSE, /* stereo */ + DEFAULT_SOFTWARE_DEPTH_BITS, + STENCIL_BITS, + rgbmode ? ACCUM_BITS : 0, + indexBits, + 8, 8, 8, alphaBits ); + if (!osmesa->gl_visual) { + FREE(osmesa); + return NULL; + } + + if (!_mesa_initialize_context(&osmesa->gl_ctx, + osmesa->gl_visual, + sharelist ? &sharelist->gl_ctx + : (GLcontext *) NULL, + (void *) osmesa, GL_TRUE )) { + _mesa_destroy_visual( osmesa->gl_visual ); + FREE(osmesa); + return NULL; + } + gl_extensions_enable(&(osmesa->gl_ctx),"GL_HP_occlusion_test"); + gl_extensions_enable(&(osmesa->gl_ctx), "GL_ARB_texture_cube_map"); + + osmesa->gl_buffer = gl_create_framebuffer( osmesa->gl_visual, + osmesa->gl_visual->DepthBits > 0, + osmesa->gl_visual->StencilBits > 0, + osmesa->gl_visual->AccumRedBits > 0, + osmesa->gl_visual->AlphaBits > 0 ); + + if (!osmesa->gl_buffer) { + gl_destroy_visual( osmesa->gl_visual ); + gl_free_context_data( &osmesa->gl_ctx ); + FREE(osmesa); + return NULL; + } + osmesa->format = format; + osmesa->buffer = NULL; + osmesa->width = 0; + osmesa->height = 0; + osmesa->pixel = 0; + osmesa->clearpixel = 0; + osmesa->userRowLength = 0; + osmesa->rowlength = 0; + osmesa->yup = GL_TRUE; + osmesa->rshift = rshift; + osmesa->gshift = gshift; + osmesa->bshift = bshift; + osmesa->ashift = ashift; + osmesa->rind = rind; + osmesa->gind = gind; + osmesa->bind = bind; + } + return osmesa; +} + + + +/* + * Destroy an Off-Screen Mesa rendering context. + * + * Input: ctx - the context to destroy + */ +void GLAPIENTRY OSMesaDestroyContext( OSMesaContext ctx ) +{ + if (ctx) { + gl_destroy_visual( ctx->gl_visual ); + gl_destroy_framebuffer( ctx->gl_buffer ); + gl_free_context_data( &ctx->gl_ctx ); + FREE( ctx ); + } +} + + + +/* + * Recompute the values of the context's rowaddr array. + */ +static void compute_row_addresses( OSMesaContext ctx ) +{ + GLint i; + + if (ctx->yup) { + /* Y=0 is bottom line of window */ + if (ctx->format==OSMESA_COLOR_INDEX) { + /* 1-byte CI mode */ + GLubyte *origin = (GLubyte *) ctx->buffer; + for (i=0;i<MAX_HEIGHT;i++) { + ctx->rowaddr[i] = origin + i * ctx->rowlength; + } + } + else { + if ((ctx->format==OSMESA_RGB) || (ctx->format==OSMESA_BGR)) { + /* 3-byte RGB mode */ + GLubyte *origin = (GLubyte *) ctx->buffer; + for (i=0;i<MAX_HEIGHT;i++) { + ctx->rowaddr[i] = origin + (i * (ctx->rowlength*3)); + } + } else { + /* 4-byte RGBA mode */ + GLuint *origin = (GLuint *) ctx->buffer; + for (i=0;i<MAX_HEIGHT;i++) { + ctx->rowaddr[i] = origin + i * ctx->rowlength; + } + } + } + } + else { + /* Y=0 is top line of window */ + if (ctx->format==OSMESA_COLOR_INDEX) { + /* 1-byte CI mode */ + GLubyte *origin = (GLubyte *) ctx->buffer; + for (i=0;i<MAX_HEIGHT;i++) { + ctx->rowaddr[i] = origin + (ctx->height-i-1) * ctx->rowlength; + } + } + else { + if ((ctx->format==OSMESA_RGB) || (ctx->format==OSMESA_BGR)) { + /* 3-byte RGB mode */ + GLubyte *origin = (GLubyte *) ctx->buffer; + for (i=0;i<MAX_HEIGHT;i++) { + ctx->rowaddr[i] = origin + ((ctx->height-i-1) * (ctx->rowlength*3)); + } + } else { + /* 4-byte RGBA mode */ + GLuint *origin = (GLuint *) ctx->buffer; + for (i=0;i<MAX_HEIGHT;i++) { + ctx->rowaddr[i] = origin + (ctx->height-i-1) * ctx->rowlength; + } + } + } + } +} + + +/* + * Bind an OSMesaContext to an image buffer. The image buffer is just a + * block of memory which the client provides. Its size must be at least + * as large as width*height*sizeof(type). Its address should be a multiple + * of 4 if using RGBA mode. + * + * Image data is stored in the order of glDrawPixels: row-major order + * with the lower-left image pixel stored in the first array position + * (ie. bottom-to-top). + * + * Since the only type initially supported is GL_UNSIGNED_BYTE, if the + * context is in RGBA mode, each pixel will be stored as a 4-byte RGBA + * value. If the context is in color indexed mode, each pixel will be + * stored as a 1-byte value. + * + * If the context's viewport hasn't been initialized yet, it will now be + * initialized to (0,0,width,height). + * + * Input: ctx - the rendering context + * buffer - the image buffer memory + * type - data type for pixel components, only GL_UNSIGNED_BYTE + * supported now + * width, height - size of image buffer in pixels, at least 1 + * Return: GL_TRUE if success, GL_FALSE if error because of invalid ctx, + * invalid buffer address, type!=GL_UNSIGNED_BYTE, width<1, height<1, + * width>internal limit or height>internal limit. + */ +GLboolean GLAPIENTRY +OSMesaMakeCurrent( OSMesaContext ctx, void *buffer, GLenum type, + GLsizei width, GLsizei height ) +{ + if (!ctx || !buffer || type!=GL_UNSIGNED_BYTE + || width<1 || height<1 || width>MAX_WIDTH || height>MAX_HEIGHT) { + return GL_FALSE; + } + + osmesa_update_state( &ctx->gl_ctx ); + gl_make_current( &ctx->gl_ctx, ctx->gl_buffer ); + + ctx->buffer = buffer; + ctx->width = width; + ctx->height = height; + if (ctx->userRowLength) + ctx->rowlength = ctx->userRowLength; + else + ctx->rowlength = width; + + compute_row_addresses( ctx ); + + /* init viewport */ + if (ctx->gl_ctx.Viewport.Width==0) { + /* initialize viewport and scissor box to buffer size */ + _mesa_Viewport( 0, 0, width, height ); + ctx->gl_ctx.Scissor.Width = width; + ctx->gl_ctx.Scissor.Height = height; + } + + return GL_TRUE; +} + + + +OSMesaContext GLAPIENTRY OSMesaGetCurrentContext( void ) +{ + GLcontext *ctx = gl_get_current_context(); + if (ctx) + return (OSMesaContext) ctx; + else + return NULL; +} + + + +void GLAPIENTRY OSMesaPixelStore( GLint pname, GLint value ) +{ + OSMesaContext ctx = OSMesaGetCurrentContext(); + + switch (pname) { + case OSMESA_ROW_LENGTH: + if (value<0) { + gl_error( &ctx->gl_ctx, GL_INVALID_VALUE, + "OSMesaPixelStore(value)" ); + return; + } + ctx->userRowLength = value; + ctx->rowlength = value; + break; + case OSMESA_Y_UP: + ctx->yup = value ? GL_TRUE : GL_FALSE; + break; + default: + gl_error( &ctx->gl_ctx, GL_INVALID_ENUM, "OSMesaPixelStore(pname)" ); + return; + } + + compute_row_addresses( ctx ); +} + + +void GLAPIENTRY OSMesaGetIntegerv( GLint pname, GLint *value ) +{ + OSMesaContext ctx = OSMesaGetCurrentContext(); + + switch (pname) { + case OSMESA_WIDTH: + *value = ctx->width; + return; + case OSMESA_HEIGHT: + *value = ctx->height; + return; + case OSMESA_FORMAT: + *value = ctx->format; + return; + case OSMESA_TYPE: + *value = GL_UNSIGNED_BYTE; + return; + case OSMESA_ROW_LENGTH: + *value = ctx->rowlength; + return; + case OSMESA_Y_UP: + *value = ctx->yup; + return; + default: + gl_error(&ctx->gl_ctx, GL_INVALID_ENUM, "OSMesaGetIntergerv(pname)"); + return; + } +} + +/* + * Return the depth buffer associated with an OSMesa context. + * Input: c - the OSMesa context + * Output: width, height - size of buffer in pixels + * bytesPerValue - bytes per depth value (2 or 4) + * buffer - pointer to depth buffer values + * Return: GL_TRUE or GL_FALSE to indicate success or failure. + */ +GLboolean GLAPIENTRY +OSMesaGetDepthBuffer( OSMesaContext c, GLint *width, GLint *height, + GLint *bytesPerValue, void **buffer ) +{ + if ((!c->gl_buffer) || (!c->gl_buffer->DepthBuffer)) { + *width = 0; + *height = 0; + *bytesPerValue = 0; + *buffer = 0; + return GL_FALSE; + } + else { + *width = c->gl_buffer->Width; + *height = c->gl_buffer->Height; + *bytesPerValue = sizeof(GLdepth); + *buffer = c->gl_buffer->DepthBuffer; + return GL_TRUE; + } +} + +/* + * Return the color buffer associated with an OSMesa context. + * Input: c - the OSMesa context + * Output: width, height - size of buffer in pixels + * format - the pixel format (OSMESA_FORMAT) + * buffer - pointer to color buffer values + * Return: GL_TRUE or GL_FALSE to indicate success or failure. + */ +GLboolean GLAPIENTRY +OSMesaGetColorBuffer( OSMesaContext c, GLint *width, + GLint *height, GLint *format, void **buffer ) +{ + if (!c->buffer) { + *width = 0; + *height = 0; + *format = 0; + *buffer = 0; + return GL_FALSE; + } + else { + *width = c->width; + *height = c->height; + *format = c->format; + *buffer = c->buffer; + return GL_TRUE; + } +} + +/**********************************************************************/ +/*** Device Driver Functions ***/ +/**********************************************************************/ + + +/* + * Useful macros: + */ +#define PACK_RGBA(R,G,B,A) ( ((R) << osmesa->rshift) \ + | ((G) << osmesa->gshift) \ + | ((B) << osmesa->bshift) \ + | ((A) << osmesa->ashift) ) + +#define PACK_RGBA2(R,G,B,A) ( ((R) << rshift) \ + | ((G) << gshift) \ + | ((B) << bshift) \ + | ((A) << ashift) ) + +#define UNPACK_RED(P) (((P) >> osmesa->rshift) & 0xff) +#define UNPACK_GREEN(P) (((P) >> osmesa->gshift) & 0xff) +#define UNPACK_BLUE(P) (((P) >> osmesa->bshift) & 0xff) +#define UNPACK_ALPHA(P) (((P) >> osmesa->ashift) & 0xff) + +#define PIXELADDR1(X,Y) ((GLubyte *) osmesa->rowaddr[Y] + (X)) +#define PIXELADDR3(X,Y) ((GLubyte *) osmesa->rowaddr[Y] + ((X)*3)) +#define PIXELADDR4(X,Y) ((GLuint *) osmesa->rowaddr[Y] + (X)) + + + + +static GLboolean set_draw_buffer( GLcontext *ctx, GLenum mode ) +{ + (void) ctx; + if (mode==GL_FRONT_LEFT) { + return GL_TRUE; + } + else { + return GL_FALSE; + } +} + + +static void set_read_buffer( GLcontext *ctx, GLframebuffer *buffer, GLenum mode ) +{ + /* separate read buffer not supported */ + ASSERT(buffer == ctx->DrawBuffer); + ASSERT(mode == GL_FRONT_LEFT); +} + + +static void clear_index( GLcontext *ctx, GLuint index ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + osmesa->clearpixel = index; +} + + + +static void clear_color( GLcontext *ctx, + GLubyte r, GLubyte g, GLubyte b, GLubyte a ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + osmesa->clearpixel = PACK_RGBA( r, g, b, a ); +} + + + +static GLbitfield clear( GLcontext *ctx, GLbitfield mask, GLboolean all, + GLint x, GLint y, GLint width, GLint height ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + const GLuint *colorMask = (GLuint *) &ctx->Color.ColorMask; + + /* we can't handle color or index masking */ + if (*colorMask != 0xffffffff || ctx->Color.IndexMask != 0xffffffff) + return mask; + + /* sanity check - we only have a front-left buffer */ + ASSERT((mask & (DD_FRONT_RIGHT_BIT | DD_BACK_LEFT_BIT | DD_BACK_RIGHT_BIT)) == 0); + + if (mask & DD_FRONT_LEFT_BIT) { + if (osmesa->format==OSMESA_COLOR_INDEX) { + if (all) { + /* Clear whole CI buffer */ + MEMSET(osmesa->buffer, osmesa->clearpixel, + osmesa->rowlength * osmesa->height); + } + else { + /* Clear part of CI buffer */ + GLint i, j; + for (i=0;i<height;i++) { + GLubyte *ptr1 = PIXELADDR1( x, (y+i) ); + for (j=0;j<width;j++) { + *ptr1++ = osmesa->clearpixel; + } + } + } + } + else if ((osmesa->format==OSMESA_RGB)||(osmesa->format==OSMESA_BGR)) { + GLubyte rval = UNPACK_RED(osmesa->clearpixel); + GLubyte gval = UNPACK_GREEN(osmesa->clearpixel); + GLubyte bval = UNPACK_BLUE(osmesa->clearpixel); + GLint rind = osmesa->rind; + GLint gind = osmesa->gind; + GLint bind = osmesa->bind; + if (all) { + GLuint i, n; + GLubyte *ptr3 = (GLubyte *) osmesa->buffer; + /* Clear whole RGB buffer */ + n = osmesa->rowlength * osmesa->height; + for (i=0;i<n;i++) { + ptr3[rind] = rval; + ptr3[gind] = gval; + ptr3[bind] = bval; + ptr3 += 3; + } + } + else { + /* Clear part of RGB buffer */ + GLint i, j; + for (i=0;i<height;i++) { + GLubyte *ptr3 = PIXELADDR3( x, (y+i) ); + for (j=0;j<width;j++) { + ptr3[rind] = rval; + ptr3[gind] = gval; + ptr3[bind] = bval; + ptr3 += 3; + } + } + } + } + else { + if (all) { + /* Clear whole RGBA buffer */ + GLuint i, n, *ptr4; + n = osmesa->rowlength * osmesa->height; + ptr4 = (GLuint *) osmesa->buffer; + if (osmesa->clearpixel) { + for (i=0;i<n;i++) { + *ptr4++ = osmesa->clearpixel; + } + } + else { + BZERO(ptr4, n * sizeof(GLuint)); + } + } + else { + /* Clear part of RGBA buffer */ + GLint i, j; + for (i=0;i<height;i++) { + GLuint *ptr4 = PIXELADDR4( x, (y+i) ); + for (j=0;j<width;j++) { + *ptr4++ = osmesa->clearpixel; + } + } + } + } + } + /* have Mesa clear all other buffers */ + return mask & (~DD_FRONT_LEFT_BIT); +} + + + +static void set_index( GLcontext *ctx, GLuint index ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + osmesa->pixel = index; +} + + + +static void set_color( GLcontext *ctx, + GLubyte r, GLubyte g, GLubyte b, GLubyte a ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + osmesa->pixel = PACK_RGBA( r, g, b, a ); +} + + + +static void buffer_size( GLcontext *ctx, GLuint *width, GLuint *height ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + *width = osmesa->width; + *height = osmesa->height; +} + + +/**********************************************************************/ +/***** Read/write spans/arrays of RGBA pixels *****/ +/**********************************************************************/ + +/* Write RGBA pixels to an RGBA (or permuted) buffer. */ +static void write_rgba_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + CONST GLubyte rgba[][4], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint *ptr4 = PIXELADDR4( x, y ); + GLuint i; + GLint rshift = osmesa->rshift; + GLint gshift = osmesa->gshift; + GLint bshift = osmesa->bshift; + GLint ashift = osmesa->ashift; + if (mask) { + for (i=0;i<n;i++,ptr4++) { + if (mask[i]) { + *ptr4 = PACK_RGBA2( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ); + } + } + } + else { + for (i=0;i<n;i++,ptr4++) { + *ptr4 = PACK_RGBA2( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ); + } + } +} + + +/* Write RGBA pixels to an RGBA buffer. This is the fastest span-writer. */ +static void write_rgba_span_rgba( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + CONST GLubyte rgba[][4], + const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint *ptr4 = PIXELADDR4( x, y ); + const GLuint *rgba4 = (const GLuint *) rgba; + GLuint i; + if (mask) { + for (i=0;i<n;i++) { + if (mask[i]) { + ptr4[i] = rgba4[i]; + } + } + } + else { + MEMCPY( ptr4, rgba4, n * 4 ); + } +} + + +/* Write RGB pixels to an RGBA (or permuted) buffer. */ +static void write_rgb_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + CONST GLubyte rgb[][3], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint *ptr4 = PIXELADDR4( x, y ); + GLuint i; + GLint rshift = osmesa->rshift; + GLint gshift = osmesa->gshift; + GLint bshift = osmesa->bshift; + GLint ashift = osmesa->ashift; + if (mask) { + for (i=0;i<n;i++,ptr4++) { + if (mask[i]) { + *ptr4 = PACK_RGBA2( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255 ); + } + } + } + else { + for (i=0;i<n;i++,ptr4++) { + *ptr4 = PACK_RGBA2( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP], 255); + } + } +} + + + +static void write_monocolor_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint *ptr4 = PIXELADDR4(x,y); + GLuint i; + for (i=0;i<n;i++,ptr4++) { + if (mask[i]) { + *ptr4 = osmesa->pixel; + } + } +} + + + +static void write_rgba_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + GLint rshift = osmesa->rshift; + GLint gshift = osmesa->gshift; + GLint bshift = osmesa->bshift; + GLint ashift = osmesa->ashift; + for (i=0;i<n;i++) { + if (mask[i]) { + GLuint *ptr4 = PIXELADDR4(x[i],y[i]); + *ptr4 = PACK_RGBA2( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP], rgba[i][ACOMP] ); + } + } +} + + + +static void write_monocolor_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + GLuint *ptr4 = PIXELADDR4(x[i],y[i]); + *ptr4 = osmesa->pixel; + } + } +} + + +static void read_rgba_span( const GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte rgba[][4] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + GLuint *ptr4 = PIXELADDR4(x,y); + for (i=0;i<n;i++) { + GLuint pixel = *ptr4++; + rgba[i][RCOMP] = UNPACK_RED(pixel); + rgba[i][GCOMP] = UNPACK_GREEN(pixel); + rgba[i][BCOMP] = UNPACK_BLUE(pixel); + rgba[i][ACOMP] = UNPACK_ALPHA(pixel); + } +} + + +/* Read RGBA pixels from an RGBA buffer */ +static void read_rgba_span_rgba( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint *ptr4 = PIXELADDR4(x,y); + MEMCPY( rgba, ptr4, n * 4 * sizeof(GLubyte) ); +} + + +static void read_rgba_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + GLuint *ptr4 = PIXELADDR4(x[i],y[i]); + GLuint pixel = *ptr4; + rgba[i][RCOMP] = UNPACK_RED(pixel); + rgba[i][GCOMP] = UNPACK_GREEN(pixel); + rgba[i][BCOMP] = UNPACK_BLUE(pixel); + rgba[i][ACOMP] = UNPACK_ALPHA(pixel); + } + } +} + +/**********************************************************************/ +/***** 3 byte RGB pixel support funcs *****/ +/**********************************************************************/ + +/* Write RGBA pixels to an RGB or BGR buffer. */ +static void write_rgba_span3( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + CONST GLubyte rgba[][4], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLubyte *ptr3 = PIXELADDR3( x, y); + GLuint i; + GLint rind = osmesa->rind; + GLint gind = osmesa->gind; + GLint bind = osmesa->bind; + if (mask) { + for (i=0;i<n;i++,ptr3+=3) { + if (mask[i]) { + ptr3[rind] = rgba[i][RCOMP]; + ptr3[gind] = rgba[i][GCOMP]; + ptr3[bind] = rgba[i][BCOMP]; + } + } + } + else { + for (i=0;i<n;i++,ptr3+=3) { + ptr3[rind] = rgba[i][RCOMP]; + ptr3[gind] = rgba[i][GCOMP]; + ptr3[bind] = rgba[i][BCOMP]; + } + } +} + +/* Write RGB pixels to an RGB or BGR buffer. */ +static void write_rgb_span3( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + CONST GLubyte rgb[][3], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLubyte *ptr3 = PIXELADDR3( x, y); + GLuint i; + GLint rind = osmesa->rind; + GLint gind = osmesa->gind; + GLint bind = osmesa->bind; + if (mask) { + for (i=0;i<n;i++,ptr3+=3) { + if (mask[i]) { + ptr3[rind] = rgb[i][RCOMP]; + ptr3[gind] = rgb[i][GCOMP]; + ptr3[bind] = rgb[i][BCOMP]; + } + } + } + else { + for (i=0;i<n;i++,ptr3+=3) { + ptr3[rind] = rgb[i][RCOMP]; + ptr3[gind] = rgb[i][GCOMP]; + ptr3[bind] = rgb[i][BCOMP]; + } + } +} + + +static void write_monocolor_span3( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + + GLubyte rval = UNPACK_RED(osmesa->pixel); + GLubyte gval = UNPACK_GREEN(osmesa->pixel); + GLubyte bval = UNPACK_BLUE(osmesa->pixel); + GLint rind = osmesa->rind; + GLint gind = osmesa->gind; + GLint bind = osmesa->bind; + GLubyte *ptr3 = PIXELADDR3( x, y); + GLuint i; + for (i=0;i<n;i++,ptr3+=3) { + if (mask[i]) { + ptr3[rind] = rval; + ptr3[gind] = gval; + ptr3[bind] = bval; + } + } +} + +static void write_rgba_pixels3( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + GLint rind = osmesa->rind; + GLint gind = osmesa->gind; + GLint bind = osmesa->bind; + for (i=0;i<n;i++) { + if (mask[i]) { + GLubyte *ptr3 = PIXELADDR3(x[i],y[i]); + ptr3[rind] = rgba[i][RCOMP]; + ptr3[gind] = rgba[i][GCOMP]; + ptr3[bind] = rgba[i][BCOMP]; + } + } +} + +static void write_monocolor_pixels3( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + GLint rind = osmesa->rind; + GLint gind = osmesa->gind; + GLint bind = osmesa->bind; + GLubyte rval = UNPACK_RED(osmesa->pixel); + GLubyte gval = UNPACK_GREEN(osmesa->pixel); + GLubyte bval = UNPACK_BLUE(osmesa->pixel); + for (i=0;i<n;i++) { + if (mask[i]) { + GLubyte *ptr3 = PIXELADDR3(x[i],y[i]); + ptr3[rind] = rval; + ptr3[gind] = gval; + ptr3[bind] = bval; + } + } +} + +static void read_rgba_span3( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + GLint rind = osmesa->rind; + GLint gind = osmesa->gind; + GLint bind = osmesa->bind; + const GLubyte *ptr3 = PIXELADDR3( x, y); + for (i=0;i<n;i++,ptr3+=3) { + rgba[i][RCOMP] = ptr3[rind]; + rgba[i][GCOMP] = ptr3[gind]; + rgba[i][BCOMP] = ptr3[bind]; + rgba[i][ACOMP] = 0; + } +} + +static void read_rgba_pixels3( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + GLint rind = osmesa->rind; + GLint gind = osmesa->gind; + GLint bind = osmesa->bind; + for (i=0;i<n;i++) { + if (mask[i]) { + const GLubyte *ptr3 = PIXELADDR3(x[i],y[i]); + rgba[i][RCOMP] = ptr3[rind]; + rgba[i][GCOMP] = ptr3[gind]; + rgba[i][BCOMP] = ptr3[bind]; + rgba[i][ACOMP] = 0; + } + } +} + + +/**********************************************************************/ +/***** Read/write spans/arrays of CI pixels *****/ +/**********************************************************************/ + +/* Write 32-bit color index to buffer */ +static void write_index32_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLuint index[], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLubyte *ptr1 = PIXELADDR1(x,y); + GLuint i; + if (mask) { + for (i=0;i<n;i++,ptr1++) { + if (mask[i]) { + *ptr1 = (GLubyte) index[i]; + } + } + } + else { + for (i=0;i<n;i++,ptr1++) { + *ptr1 = (GLubyte) index[i]; + } + } +} + + +/* Write 8-bit color index to buffer */ +static void write_index8_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte index[], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLubyte *ptr1 = PIXELADDR1(x,y); + GLuint i; + if (mask) { + for (i=0;i<n;i++,ptr1++) { + if (mask[i]) { + *ptr1 = (GLubyte) index[i]; + } + } + } + else { + MEMCPY( ptr1, index, n ); + } +} + + +static void write_monoindex_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLubyte *ptr1 = PIXELADDR1(x,y); + GLuint i; + for (i=0;i<n;i++,ptr1++) { + if (mask[i]) { + *ptr1 = (GLubyte) osmesa->pixel; + } + } +} + + +static void write_index_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLuint index[], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + GLubyte *ptr1 = PIXELADDR1(x[i],y[i]); + *ptr1 = (GLubyte) index[i]; + } + } +} + + +static void write_monoindex_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + for (i=0;i<n;i++) { + if (mask[i]) { + GLubyte *ptr1 = PIXELADDR1(x[i],y[i]); + *ptr1 = (GLubyte) osmesa->pixel; + } + } +} + + +static void read_index_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint index[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + const GLubyte *ptr1 = PIXELADDR1(x,y); + for (i=0;i<n;i++,ptr1++) { + index[i] = (GLuint) *ptr1; + } +} + + +static void read_index_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint index[], const GLubyte mask[] ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLuint i; + for (i=0;i<n;i++) { + if (mask[i] ) { + const GLubyte *ptr1 = PIXELADDR1(x[i],y[i]); + index[i] = (GLuint) *ptr1; + } + } +} + + + +/**********************************************************************/ +/***** Optimized line rendering *****/ +/**********************************************************************/ + + +/* + * Draw a flat-shaded, RGB line into an osmesa buffer. + */ +static void flat_rgba_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLubyte *color = ctx->VB->ColorPtr->data[pvert]; + unsigned long pixel = PACK_RGBA( color[0], color[1], color[2], color[3] ); + +#define INTERP_XY 1 +#define CLIP_HACK 1 +#define PLOT(X,Y) { GLuint *ptr4 = PIXELADDR4(X,Y); *ptr4 = pixel; } + +#ifdef WIN32 +#include "..\linetemp.h" +#else +#include "linetemp.h" +#endif +} + + +/* + * Draw a flat-shaded, Z-less, RGB line into an osmesa buffer. + */ +static void flat_rgba_z_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLubyte *color = ctx->VB->ColorPtr->data[pvert]; + unsigned long pixel = PACK_RGBA( color[0], color[1], color[2], color[3] ); + +#define INTERP_XY 1 +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE +#define CLIP_HACK 1 +#define PLOT(X,Y) \ + if (Z < *zPtr) { \ + GLuint *ptr4 = PIXELADDR4(X,Y); \ + *ptr4 = pixel; \ + *zPtr = Z; \ + } + +#ifdef WIN32 +#include "..\linetemp.h" +#else +#include "linetemp.h" +#endif +} + + +/* + * Draw a flat-shaded, alpha-blended, RGB line into an osmesa buffer. + */ +static void flat_blend_rgba_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + struct vertex_buffer *VB = ctx->VB; + GLint rshift = osmesa->rshift; + GLint gshift = osmesa->gshift; + GLint bshift = osmesa->bshift; + GLint avalue = VB->ColorPtr->data[pvert][3]; + GLint msavalue = 255 - avalue; + GLint rvalue = VB->ColorPtr->data[pvert][0]*avalue; + GLint gvalue = VB->ColorPtr->data[pvert][1]*avalue; + GLint bvalue = VB->ColorPtr->data[pvert][2]*avalue; + +#define INTERP_XY 1 +#define CLIP_HACK 1 +#define PLOT(X,Y) \ + { GLuint *ptr4 = PIXELADDR4(X,Y); \ + GLuint pixel = 0; \ + pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift);\ + pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift);\ + pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift);\ + *ptr4 = pixel; \ + } + +#ifdef WIN32 +#include "..\linetemp.h" +#else +#include "linetemp.h" +#endif +} + + +/* + * Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. + */ +static void flat_blend_rgba_z_line( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + struct vertex_buffer *VB = ctx->VB; + GLint rshift = osmesa->rshift; + GLint gshift = osmesa->gshift; + GLint bshift = osmesa->bshift; + GLint avalue = VB->ColorPtr->data[pvert][3]; + GLint msavalue = 256 - avalue; + GLint rvalue = VB->ColorPtr->data[pvert][0]*avalue; + GLint gvalue = VB->ColorPtr->data[pvert][1]*avalue; + GLint bvalue = VB->ColorPtr->data[pvert][2]*avalue; + +#define INTERP_XY 1 +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE +#define CLIP_HACK 1 +#define PLOT(X,Y) \ + if (Z < *zPtr) { \ + GLuint *ptr4 = PIXELADDR4(X,Y); \ + GLuint pixel = 0; \ + pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift); \ + pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift); \ + pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift); \ + *ptr4 = pixel; \ + } + +#ifdef WIN32 +#include "..\linetemp.h" +#else +#include "linetemp.h" +#endif +} + + +/* + * Draw a flat-shaded, Z-less, alpha-blended, RGB line into an osmesa buffer. + */ +static void flat_blend_rgba_z_line_write( GLcontext *ctx, + GLuint vert0, GLuint vert1, GLuint pvert ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + struct vertex_buffer *VB = ctx->VB; + GLint rshift = osmesa->rshift; + GLint gshift = osmesa->gshift; + GLint bshift = osmesa->bshift; + GLint avalue = VB->ColorPtr->data[pvert][3]; + GLint msavalue = 256 - avalue; + GLint rvalue = VB->ColorPtr->data[pvert][0]*avalue; + GLint gvalue = VB->ColorPtr->data[pvert][1]*avalue; + GLint bvalue = VB->ColorPtr->data[pvert][2]*avalue; + +#define INTERP_XY 1 +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE +#define CLIP_HACK 1 +#define PLOT(X,Y) \ + if (Z < *zPtr) { \ + GLuint *ptr4 = PIXELADDR4(X,Y); \ + GLuint pixel = 0; \ + pixel |=((((((*ptr4) >> rshift) & 0xff)*msavalue+rvalue)>>8) << rshift); \ + pixel |=((((((*ptr4) >> gshift) & 0xff)*msavalue+gvalue)>>8) << gshift); \ + pixel |=((((((*ptr4) >> bshift) & 0xff)*msavalue+bvalue)>>8) << bshift); \ + *ptr4 = pixel; \ + *zPtr = Z; \ + } + +#ifdef WIN32 +#include "..\linetemp.h" +#else +#include "linetemp.h" +#endif +} + + +/* + * Analyze context state to see if we can provide a fast line drawing + * function, like those in lines.c. Otherwise, return NULL. + */ +static line_func choose_line_function( GLcontext *ctx ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + + if (ctx->Line.SmoothFlag) return NULL; + if (ctx->Texture.Enabled) return NULL; + if (ctx->Light.ShadeModel!=GL_FLAT) return NULL; + + if (ctx->Line.Width==1.0F + && ctx->Line.StippleFlag==GL_FALSE) { + + if (ctx->RasterMask==DEPTH_BIT + && ctx->Depth.Func==GL_LESS + && ctx->Depth.Mask==GL_TRUE + && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS) { + switch(osmesa->format) { + case OSMESA_RGBA: + case OSMESA_BGRA: + case OSMESA_ARGB: + return flat_rgba_z_line; + default: + return NULL; + } + } + + if (ctx->RasterMask==0) { + switch(osmesa->format) { + case OSMESA_RGBA: + case OSMESA_BGRA: + case OSMESA_ARGB: + return flat_rgba_line; + default: + return NULL; + } + } + + if (ctx->RasterMask==(DEPTH_BIT|BLEND_BIT) + && ctx->Depth.Func==GL_LESS + && ctx->Depth.Mask==GL_TRUE + && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS + && ctx->Color.BlendSrcRGB==GL_SRC_ALPHA + && ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA + && ctx->Color.BlendSrcA==GL_SRC_ALPHA + && ctx->Color.BlendDstA==GL_ONE_MINUS_SRC_ALPHA + && ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { + switch(osmesa->format) { + case OSMESA_RGBA: + case OSMESA_BGRA: + case OSMESA_ARGB: + return flat_blend_rgba_z_line_write; + default: + return NULL; + } + } + + if (ctx->RasterMask==(DEPTH_BIT|BLEND_BIT) + && ctx->Depth.Func==GL_LESS + && ctx->Depth.Mask==GL_FALSE + && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS + && ctx->Color.BlendSrcRGB==GL_SRC_ALPHA + && ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA + && ctx->Color.BlendSrcA==GL_SRC_ALPHA + && ctx->Color.BlendDstA==GL_ONE_MINUS_SRC_ALPHA + && ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { + switch(osmesa->format) { + case OSMESA_RGBA: + case OSMESA_BGRA: + case OSMESA_ARGB: + return flat_blend_rgba_z_line; + default: + return NULL; + } + } + + if (ctx->RasterMask==BLEND_BIT + && ctx->Color.BlendSrcRGB==GL_SRC_ALPHA + && ctx->Color.BlendDstRGB==GL_ONE_MINUS_SRC_ALPHA + && ctx->Color.BlendSrcA==GL_SRC_ALPHA + && ctx->Color.BlendDstA==GL_ONE_MINUS_SRC_ALPHA + && ctx->Color.BlendEquation==GL_FUNC_ADD_EXT) { + switch(osmesa->format) { + case OSMESA_RGBA: + case OSMESA_BGRA: + case OSMESA_ARGB: + return flat_blend_rgba_line; + default: + return NULL; + } + } + + } + return NULL; +} + + +/**********************************************************************/ +/***** Optimized triangle rendering *****/ +/**********************************************************************/ + + +/* + * Smooth-shaded, z-less triangle, RGBA color. + */ +static void smooth_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, + GLuint v2, GLuint pv ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + GLint rshift = osmesa->rshift; + GLint gshift = osmesa->gshift; + GLint bshift = osmesa->bshift; + GLint ashift = osmesa->ashift; + (void) pv; + +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE +#define INTERP_RGB 1 +#define INTERP_ALPHA 1 +#define INNER_LOOP( LEFT, RIGHT, Y ) \ +{ \ + GLint i, len = RIGHT-LEFT; \ + GLuint *img = PIXELADDR4(LEFT,Y); \ + for (i=0;i<len;i++,img++) { \ + GLdepth z = FixedToDepth(ffz); \ + if (z < zRow[i]) { \ + *img = PACK_RGBA2( FixedToInt(ffr), FixedToInt(ffg), \ + FixedToInt(ffb), FixedToInt(ffa) ); \ + zRow[i] = z; \ + } \ + ffr += fdrdx; ffg += fdgdx; ffb += fdbdx; ffa += fdadx;\ + ffz += fdzdx; \ + } \ +} +#ifdef WIN32 +#include "..\tritemp.h" +#else +#include "tritemp.h" +#endif +} + + + + +/* + * Flat-shaded, z-less triangle, RGBA color. + */ +static void flat_rgba_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, + GLuint v2, GLuint pv ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; +#define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE +#define SETUP_CODE \ + GLubyte r = VB->ColorPtr->data[pv][0]; \ + GLubyte g = VB->ColorPtr->data[pv][1]; \ + GLubyte b = VB->ColorPtr->data[pv][2]; \ + GLubyte a = VB->ColorPtr->data[pv][3]; \ + GLuint pixel = PACK_RGBA(r,g,b,a); + +#define INNER_LOOP( LEFT, RIGHT, Y ) \ +{ \ + GLint i, len = RIGHT-LEFT; \ + GLuint *img = PIXELADDR4(LEFT,Y); \ + for (i=0;i<len;i++,img++) { \ + GLdepth z = FixedToDepth(ffz); \ + if (z < zRow[i]) { \ + *img = pixel; \ + zRow[i] = z; \ + } \ + ffz += fdzdx; \ + } \ +} +#ifdef WIN32 +#include "..\tritemp.h" +#else +#include "tritemp.h" +#endif +} + + + +/* + * Return pointer to an accelerated triangle function if possible. + */ +static triangle_func choose_triangle_function( GLcontext *ctx ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + + if ((osmesa->format==OSMESA_RGB)||(osmesa->format==OSMESA_BGR)) return NULL; + + if (ctx->Polygon.SmoothFlag) return NULL; + if (ctx->Polygon.StippleFlag) return NULL; + if (ctx->Texture.Enabled) return NULL; + + if (ctx->RasterMask==DEPTH_BIT + && ctx->Depth.Func==GL_LESS + && ctx->Depth.Mask==GL_TRUE + && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS + && osmesa->format!=OSMESA_COLOR_INDEX) { + if (ctx->Light.ShadeModel==GL_SMOOTH) { + return smooth_rgba_z_triangle; + } + else { + return flat_rgba_z_triangle; + } + } + return NULL; +} + + + +static const GLubyte *get_string( GLcontext *ctx, GLenum name ) +{ + (void) ctx; + switch (name) { + case GL_RENDERER: + return (const GLubyte *) "Mesa OffScreen"; + default: + return NULL; + } +} + + +static void osmesa_update_state( GLcontext *ctx ) +{ + OSMesaContext osmesa = (OSMesaContext) ctx; + + ASSERT((void *) osmesa == (void *) ctx->DriverCtx); + + ctx->Driver.GetString = get_string; + ctx->Driver.UpdateState = osmesa_update_state; + + ctx->Driver.SetDrawBuffer = set_draw_buffer; + ctx->Driver.SetReadBuffer = set_read_buffer; + ctx->Driver.Color = set_color; + ctx->Driver.Index = set_index; + ctx->Driver.ClearIndex = clear_index; + ctx->Driver.ClearColor = clear_color; + ctx->Driver.Clear = clear; + + ctx->Driver.GetBufferSize = buffer_size; + + ctx->Driver.PointsFunc = NULL; + ctx->Driver.LineFunc = choose_line_function( ctx ); + ctx->Driver.TriangleFunc = choose_triangle_function( ctx ); + + + /* RGB(A) span/pixel functions */ + if ((osmesa->format==OSMESA_RGB) || (osmesa->format==OSMESA_BGR)) { + /* 3 bytes / pixel in frame buffer */ + ctx->Driver.WriteRGBASpan = write_rgba_span3; + ctx->Driver.WriteRGBSpan = write_rgb_span3; + ctx->Driver.WriteRGBAPixels = write_rgba_pixels3; + ctx->Driver.WriteMonoRGBASpan = write_monocolor_span3; + ctx->Driver.WriteMonoRGBAPixels = write_monocolor_pixels3; + ctx->Driver.ReadRGBASpan = read_rgba_span3; + ctx->Driver.ReadRGBAPixels = read_rgba_pixels3; + } + else { + /* 4 bytes / pixel in frame buffer */ + if (osmesa->format==OSMESA_RGBA + && RCOMP==0 && GCOMP==1 && BCOMP==2 && ACOMP==3) + ctx->Driver.WriteRGBASpan = write_rgba_span_rgba; + else + ctx->Driver.WriteRGBASpan = write_rgba_span; + ctx->Driver.WriteRGBSpan = write_rgb_span; + ctx->Driver.WriteRGBAPixels = write_rgba_pixels; + ctx->Driver.WriteMonoRGBASpan = write_monocolor_span; + ctx->Driver.WriteMonoRGBAPixels = write_monocolor_pixels; + if (osmesa->format==OSMESA_RGBA + && RCOMP==0 && GCOMP==1 && BCOMP==2 && ACOMP==3) + ctx->Driver.ReadRGBASpan = read_rgba_span_rgba; + else + ctx->Driver.ReadRGBASpan = read_rgba_span; + ctx->Driver.ReadRGBAPixels = read_rgba_pixels; + } + + /* CI span/pixel functions */ + ctx->Driver.WriteCI32Span = write_index32_span; + ctx->Driver.WriteCI8Span = write_index8_span; + ctx->Driver.WriteMonoCISpan = write_monoindex_span; + ctx->Driver.WriteCI32Pixels = write_index_pixels; + ctx->Driver.WriteMonoCIPixels = write_monoindex_pixels; + ctx->Driver.ReadCI32Span = read_index_span; + ctx->Driver.ReadCI32Pixels = read_index_pixels; +} diff --git a/xc/extras/Mesa/src/X/fakeglx.c b/xc/extras/Mesa/src/X/fakeglx.c index 16fb2f622..d613c0a83 100644 --- a/xc/extras/Mesa/src/X/fakeglx.c +++ b/xc/extras/Mesa/src/X/fakeglx.c @@ -47,7 +47,9 @@ #include "context.h" #include "config.h" #include "macros.h" +#include "mmath.h" #include "types.h" +#include "xfonts.h" #include "xmesaP.h" @@ -70,6 +72,7 @@ /* Silence compiler warnings */ +extern void Fake_glXDummyFunc( void ); void Fake_glXDummyFunc( void ) { (void) kernel8; @@ -226,7 +229,9 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, GLboolean rgbFlag, GLboolean alphaFlag, GLboolean dbFlag, GLboolean stereoFlag, GLint depth_size, GLint stencil_size, - GLint accum_size, GLint level ) + GLint accumRedSize, GLint accumGreenSize, + GLint accumBlueSize, GLint accumAlphaSize, + GLint level ) { GLboolean ximageFlag = GL_TRUE; XMesaVisual xmvis; @@ -269,7 +274,10 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, && (v->gl_visual->AlphaBits > 0) == alphaFlag && (v->gl_visual->DepthBits >= depth_size || depth_size == 0) && (v->gl_visual->StencilBits >= stencil_size || stencil_size == 0) - && (v->gl_visual->AccumBits >= accum_size || accum_size == 0)) { + && (v->gl_visual->AccumRedBits >= accumRedSize || accumRedSize == 0) + && (v->gl_visual->AccumGreenBits >= accumGreenSize || accumGreenSize == 0) + && (v->gl_visual->AccumBlueBits >= accumBlueSize || accumBlueSize == 0) + && (v->gl_visual->AccumAlphaBits >= accumAlphaSize || accumAlphaSize == 0)) { /* now either compare XVisualInfo pointers or visual IDs */ if ((!comparePointers && v->visinfo->visualid == vinfo->visualid) || (comparePointers && v->vishandle == vinfo)) { @@ -287,7 +295,10 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, xmvis = XMesaCreateVisual( dpy, vinfo, rgbFlag, alphaFlag, dbFlag, stereoFlag, ximageFlag, - depth_size, stencil_size, accum_size, level ); + depth_size, stencil_size, + accumRedSize, accumBlueSize, + accumBlueSize, accumAlphaSize, 0, level, + GLX_NONE_EXT ); if (xmvis) { VisualTable[NumVisuals] = xmvis; NumVisuals++; @@ -299,6 +310,11 @@ save_glx_visual( Display *dpy, XVisualInfo *vinfo, /* * Create a GLX visual from a regular XVisualInfo. + * This is called when Fake GLX is given an XVisualInfo which wasn't + * returned by glXChooseVisual. Since this is the first time we're + * considering this visual we'll take a guess at reasonable values + * for depth buffer size, stencil size, accum size, etc. + * This is the best we can do with a client-side emulation of GLX. */ static XMesaVisual create_glx_visual( Display *dpy, XVisualInfo *visinfo ) @@ -315,7 +331,7 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo ) GL_FALSE, /* stereo */ 0, /* depth bits */ 0, /* stencil bits */ - 0, /* accum bits */ + 0,0,0,0, /* accum bits */ vislevel /* level */ ); } @@ -328,9 +344,12 @@ create_glx_visual( Display *dpy, XVisualInfo *visinfo ) GL_FALSE, /* alpha */ GL_TRUE, /* double */ GL_FALSE, /* stereo */ - 8*sizeof(GLdepth), - 8*sizeof(GLstencil), - 8*sizeof(GLaccum), + DEFAULT_SOFTWARE_DEPTH_BITS, + 8 * sizeof(GLstencil), + 8 * sizeof(GLaccum), /* r */ + 8 * sizeof(GLaccum), /* g */ + 8 * sizeof(GLaccum), /* b */ + 8 * sizeof(GLaccum), /* a */ 0 /* level */ ); } @@ -436,21 +455,6 @@ static int transparent_pixel( XMesaVisual glxvis ) /* - * Return number of bits set in n. - */ -static int bitcount( unsigned long n ) -{ - int bits; - for (bits=0; n>0; n=n>>1) { - if (n&1) { - bits++; - } - } - return bits; -} - - -/* * Try to get an X visual which matches the given arguments. */ static XVisualInfo *get_visual( Display *dpy, int scr, @@ -483,9 +487,9 @@ static XVisualInfo *get_visual( Display *dpy, int scr, * 10 bits per color channel. Mesa's limited to a max of 8 bits/channel. */ if (vis && depth > 24 && (xclass==TrueColor || xclass==DirectColor)) { - if (bitcount(vis->red_mask) <= 8 - && bitcount(vis->green_mask) <= 8 - && bitcount(vis->blue_mask) <= 8) { + if (_mesa_bitcount((GLuint) vis->red_mask ) <= 8 && + _mesa_bitcount((GLuint) vis->green_mask) <= 8 && + _mesa_bitcount((GLuint) vis->blue_mask ) <= 8) { return vis; } else { @@ -860,11 +864,15 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) GLboolean stereo_flag = GL_FALSE; GLint depth_size = 0; GLint stencil_size = 0; - GLint accum_size = 0; + GLint accumRedSize = 0; + GLint accumGreenSize = 0; + GLint accumBlueSize = 0; + GLint accumAlphaSize = 0; int level = 0; int visual_type = DONT_CARE; int trans_type = DONT_CARE; int trans_value = DONT_CARE; + GLint caveat = DONT_CARE; parselist = list; @@ -927,13 +935,31 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) stencil_size = *parselist++; break; case GLX_ACCUM_RED_SIZE: + parselist++; + { + GLint size = *parselist++; + accumRedSize = MAX2( accumRedSize, size ); + } + break; case GLX_ACCUM_GREEN_SIZE: + parselist++; + { + GLint size = *parselist++; + accumGreenSize = MAX2( accumGreenSize, size ); + } + break; case GLX_ACCUM_BLUE_SIZE: + parselist++; + { + GLint size = *parselist++; + accumBlueSize = MAX2( accumBlueSize, size ); + } + break; case GLX_ACCUM_ALPHA_SIZE: parselist++; { GLint size = *parselist++; - accum_size = MAX2( accum_size, size ); + accumAlphaSize = MAX2( accumAlphaSize, size ); } break; @@ -961,6 +987,14 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) parselist++; break; + /* + * GLX_EXT_visual_info extension + */ + case GLX_VISUAL_CAVEAT_EXT: + parselist++; + caveat = *parselist++; /* ignored for now */ + break; + case None: break; default: @@ -990,7 +1024,7 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) else { /* Get a color index visual */ vis = choose_x_visual( dpy, screen, rgb_flag, min_ci, visual_type ); - accum_size = 0; + accumRedSize = accumGreenSize = accumBlueSize = accumAlphaSize = 0; } } else { @@ -1013,9 +1047,33 @@ Fake_glXChooseVisual( Display *dpy, int screen, int *list ) } if (vis) { + /* Note: we're not exactly obeying the glXChooseVisual rules here. + * When GLX_DEPTH_SIZE = 1 is specified we're supposed to choose the + * largest depth buffer size, which is 32bits/value. However, we + * return 16 to maintain performance with earlier versions of Mesa. + */ + if (depth_size == 1) + depth_size = DEFAULT_SOFTWARE_DEPTH_BITS; + else if (depth_size > 24) + depth_size = 31; + else if (depth_size > 16) + depth_size = 24; + /* we only support one size of stencil and accum buffers. */ + if (stencil_size > 0) + stencil_size = STENCIL_BITS; + if (accumRedSize > 0) + accumRedSize = ACCUM_BITS; + if (accumGreenSize > 0) + accumGreenSize = ACCUM_BITS; + if (accumBlueSize > 0) + accumBlueSize = ACCUM_BITS; + if (accumAlphaSize > 0) + accumAlphaSize = ACCUM_BITS; if (!save_glx_visual( dpy, vis, rgb_flag, alpha_flag, double_flag, - stereo_flag, - depth_size, stencil_size, accum_size, level )) + stereo_flag, depth_size, stencil_size, + accumRedSize, accumGreenSize, + accumBlueSize, accumAlphaSize, + level )) return NULL; } @@ -1227,6 +1285,7 @@ Fake_glXQueryExtension( Display *dpy, int *errorb, int *event ) } +extern void _kw_ungrab_all( Display *dpy ); void _kw_ungrab_all( Display *dpy ) { XUngrabPointer( dpy, CurrentTime ); @@ -1372,15 +1431,16 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, *value = glxvis->gl_visual->StencilBits; return 0; case GLX_ACCUM_RED_SIZE: + *value = glxvis->gl_visual->AccumRedBits; + return 0; case GLX_ACCUM_GREEN_SIZE: + *value = glxvis->gl_visual->AccumGreenBits; + return 0; case GLX_ACCUM_BLUE_SIZE: - *value = glxvis->gl_visual->AccumBits; + *value = glxvis->gl_visual->AccumBlueBits; return 0; case GLX_ACCUM_ALPHA_SIZE: - if (glxvis->gl_visual->AlphaBits > 0) - *value = glxvis->gl_visual->AccumBits; - else - *value = 0; + *value = glxvis->gl_visual->AccumAlphaBits; return 0; /* @@ -1438,6 +1498,17 @@ Fake_glXGetConfig( Display *dpy, XVisualInfo *visinfo, return 0; /* + * GLX_EXT_visual_info extension + */ + case GLX_VISUAL_CAVEAT_EXT: + /* test for zero, just in case */ + if (glxvis->VisualCaveat > 0) + *value = glxvis->VisualCaveat; + else + *value = GLX_NONE_EXT; + return 0; + + /* * Extensions */ default: @@ -1472,10 +1543,10 @@ static const char *get_extensions( void ) #ifdef FX const char *fx = getenv("MESA_GLX_FX"); if (fx && fx[0] != 'd') { - return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address"; + return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_MESA_set_3dfx_mode GLX_ARB_get_proc_address"; } #endif - return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address"; + return "GLX_MESA_pixmap_colormap GLX_EXT_visual_info GLX_EXT_visual_rating GLX_MESA_release_buffers GLX_MESA_copy_sub_buffer GLX_SGI_video_sync GLX_ARB_get_proc_address"; } @@ -1544,7 +1615,7 @@ Fake_glXGetClientString( Display *dpy, int name ) * GLX 1.3 and later */ -static GLXFBConfig +static GLXFBConfig * Fake_glXChooseFBConfig( Display *dpy, int screen, const int *attribList, int *nitems ) { @@ -1568,6 +1639,16 @@ Fake_glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config, } +static GLXFBConfig * +Fake_glXGetFBConfigs( Display *dpy, int screen, int *nelements ) +{ + (void) dpy; + (void) screen; + (void) nelements; + return 0; +} + + static XVisualInfo * Fake_glXGetVisualFromFBConfig( Display *dpy, GLXFBConfig config ) { @@ -1742,9 +1823,7 @@ Fake_glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count) -extern void Fake_glXUseXFont( Font font, int first, int count, int listbase ); - - +extern struct _glxapi_table *_mesa_GetGLXDispatchTable(void); struct _glxapi_table *_mesa_GetGLXDispatchTable(void) { static struct _glxapi_table glx; @@ -1799,6 +1878,7 @@ struct _glxapi_table *_mesa_GetGLXDispatchTable(void) glx.DestroyWindow = Fake_glXDestroyWindow; /*glx.GetCurrentReadDrawable = Fake_glXGetCurrentReadDrawable;*/ glx.GetFBConfigAttrib = Fake_glXGetFBConfigAttrib; + glx.GetFBConfigs = Fake_glXGetFBConfigs; glx.GetSelectedEvent = Fake_glXGetSelectedEvent; glx.GetVisualFromFBConfig = Fake_glXGetVisualFromFBConfig; glx.MakeContextCurrent = Fake_glXMakeContextCurrent; diff --git a/xc/extras/Mesa/src/X/xfonts.c b/xc/extras/Mesa/src/X/xfonts.c index c71e65324..2a1aca33c 100644 --- a/xc/extras/Mesa/src/X/xfonts.c +++ b/xc/extras/Mesa/src/X/xfonts.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -43,8 +43,10 @@ #include "GL/xmesa.h" #include "context.h" #include "mem.h" +#include "xfonts.h" #include "xmesaP.h" + /* Some debugging info. */ #ifdef DEBUG @@ -372,7 +374,7 @@ bm_height); glEndList (); } - free (bm); + FREE(bm); XFreeFontInfo( NULL, fs, 0 ); XFreeGC (dpy, gc); @@ -385,6 +387,8 @@ bm_height); glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); } + +extern void xmesa_xfonts_dummy( void ); void xmesa_xfonts_dummy( void ) { /* silence unused var warnings */ diff --git a/xc/extras/Mesa/src/X/xmesa1.c b/xc/extras/Mesa/src/X/xmesa1.c index 56e6fcad7..92aad010c 100644 --- a/xc/extras/Mesa/src/X/xmesa1.c +++ b/xc/extras/Mesa/src/X/xmesa1.c @@ -64,6 +64,7 @@ #include "GL/xmesa.h" #include "xmesaP.h" #include "context.h" +#include "extensions.h" #include "matrix.h" #include "mem.h" #include "types.h" @@ -72,6 +73,11 @@ #endif +#ifndef GLX_NONE_EXT +#define GLX_NONE_EXT 0x8000 +#endif + + /* * Current X/Mesa context pointer: */ @@ -418,7 +424,7 @@ static void free_xmesa_buffer(int client, XMesaBuffer buffer) } -/* Copy X color table stuff from on XMesaBuffer to another. */ +/* Copy X color table stuff from one XMesaBuffer to another. */ static void copy_colortable_info(XMesaBuffer dst, const XMesaBuffer src) { MEMCPY(dst->color_table, src->color_table, sizeof(src->color_table)); @@ -1349,10 +1355,11 @@ static GLboolean initialize_visual_and_buffer( int client, /* * Convert an RGBA color to a pixel value. */ -unsigned long xmesa_color_to_pixel( XMesaContext xmesa, - GLubyte r, GLubyte g, GLubyte b, GLubyte a) +unsigned long +xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLubyte a, + GLuint pixelFormat) { - switch (xmesa->pixelformat) { + switch (pixelFormat) { case PF_INDEX: return 0; case PF_TRUECOLOR: @@ -1408,21 +1415,29 @@ unsigned long xmesa_color_to_pixel( XMesaContext xmesa, /* * Create a new X/Mesa visual. - * Input: display - the X display - * visinfo - the XVisualInfo - * rgb_flag - TRUE=RGB(A) mode, FALSE=CI mode - * alpha_flag - need alpha planes? - * db_flag - TRUE=double bufferd, FALSE=single - * stereo_flag - true/false - * ximage_flag - TRUE=use XImage for back buffer, FALSE=use Pixmap - * depth_size - requested min bits per depth buffer value - * stencil_size - requested min bits per stencil buffer value - * accum_size - requested min bits per accum buffer value (per channel) - * level - 0=normal, 1=overaly, -1=underlay, etc. - * Return: New XMesaVisual or NULL if something goes wrong + * Input: display - X11 display + * visinfo - an XVisualInfo pointer + * rgb_flag - GL_TRUE = RGB mode, + * GL_FALSE = color index mode + * alpha_flag - alpha buffer requested? + * db_flag - GL_TRUE = double-buffered, + * GL_FALSE = single buffered + * stereo_flag - stereo visual? + * ximage_flag - GL_TRUE = use an XImage for back buffer, + * GL_FALSE = use an off-screen pixmap for back buffer + * depth_size - requested bits/depth values, or zero + * stencil_size - requested bits/stencil values, or zero + * accum_red_size - requested bits/red accum values, or zero + * accum_green_size - requested bits/green accum values, or zero + * accum_blue_size - requested bits/blue accum values, or zero + * accum_alpha_size - requested bits/alpha accum values, or zero + * num_samples - number of samples/pixel if multisampling, or zero + * level - visual level, usually 0 + * visualCaveat - ala the GLX extension, usually GLX_NONE_EXT + * Return; a new XMesaVisual or 0 if error. */ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, - XMesaVisualInfo visinfo, + XMesaVisualInfo visinfo, GLboolean rgb_flag, GLboolean alpha_flag, GLboolean db_flag, @@ -1430,8 +1445,13 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, GLboolean ximage_flag, GLint depth_size, GLint stencil_size, - GLint accum_size, - GLint level ) + GLint accum_red_size, + GLint accum_green_size, + GLint accum_blue_size, + GLint accum_alpha_size, + GLint num_samples, + GLint level, + GLint visualCaveat ) { char *gamma; XMesaVisual v; @@ -1506,6 +1526,7 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, v->ximage_flag = ximage_flag; v->level = level; + v->VisualCaveat = visualCaveat; (void) initialize_visual_and_buffer( 0, v, NULL, rgb_flag, 0, 0 ); @@ -1532,11 +1553,15 @@ XMesaVisual XMesaCreateVisual( XMesaDisplay *display, } } - v->gl_visual = gl_create_visual( rgb_flag, alpha_flag, db_flag, stereo_flag, - depth_size, stencil_size, accum_size, - v->index_bits, - red_bits, green_bits, - blue_bits, alpha_bits ); + v->gl_visual = _mesa_create_visual( rgb_flag, db_flag, stereo_flag, + red_bits, green_bits, + blue_bits, alpha_bits, + v->index_bits, + depth_size, + stencil_size, + accum_red_size, accum_green_size, + accum_blue_size, accum_alpha_size, + 0 ); if (!v->gl_visual) { #ifndef XFree86Server FREE(v->visinfo); @@ -1557,7 +1582,7 @@ void XMesaSetVisualDisplay( XMesaDisplay *dpy, XMesaVisual v ) void XMesaDestroyVisual( XMesaVisual v ) { - gl_destroy_visual( v->gl_visual ); + _mesa_destroy_visual( v->gl_visual ); #ifndef XFree86Server FREE(v->visinfo); #endif @@ -1594,6 +1619,9 @@ XMesaContext XMesaCreateContext( XMesaVisual v, XMesaContext share_list return NULL; } + gl_extensions_enable(c->gl_ctx, "GL_HP_occlusion_test"); + gl_extensions_enable(c->gl_ctx, "GL_ARB_texture_cube_map"); + if (CHECK_BYTE_ORDER(v)) { c->swapbytes = GL_FALSE; } @@ -1750,7 +1778,7 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, b->gl_buffer = gl_create_framebuffer( v->gl_visual, v->gl_visual->DepthBits > 0, v->gl_visual->StencilBits > 0, - v->gl_visual->AccumBits > 0, + v->gl_visual->AccumRedBits > 0, v->gl_visual->AlphaBits > 0 ); if (!b->gl_buffer) { free_xmesa_buffer(client, b); @@ -1778,9 +1806,9 @@ XMesaBuffer XMesaCreateWindowBuffer2( XMesaVisual v, if (v->gl_visual->DBflag) { attribs[numAttribs++] = FXMESA_DOUBLEBUFFER; } - if (v->gl_visual->AccumBits > 0) { + if (v->gl_visual->AccumRedBits > 0) { attribs[numAttribs++] = FXMESA_ACCUM_SIZE; - attribs[numAttribs++] = v->gl_visual->AccumBits; + attribs[numAttribs++] = v->gl_visual->AccumRedBits; } if (v->gl_visual->StencilBits > 0) { attribs[numAttribs++] = FXMESA_STENCIL_SIZE; @@ -1897,7 +1925,9 @@ XMesaBuffer XMesaCreatePixmapBuffer( XMesaVisual v, b->gl_buffer = gl_create_framebuffer( v->gl_visual, v->gl_visual->DepthBits > 0, v->gl_visual->StencilBits > 0, - v->gl_visual->AccumBits > 0, + v->gl_visual->AccumRedBits + + v->gl_visual->AccumGreenBits + + v->gl_visual->AccumBlueBits > 0, v->gl_visual->AlphaBits > 0 ); if (!b->gl_buffer) { free_xmesa_buffer(client, b); @@ -2041,13 +2071,14 @@ GLboolean XMesaMakeCurrent2( XMesaContext c, XMesaBuffer drawBuffer, * can be different for different windows. */ c->pixel = xmesa_color_to_pixel( c, c->red, c->green, - c->blue, c->alpha ); + c->blue, c->alpha, c->pixelformat ); XMesaSetForeground( c->display, c->xm_buffer->gc1, c->pixel ); c->clearpixel = xmesa_color_to_pixel( c, c->clearcolor[0], c->clearcolor[1], c->clearcolor[2], - c->clearcolor[3] ); + c->clearcolor[3], + c->xm_visual->undithered_pf); XMesaSetForeground(c->display, c->xm_buffer->cleargc, c->clearpixel); } @@ -2147,13 +2178,13 @@ GLboolean XMesaSetFXmode( GLint mode ) if (XMesa) { if (mode == XMESA_FX_WINDOW) { if (XMesa->xm_buffer->FXisHackUsable) { - grSstControl(GR_CONTROL_DEACTIVATE); + FX_grSstControl(GR_CONTROL_DEACTIVATE); XMesa->xm_buffer->FXwindowHack = GL_TRUE; return GL_TRUE; } } else if (mode == XMESA_FX_FULLSCREEN) { - grSstControl(GR_CONTROL_ACTIVATE); + FX_grSstControl(GR_CONTROL_ACTIVATE); XMesa->xm_buffer->FXwindowHack = GL_FALSE; return GL_TRUE; } @@ -2253,7 +2284,7 @@ static void FXgetImage( XMesaBuffer b ) (pixbuf[x] & 0xf800) >> 8, (pixbuf[x] & 0x07e0) >> 3, (pixbuf[x] & 0x001f) << 3, - 0xff)); + 0xff, XMesa->pixelformat)); } } } @@ -2435,7 +2466,7 @@ GLboolean XMesaGetBackBuffer( XMesaBuffer b, GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height, GLint *bytesPerValue, void **buffer ) { - if ((!b->gl_buffer) || (!b->gl_buffer->Depth)) { + if ((!b->gl_buffer) || (!b->gl_buffer->DepthBuffer)) { *width = 0; *height = 0; *bytesPerValue = 0; @@ -2446,7 +2477,7 @@ GLboolean XMesaGetDepthBuffer( XMesaBuffer b, GLint *width, GLint *height, *width = b->gl_buffer->Width; *height = b->gl_buffer->Height; *bytesPerValue = sizeof(GLdepth); - *buffer = b->gl_buffer->Depth; + *buffer = b->gl_buffer->DepthBuffer; return GL_TRUE; } } diff --git a/xc/extras/Mesa/src/X/xmesa2.c b/xc/extras/Mesa/src/X/xmesa2.c index 75340eb43..77b8d4b05 100644 --- a/xc/extras/Mesa/src/X/xmesa2.c +++ b/xc/extras/Mesa/src/X/xmesa2.c @@ -36,8 +36,12 @@ #include "drawpix.h" #include "mem.h" #include "state.h" +#include "depth.h" +#include "macros.h" +#include "vb.h" #include "types.h" #include "xmesaP.h" +#include "extensions.h" @@ -347,7 +351,8 @@ static void clear_color( GLcontext *ctx, xmesa->clearcolor[1] = g; xmesa->clearcolor[2] = b; xmesa->clearcolor[3] = a; - xmesa->clearpixel = xmesa_color_to_pixel( xmesa, r, g, b, a ); + xmesa->clearpixel = xmesa_color_to_pixel( xmesa, r, g, b, a, + xmesa->xm_visual->undithered_pf ); XMesaSetForeground( xmesa->display, xmesa->xm_buffer->cleargc, xmesa->clearpixel ); } @@ -430,7 +435,7 @@ static void set_color( GLcontext *ctx, xmesa->green = g; xmesa->blue = b; xmesa->alpha = a; - xmesa->pixel = xmesa_color_to_pixel( xmesa, r, g, b, a );; + xmesa->pixel = xmesa_color_to_pixel( xmesa, r, g, b, a, xmesa->pixelformat );; XMesaSetForeground( xmesa->display, xmesa->xm_buffer->gc1, xmesa->pixel ); } @@ -713,7 +718,7 @@ clear_16bit_ximage( GLcontext *ctx, GLboolean all, } -/* Optimized code provided by Nozomi Ytow <nozomi@biol.tsukuba.ac.jp> */ +/* Optimized code provided by Nozomi Ytow <noz@xfree86.org> */ static void clear_24bit_ximage( GLcontext *ctx, GLboolean all, GLint x, GLint y, GLint width, GLint height ) @@ -731,14 +736,31 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, } if (all) { - register GLint n = xmesa->xm_buffer->width * xmesa->xm_buffer->height; - register bgr_t *ptr3 = (bgr_t *) xmesa->xm_buffer->backimage->data; if (r==g && g==b) { /* same value for all three components (gray) */ - MEMSET(ptr3, r, 3 * n); + const GLint w3 = xmesa->xm_buffer->width * 3; + const GLint h = xmesa->xm_buffer->height; + GLint i; + for (i = 0; i < h; i++) { + bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i); + MEMSET(ptr3, r, w3); + } } else { /* the usual case */ + const GLint w = xmesa->xm_buffer->width; + const GLint h = xmesa->xm_buffer->height; + GLint i, j; + for (i = 0; i < h; i++) { + bgr_t *ptr3 = PIXELADDR3(xmesa->xm_buffer, 0, i); + for (j = 0; j < w; j++) { + ptr3->r = r; + ptr3->g = g; + ptr3->b = b; + ptr3++; + } + } +#if 0 /* this code doesn't work for all window widths */ register GLuint *ptr4 = (GLuint *) ptr3; register GLuint px; GLuint pixel4[3]; @@ -805,6 +827,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, case 0: break; } +#endif } } else { @@ -819,6 +842,17 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, } else { /* non-gray clear color */ + GLint i, j; + for (j = 0; j < height; j++) { + bgr_t *ptr3 = PIXELADDR3( xmesa->xm_buffer, x, y+j ); + for (i = 0; i < width; i++) { + ptr3->r = r; + ptr3->g = g; + ptr3->b = b; + ptr3++; + } + } +#if 0 /* this code might not always (seems ptr3 always == ptr4) */ GLint j; GLuint pixel4[3]; pixel4[0] = clearPixel | (clearPixel << 24); @@ -889,6 +923,7 @@ clear_24bit_ximage( GLcontext *ctx, GLboolean all, break; } } +#endif } } } @@ -2342,9 +2377,24 @@ static void write_span_5R6G5B_ximage( RGBA_SPAN_ARGS ) } else { /* draw all pixels */ - for (i=0;i<n;i++) { - ptr[i] = PACK_5R6G5B( rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ); +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint *ptr32 = (GLuint *) ptr; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2) { + GLuint p0, p1; + p0 = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); + p1 = PACK_5R6G5B(rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP]); + *ptr32++ = (p1 << 16) | p0; + } + if (extraPixel) { + ptr[n] = PACK_5R6G5B(rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]); + } +#else + for (i = 0; i < n; i++) { + ptr[i] = PACK_5R6G5B(rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); } +#endif } } @@ -2366,9 +2416,24 @@ static void write_span_DITHER_5R6G5B_ximage( RGBA_SPAN_ARGS ) } else { /* draw all pixels */ - for (i=0;i<n;i++,x++) { - PACK_TRUEDITHER( ptr[i], x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ); +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint *ptr32 = (GLuint *) ptr; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2, x += 2) { + GLuint p0, p1; + PACK_TRUEDITHER( p0, x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP] ); + PACK_TRUEDITHER( p1, x+1, y, rgba[i+1][RCOMP], rgba[i+1][GCOMP], rgba[i+1][BCOMP] ); + *ptr32++ = (p1 << 16) | p0; + } + if (extraPixel) { + PACK_TRUEDITHER( ptr[n], x+n, y, rgba[n][RCOMP], rgba[n][GCOMP], rgba[n][BCOMP]); } +#else + for (i = 0; i < n; i++, x++) { + PACK_TRUEDITHER( ptr[i], x, y, rgba[i][RCOMP], rgba[i][GCOMP], rgba[i][BCOMP]); + } +#endif } } @@ -2390,9 +2455,24 @@ static void write_span_rgb_5R6G5B_ximage( RGB_SPAN_ARGS ) } else { /* draw all pixels */ +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint *ptr32 = (GLuint *) ptr; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2) { + GLuint p0, p1; + p0 = PACK_5R6G5B(rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP]); + p1 = PACK_5R6G5B(rgb[i+1][RCOMP], rgb[i+1][GCOMP], rgb[i+1][BCOMP]); + *ptr32++ = (p1 << 16) | p0; + } + if (extraPixel) { + ptr[n] = PACK_5R6G5B(rgb[n][RCOMP], rgb[n][GCOMP], rgb[n][BCOMP]); + } +#else for (i=0;i<n;i++) { ptr[i] = PACK_5R6G5B( rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ); } +#endif } } @@ -2414,9 +2494,24 @@ static void write_span_rgb_DITHER_5R6G5B_ximage( RGB_SPAN_ARGS ) } else { /* draw all pixels */ +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint *ptr32 = (GLuint *) ptr; + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2, x += 2) { + GLuint p0, p1; + PACK_TRUEDITHER( p0, x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ); + PACK_TRUEDITHER( p1, x+1, y, rgb[i+1][RCOMP], rgb[i+1][GCOMP], rgb[i+1][BCOMP] ); + *ptr32++ = (p1 << 16) | p0; + } + if (extraPixel) { + PACK_TRUEDITHER( ptr[n], x+n, y, rgb[n][RCOMP], rgb[n][GCOMP], rgb[n][BCOMP]); + } +#else for (i=0;i<n;i++,x++) { PACK_TRUEDITHER( ptr[i], x, y, rgb[i][RCOMP], rgb[i][GCOMP], rgb[i][BCOMP] ); } +#endif } } @@ -4280,7 +4375,6 @@ static void read_color_span( const GLcontext *ctx, { const XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaBuffer source; - register GLuint i; if (xmesa->use_read_buffer) source = xmesa->xm_read_buffer; @@ -4288,10 +4382,11 @@ static void read_color_span( const GLcontext *ctx, source = xmesa->xm_buffer; if (source->buffer) { + /* Read from Pixmap or Window */ XMesaImage *span = NULL; int error; #ifdef XFree86Server - span = XMesaCreateImage(GET_VISUAL_DEPTH(xmesa->xm_visual), n, 1, NULL); + span = XMesaCreateImage(xmesa->xm_visual->BitsPerPixel, n, 1, NULL); span->data = (char *)MALLOC(span->height * span->bytes_per_line); error = (!span->data); (*xmesa->display->GetImage)(source->buffer, @@ -4307,18 +4402,17 @@ static void read_color_span( const GLcontext *ctx, switch (xmesa->pixelformat) { case PF_TRUECOLOR: case PF_TRUEDITHER: - case PF_5R6G5B: - case PF_DITHER_5R6G5B: { + const GLubyte *pixelToR = xmesa->xm_visual->PixelToR; + const GLubyte *pixelToG = xmesa->xm_visual->PixelToG; + const GLubyte *pixelToB = xmesa->xm_visual->PixelToB; unsigned long rMask = GET_REDMASK(xmesa->xm_visual); unsigned long gMask = GET_GREENMASK(xmesa->xm_visual); unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual); - GLubyte *pixelToR = xmesa->xm_visual->PixelToR; - GLubyte *pixelToG = xmesa->xm_visual->PixelToG; - GLubyte *pixelToB = xmesa->xm_visual->PixelToB; GLint rShift = xmesa->xm_visual->rshift; GLint gShift = xmesa->xm_visual->gshift; GLint bShift = xmesa->xm_visual->bshift; + GLuint i; for (i=0;i<n;i++) { unsigned long p; p = XMesaGetPixel( span, i, 0 ); @@ -4329,9 +4423,31 @@ static void read_color_span( const GLcontext *ctx, } } break; + case PF_5R6G5B: + case PF_DITHER_5R6G5B: + { + const GLubyte *pixelToR = xmesa->xm_visual->PixelToR; + const GLubyte *pixelToG = xmesa->xm_visual->PixelToG; + const GLubyte *pixelToB = xmesa->xm_visual->PixelToB; + GLuint i; + for (i=0;i<n;i++) { + unsigned long p = XMesaGetPixel( span, i, 0 ); + /* fast, but not quite accurate + rgba[i][RCOMP] = ((p >> 8) & 0xf8); + rgba[i][GCOMP] = ((p >> 3) & 0xfc); + rgba[i][BCOMP] = ((p << 3) & 0xff); + */ + rgba[i][RCOMP] = pixelToR[p >> 11]; + rgba[i][GCOMP] = pixelToG[(p >> 5) & 0x3f]; + rgba[i][BCOMP] = pixelToB[p & 0x1f]; + rgba[i][ACOMP] = 255; + } + } + break; case PF_8A8B8G8R: { - GLuint *ptr4 = (GLuint *) span->data; + const GLuint *ptr4 = (GLuint *) span->data; + GLuint i; for (i=0;i<n;i++) { GLuint p4 = *ptr4++; rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff); @@ -4343,7 +4459,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_8R8G8B: { - GLuint *ptr4 = (GLuint *) span->data; + const GLuint *ptr4 = (GLuint *) span->data; + GLuint i; for (i=0;i<n;i++) { GLuint p4 = *ptr4++; rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff); @@ -4355,7 +4472,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_8R8G8B24: { - bgr_t *ptr3 = (bgr_t *) span->data; + const bgr_t *ptr3 = (bgr_t *) span->data; + GLuint i; for (i=0;i<n;i++) { rgba[i][RCOMP] = ptr3[i].r; rgba[i][GCOMP] = ptr3[i].g; @@ -4367,6 +4485,7 @@ static void read_color_span( const GLcontext *ctx, case PF_HPCR: { GLubyte *ptr1 = (GLubyte *) span->data; + GLuint i; for (i=0;i<n;i++) { GLubyte p = *ptr1++; rgba[i][RCOMP] = p & 0xE0; @@ -4384,7 +4503,8 @@ static void read_color_span( const GLcontext *ctx, GLubyte *gTable = source->pixel_to_g; GLubyte *bTable = source->pixel_to_b; if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) { - GLubyte *ptr1 = (GLubyte *) span->data; + const GLubyte *ptr1 = (GLubyte *) span->data; + GLuint i; for (i=0;i<n;i++) { unsigned long p = *ptr1++; rgba[i][RCOMP] = rTable[p]; @@ -4394,9 +4514,9 @@ static void read_color_span( const GLcontext *ctx, } } else { + GLuint i; for (i=0;i<n;i++) { - unsigned long p; - p = XMesaGetPixel( span, i, 0 ); + unsigned long p = XMesaGetPixel( span, i, 0 ); rgba[i][RCOMP] = rTable[p]; rgba[i][GCOMP] = gTable[p]; rgba[i][BCOMP] = bTable[p]; @@ -4408,6 +4528,7 @@ static void read_color_span( const GLcontext *ctx, case PF_1BIT: { int bitFlip = xmesa->xm_visual->bitFlip; + GLuint i; for (i=0;i<n;i++) { unsigned long p; p = XMesaGetPixel( span, i, 0 ) ^ bitFlip; @@ -4425,6 +4546,7 @@ static void read_color_span( const GLcontext *ctx, } else { /* return black pixels */ + GLuint i; for (i=0;i<n;i++) { rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = rgba[i][ACOMP] = 0; } @@ -4434,22 +4556,22 @@ static void read_color_span( const GLcontext *ctx, } } else if (source->backimage) { + /* Read from XImage back buffer */ switch (xmesa->pixelformat) { case PF_TRUECOLOR: case PF_TRUEDITHER: - case PF_5R6G5B: - case PF_DITHER_5R6G5B: { + const GLubyte *pixelToR = xmesa->xm_visual->PixelToR; + const GLubyte *pixelToG = xmesa->xm_visual->PixelToG; + const GLubyte *pixelToB = xmesa->xm_visual->PixelToB; unsigned long rMask = GET_REDMASK(xmesa->xm_visual); unsigned long gMask = GET_GREENMASK(xmesa->xm_visual); unsigned long bMask = GET_BLUEMASK(xmesa->xm_visual); - GLubyte *pixelToR = xmesa->xm_visual->PixelToR; - GLubyte *pixelToG = xmesa->xm_visual->PixelToG; - GLubyte *pixelToB = xmesa->xm_visual->PixelToB; GLint rShift = xmesa->xm_visual->rshift; GLint gShift = xmesa->xm_visual->gshift; GLint bShift = xmesa->xm_visual->bshift; XMesaImage *img = source->backimage; + GLuint i; y = FLIP(source, y); for (i=0;i<n;i++) { unsigned long p; @@ -4461,9 +4583,58 @@ static void read_color_span( const GLcontext *ctx, } } break; + case PF_5R6G5B: + case PF_DITHER_5R6G5B: + { + const GLubyte *pixelToR = xmesa->xm_visual->PixelToR; + const GLubyte *pixelToG = xmesa->xm_visual->PixelToG; + const GLubyte *pixelToB = xmesa->xm_visual->PixelToB; + const GLushort *ptr2 = PIXELADDR2( source, x, y ); + const GLuint *ptr4 = (const GLuint *) ptr2; + GLuint i; +#if defined(__i386__) /* word stores don't have to be on 4-byte boundaries */ + GLuint extraPixel = (n & 1); + n -= extraPixel; + for (i = 0; i < n; i += 2) { + const GLuint p = *ptr4++; + const GLuint p0 = p & 0xffff; + const GLuint p1 = p >> 16; + /* fast, but not quite accurate + rgba[i][RCOMP] = ((p >> 8) & 0xf8); + rgba[i][GCOMP] = ((p >> 3) & 0xfc); + rgba[i][BCOMP] = ((p << 3) & 0xff); + */ + rgba[i][RCOMP] = pixelToR[p0 >> 11]; + rgba[i][GCOMP] = pixelToG[(p0 >> 5) & 0x3f]; + rgba[i][BCOMP] = pixelToB[p0 & 0x1f]; + rgba[i][ACOMP] = 255; + rgba[i+1][RCOMP] = pixelToR[p1 >> 11]; + rgba[i+1][GCOMP] = pixelToG[(p1 >> 5) & 0x3f]; + rgba[i+1][BCOMP] = pixelToB[p1 & 0x1f]; + rgba[i+1][ACOMP] = 255; + } + if (extraPixel) { + GLushort p = ptr2[n]; + rgba[n][RCOMP] = pixelToR[p >> 11]; + rgba[n][GCOMP] = pixelToG[(p >> 5) & 0x3f]; + rgba[n][BCOMP] = pixelToB[p & 0x1f]; + rgba[n][ACOMP] = 255; + } +#else + for (i = 0; i < n; i++) { + const GLushort p = ptr2[i]; + rgba[i][RCOMP] = pixelToR[p >> 11]; + rgba[i][GCOMP] = pixelToG[(p >> 5) & 0x3f]; + rgba[i][BCOMP] = pixelToB[p & 0x1f]; + rgba[i][ACOMP] = 255; + } +#endif + } + break; case PF_8A8B8G8R: { - GLuint *ptr4 = PIXELADDR4( source, x, y ); + const GLuint *ptr4 = PIXELADDR4( source, x, y ); + GLuint i; for (i=0;i<n;i++) { GLuint p4 = *ptr4++; rgba[i][RCOMP] = (GLubyte) ( p4 & 0xff); @@ -4475,7 +4646,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_8R8G8B: { - GLuint *ptr4 = PIXELADDR4( source, x, y ); + const GLuint *ptr4 = PIXELADDR4( source, x, y ); + GLuint i; for (i=0;i<n;i++) { GLuint p4 = *ptr4++; rgba[i][RCOMP] = (GLubyte) ((p4 >> 16) & 0xff); @@ -4487,7 +4659,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_8R8G8B24: { - bgr_t *ptr3 = PIXELADDR3( source, x, y ); + const bgr_t *ptr3 = PIXELADDR3( source, x, y ); + GLuint i; for (i=0;i<n;i++) { rgba[i][RCOMP] = ptr3[i].r; rgba[i][GCOMP] = ptr3[i].g; @@ -4498,7 +4671,8 @@ static void read_color_span( const GLcontext *ctx, break; case PF_HPCR: { - GLubyte *ptr1 = PIXELADDR1( source, x, y ); + const GLubyte *ptr1 = PIXELADDR1( source, x, y ); + GLuint i; for (i=0;i<n;i++) { GLubyte p = *ptr1++; rgba[i][RCOMP] = p & 0xE0; @@ -4512,11 +4686,12 @@ static void read_color_span( const GLcontext *ctx, case PF_LOOKUP: case PF_GRAYSCALE: { - GLubyte *rTable = source->pixel_to_r; - GLubyte *gTable = source->pixel_to_g; - GLubyte *bTable = source->pixel_to_b; + const GLubyte *rTable = source->pixel_to_r; + const GLubyte *gTable = source->pixel_to_g; + const GLubyte *bTable = source->pixel_to_b; if (GET_VISUAL_DEPTH(xmesa->xm_visual)==8) { GLubyte *ptr1 = PIXELADDR1( source, x, y ); + GLuint i; for (i=0;i<n;i++) { unsigned long p = *ptr1++; rgba[i][RCOMP] = rTable[p]; @@ -4527,10 +4702,10 @@ static void read_color_span( const GLcontext *ctx, } else { XMesaImage *img = source->backimage; + GLuint i; y = FLIP(source, y); for (i=0;i<n;i++,x++) { - unsigned long p; - p = XMesaGetPixel( img, x, y ); + unsigned long p = XMesaGetPixel( img, x, y ); rgba[i][RCOMP] = rTable[p]; rgba[i][GCOMP] = gTable[p]; rgba[i][BCOMP] = bTable[p]; @@ -4543,6 +4718,7 @@ static void read_color_span( const GLcontext *ctx, { XMesaImage *img = source->backimage; int bitFlip = xmesa->xm_visual->bitFlip; + GLuint i; y = FLIP(source, y); for (i=0;i<n;i++,x++) { unsigned long p; @@ -4936,7 +5112,6 @@ static const GLubyte *get_string( GLcontext *ctx, GLenum name ) } - static void update_span_funcs( GLcontext *ctx ) { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; diff --git a/xc/extras/Mesa/src/X/xmesa3.c b/xc/extras/Mesa/src/X/xmesa3.c index ba98c5e1d..c7e4c21c8 100644 --- a/xc/extras/Mesa/src/X/xmesa3.c +++ b/xc/extras/Mesa/src/X/xmesa3.c @@ -66,7 +66,7 @@ static void draw_points_ANY_pixmap( GLcontext *ctx, GLuint first, GLuint last ) register int x, y; const GLubyte *color = VB->ColorPtr->data[i]; unsigned long pixel = xmesa_color_to_pixel( xmesa, - color[0], color[1], color[2], color[3] ); + color[0], color[1], color[2], color[3], xmesa->pixelformat); XMesaSetForeground( dpy, gc, pixel ); x = (GLint) VB->Win.data[i][0]; y = FLIP( xmesa->xm_buffer, (GLint) VB->Win.data[i][1] ); @@ -131,7 +131,8 @@ static void flat_pixmap_line( GLcontext *ctx, unsigned long pixel; if (xmesa->xm_visual->gl_visual->RGBAflag) { const GLubyte *color = VB->ColorPtr->data[pv]; - pixel = xmesa_color_to_pixel( xmesa, color[0], color[1], color[2], color[3] ); + pixel = xmesa_color_to_pixel( xmesa, color[0], color[1], color[2], color[3], + xmesa->pixelformat ); } else { pixel = VB->IndexPtr->data[pv]; @@ -353,6 +354,7 @@ static void flat_TRUECOLOR_z_line( GLcontext *ctx, #define INTERP_XY 1 #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define CLIP_HACK 1 #define PLOT(X,Y) \ if (Z < *zPtr) { \ @@ -375,6 +377,7 @@ static void flat_8A8B8G8R_z_line( GLcontext *ctx, GLuint pixel = PACK_8B8G8R( color[0], color[1], color[2] ); #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) @@ -400,6 +403,7 @@ static void flat_8R8G8B_z_line( GLcontext *ctx, GLuint pixel = PACK_8R8G8B( color[0], color[1], color[2] ); #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) @@ -424,6 +428,7 @@ static void flat_8R8G8B24_z_line( GLcontext *ctx, const GLubyte *color = ctx->VB->ColorPtr->data[pv]; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE bgr_t #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y) @@ -451,6 +456,7 @@ static void flat_5R6G5B_z_line( GLcontext *ctx, GLushort pixel = PACK_5R6G5B( color[0], color[1], color[2] ); #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) @@ -474,6 +480,7 @@ static void flat_DITHER_5R6G5B_z_line( GLcontext *ctx, const GLubyte *color = ctx->VB->ColorPtr->data[pv]; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) @@ -500,6 +507,7 @@ static void flat_DITHER8_z_line( GLcontext *ctx, #define INTERP_XY 1 #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) @@ -526,6 +534,7 @@ static void flat_LOOKUP8_z_line( GLcontext *ctx, pixel = (GLubyte) LOOKUP( color[0], color[1], color[2] ); #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) @@ -552,6 +561,7 @@ static void flat_HPCR_z_line( GLcontext *ctx, #define INTERP_XY 1 #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) @@ -670,6 +680,7 @@ line_func xmesa_get_line_func( GLcontext *ctx ) && ctx->RasterMask==DEPTH_BIT && ctx->Depth.Func==GL_LESS && ctx->Depth.Mask==GL_TRUE + && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS && ctx->Line.Width==1.0F) { switch (xmesa->pixelformat) { case PF_TRUECOLOR: diff --git a/xc/extras/Mesa/src/X/xmesa4.c b/xc/extras/Mesa/src/X/xmesa4.c index 844447595..195a531f0 100644 --- a/xc/extras/Mesa/src/X/xmesa4.c +++ b/xc/extras/Mesa/src/X/xmesa4.c @@ -66,8 +66,9 @@ static void flat_pixmap_triangle( GLcontext *ctx, unsigned long pixel; if (xmesa->xm_visual->gl_visual->RGBAflag) { pixel = xmesa_color_to_pixel( xmesa, - VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], - VB->ColorPtr->data[pv][2], VB->ColorPtr->data[pv][3] ); + VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], + VB->ColorPtr->data[pv][2], VB->ColorPtr->data[pv][3], + xmesa->pixelformat ); } else { pixel = VB->IndexPtr->data[pv]; @@ -97,6 +98,7 @@ static void smooth_TRUECOLOR_z_triangle( GLcontext *ctx, XMesaImage *img = xmesa->xm_buffer->backimage; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define INNER_LOOP( LEFT, RIGHT, Y ) \ { \ @@ -129,6 +131,7 @@ static void smooth_8A8B8G8R_z_triangle( GLcontext *ctx, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint @@ -161,6 +164,7 @@ static void smooth_8R8G8B_z_triangle( GLcontext *ctx, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint @@ -193,6 +197,7 @@ static void smooth_8R8G8B24_z_triangle( GLcontext *ctx, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE bgr_t @@ -228,6 +233,7 @@ static void smooth_TRUEDITHER_z_triangle( GLcontext *ctx, XMesaImage *img = xmesa->xm_buffer->backimage; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define INNER_LOOP( LEFT, RIGHT, Y ) \ { \ @@ -259,6 +265,7 @@ static void smooth_5R6G5B_z_triangle( GLcontext *ctx, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort @@ -267,7 +274,7 @@ static void smooth_5R6G5B_z_triangle( GLcontext *ctx, { \ GLint i, len = RIGHT-LEFT; \ for (i=0;i<len;i++) { \ - GLdepth z = FixedToDepth(ffz); \ + DEPTH_TYPE z = FixedToDepth(ffz); \ if (z < zRow[i]) { \ pRow[i] = PACK_5R6G5B( FixedToInt(ffr), FixedToInt(ffg), \ FixedToInt(ffb) ); \ @@ -291,6 +298,7 @@ static void smooth_DITHER_5R6G5B_z_triangle( GLcontext *ctx, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort @@ -323,6 +331,7 @@ static void smooth_DITHER8_z_triangle( GLcontext *ctx, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte @@ -357,6 +366,7 @@ static void smooth_DITHER_z_triangle( GLcontext *ctx, XMesaImage *img = xmesa->xm_buffer->backimage; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte @@ -390,6 +400,7 @@ static void smooth_LOOKUP8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte @@ -423,6 +434,7 @@ static void smooth_HPCR_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; (void) pv; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INTERP_RGB 1 #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte @@ -455,6 +467,7 @@ static void flat_TRUECOLOR_z_triangle( GLcontext *ctx, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define SETUP_CODE \ unsigned long pixel; \ PACK_TRUECOLOR(pixel, VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2]); @@ -483,6 +496,7 @@ static void flat_8A8B8G8R_z_triangle( GLcontext *ctx, GLuint v0, { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) @@ -513,6 +527,7 @@ static void flat_8R8G8B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR4(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLuint #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) @@ -544,6 +559,7 @@ static void flat_8R8G8B24_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; const GLubyte *color = ctx->VB->ColorPtr->data[pv]; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR3(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE bgr_t #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) @@ -575,6 +591,7 @@ static void flat_TRUEDITHER_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define INNER_LOOP( LEFT, RIGHT, Y ) \ { \ GLint i, xx = LEFT, yy = FLIP(xmesa->xm_buffer,Y), len = RIGHT-LEFT; \ @@ -602,6 +619,7 @@ static void flat_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) @@ -612,7 +630,7 @@ static void flat_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, { \ GLint i, len = RIGHT-LEFT; \ for (i=0;i<len;i++) { \ - GLdepth z = FixedToDepth(ffz); \ + DEPTH_TYPE z = FixedToDepth(ffz); \ if (z < zRow[i]) { \ pRow[i] = (PIXEL_TYPE) p; \ zRow[i] = z; \ @@ -633,6 +651,7 @@ static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; const GLubyte *color = ctx->VB->ColorPtr->data[pv]; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR2(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLushort #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) @@ -640,7 +659,7 @@ static void flat_DITHER_5R6G5B_z_triangle( GLcontext *ctx, GLuint v0, { \ GLint i, len = RIGHT-LEFT; \ for (i=0;i<len;i++) { \ - GLdepth z = FixedToDepth(ffz); \ + DEPTH_TYPE z = FixedToDepth(ffz); \ if (z < zRow[i]) { \ PACK_TRUEDITHER(pRow[i], LEFT+i, Y, color[RCOMP], \ color[GCOMP], color[BCOMP]); \ @@ -661,6 +680,7 @@ static void flat_DITHER8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) @@ -693,6 +713,7 @@ static void flat_DITHER_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; XMesaImage *img = xmesa->xm_buffer->backimage; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define SETUP_CODE \ FLAT_DITHER_SETUP( VB->ColorPtr->data[pv][0], VB->ColorPtr->data[pv][1], VB->ColorPtr->data[pv][2] ); @@ -722,6 +743,7 @@ static void flat_HPCR_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) @@ -753,6 +775,7 @@ static void flat_LOOKUP8_z_triangle( GLcontext *ctx, GLuint v0, GLuint v1, { XMesaContext xmesa = (XMesaContext) ctx->DriverCtx; #define INTERP_Z 1 +#define DEPTH_TYPE DEFAULT_SOFTWARE_DEPTH_TYPE #define PIXEL_ADDRESS(X,Y) PIXELADDR1(xmesa->xm_buffer,X,Y) #define PIXEL_TYPE GLubyte #define BYTES_PER_ROW (xmesa->xm_buffer->backimage->bytes_per_line) @@ -1432,6 +1455,7 @@ triangle_func xmesa_get_triangle_func( GLcontext *ctx ) && ctx->RasterMask==DEPTH_BIT && ctx->Depth.Func==GL_LESS && ctx->Depth.Mask==GL_TRUE + && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS && ctx->Polygon.StippleFlag==GL_FALSE) { switch (xmesa->pixelformat) { case PF_TRUECOLOR: @@ -1463,6 +1487,7 @@ triangle_func xmesa_get_triangle_func( GLcontext *ctx ) && ctx->RasterMask==DEPTH_BIT && ctx->Depth.Func==GL_LESS && ctx->Depth.Mask==GL_TRUE + && ctx->Visual->DepthBits == DEFAULT_SOFTWARE_DEPTH_BITS && ctx->Polygon.StippleFlag==GL_FALSE) { switch (xmesa->pixelformat) { case PF_TRUECOLOR: diff --git a/xc/extras/Mesa/src/X/xmesaP.h b/xc/extras/Mesa/src/X/xmesaP.h index 9b79f4314..987877509 100644 --- a/xc/extras/Mesa/src/X/xmesaP.h +++ b/xc/extras/Mesa/src/X/xmesaP.h @@ -85,6 +85,7 @@ struct xmesa_visual { GLint BitsPerPixel; /* True bits per pixel for XImages */ GLint level; /* 0=normal, 1=overlay, etc */ + GLint VisualCaveat; /* for GLX_EXT_visual_rating extension */ GLboolean ximage_flag; /* Use XImage for back buffer (not pixmap)? */ @@ -510,8 +511,9 @@ static int const kernel1[16] = { * External functions: */ -extern unsigned long xmesa_color_to_pixel( XMesaContext xmesa, - GLubyte r, GLubyte g, GLubyte b, GLubyte a ); +extern unsigned long +xmesa_color_to_pixel( XMesaContext xmesa, GLubyte r, GLubyte g, GLubyte b, GLubyte a, + GLuint pixelFormat ); extern void xmesa_alloc_back_buffer( XMesaBuffer b ); diff --git a/xc/extras/Mesa/src/X86/glapi_x86.S b/xc/extras/Mesa/src/X86/glapi_x86.S index a9566ea46..3afd50e0a 100644 --- a/xc/extras/Mesa/src/X86/glapi_x86.S +++ b/xc/extras/Mesa/src/X86/glapi_x86.S @@ -1,37 +1,4 @@ - -/* - * Mesa 3-D graphics library - * Version: 3.3 - * - * Copyright (C) 1999-2000 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. - */ - - -/* - * X86-optimized dispatch code contibuted by Josh Vanderhoof - * - * This file will be machine-generated from the gl.spec file at some point - * in the future. - */ - - +/* DO NOT EDIT - This file generated automatically with glx86asm.py script */ #include "assyntax.h" #include "glapioffsets.h" @@ -51,45 +18,22 @@ #define GLOBL_FN(x) GLOBL x #endif -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Accum)) -GL_PREFIX(Accum): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Accum)) - JMP(GL_OFFSET(_gloffset_Accum)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(AlphaFunc)) -GL_PREFIX(AlphaFunc): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_AlphaFunc)) - JMP(GL_OFFSET(_gloffset_AlphaFunc)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Begin)) -GL_PREFIX(Begin): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Begin)) - JMP(GL_OFFSET(_gloffset_Begin)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Bitmap)) -GL_PREFIX(Bitmap): +GLOBL_FN(GL_PREFIX(NewList)) +GL_PREFIX(NewList): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Bitmap)) - JMP(GL_OFFSET(_gloffset_Bitmap)) + JZ(GLNAME(_glapi_fallback_NewList)) + JMP(GL_OFFSET(_gloffset_NewList)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(BlendFunc)) -GL_PREFIX(BlendFunc): +GLOBL_FN(GL_PREFIX(EndList)) +GL_PREFIX(EndList): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_BlendFunc)) - JMP(GL_OFFSET(_gloffset_BlendFunc)) + JZ(GLNAME(_glapi_fallback_EndList)) + JMP(GL_OFFSET(_gloffset_EndList)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(CallList)) @@ -108,60 +52,44 @@ GL_PREFIX(CallLists): JMP(GL_OFFSET(_gloffset_CallLists)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Clear)) -GL_PREFIX(Clear): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Clear)) - JMP(GL_OFFSET(_gloffset_Clear)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ClearAccum)) -GL_PREFIX(ClearAccum): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ClearAccum)) - JMP(GL_OFFSET(_gloffset_ClearAccum)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ClearColor)) -GL_PREFIX(ClearColor): +GLOBL_FN(GL_PREFIX(DeleteLists)) +GL_PREFIX(DeleteLists): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ClearColor)) - JMP(GL_OFFSET(_gloffset_ClearColor)) + JZ(GLNAME(_glapi_fallback_DeleteLists)) + JMP(GL_OFFSET(_gloffset_DeleteLists)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ClearDepth)) -GL_PREFIX(ClearDepth): +GLOBL_FN(GL_PREFIX(GenLists)) +GL_PREFIX(GenLists): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ClearDepth)) - JMP(GL_OFFSET(_gloffset_ClearDepth)) + JZ(GLNAME(_glapi_fallback_GenLists)) + JMP(GL_OFFSET(_gloffset_GenLists)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ClearIndex)) -GL_PREFIX(ClearIndex): +GLOBL_FN(GL_PREFIX(ListBase)) +GL_PREFIX(ListBase): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ClearIndex)) - JMP(GL_OFFSET(_gloffset_ClearIndex)) + JZ(GLNAME(_glapi_fallback_ListBase)) + JMP(GL_OFFSET(_gloffset_ListBase)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ClearStencil)) -GL_PREFIX(ClearStencil): +GLOBL_FN(GL_PREFIX(Begin)) +GL_PREFIX(Begin): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ClearStencil)) - JMP(GL_OFFSET(_gloffset_ClearStencil)) + JZ(GLNAME(_glapi_fallback_Begin)) + JMP(GL_OFFSET(_gloffset_Begin)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ClipPlane)) -GL_PREFIX(ClipPlane): +GLOBL_FN(GL_PREFIX(Bitmap)) +GL_PREFIX(Bitmap): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ClipPlane)) - JMP(GL_OFFSET(_gloffset_ClipPlane)) + JZ(GLNAME(_glapi_fallback_Bitmap)) + JMP(GL_OFFSET(_gloffset_Bitmap)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color3b)) @@ -172,6 +100,14 @@ GL_PREFIX(Color3b): JMP(GL_OFFSET(_gloffset_Color3b)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color3bv)) +GL_PREFIX(Color3bv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color3bv)) + JMP(GL_OFFSET(_gloffset_Color3bv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color3d)) GL_PREFIX(Color3d): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -180,6 +116,14 @@ GL_PREFIX(Color3d): JMP(GL_OFFSET(_gloffset_Color3d)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color3dv)) +GL_PREFIX(Color3dv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color3dv)) + JMP(GL_OFFSET(_gloffset_Color3dv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color3f)) GL_PREFIX(Color3f): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -188,6 +132,14 @@ GL_PREFIX(Color3f): JMP(GL_OFFSET(_gloffset_Color3f)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color3fv)) +GL_PREFIX(Color3fv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color3fv)) + JMP(GL_OFFSET(_gloffset_Color3fv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color3i)) GL_PREFIX(Color3i): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -196,6 +148,14 @@ GL_PREFIX(Color3i): JMP(GL_OFFSET(_gloffset_Color3i)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color3iv)) +GL_PREFIX(Color3iv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color3iv)) + JMP(GL_OFFSET(_gloffset_Color3iv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color3s)) GL_PREFIX(Color3s): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -204,6 +164,14 @@ GL_PREFIX(Color3s): JMP(GL_OFFSET(_gloffset_Color3s)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color3sv)) +GL_PREFIX(Color3sv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color3sv)) + JMP(GL_OFFSET(_gloffset_Color3sv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color3ub)) GL_PREFIX(Color3ub): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -212,6 +180,14 @@ GL_PREFIX(Color3ub): JMP(GL_OFFSET(_gloffset_Color3ub)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color3ubv)) +GL_PREFIX(Color3ubv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color3ubv)) + JMP(GL_OFFSET(_gloffset_Color3ubv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color3ui)) GL_PREFIX(Color3ui): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -220,6 +196,14 @@ GL_PREFIX(Color3ui): JMP(GL_OFFSET(_gloffset_Color3ui)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color3uiv)) +GL_PREFIX(Color3uiv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color3uiv)) + JMP(GL_OFFSET(_gloffset_Color3uiv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color3us)) GL_PREFIX(Color3us): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -228,6 +212,14 @@ GL_PREFIX(Color3us): JMP(GL_OFFSET(_gloffset_Color3us)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color3usv)) +GL_PREFIX(Color3usv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color3usv)) + JMP(GL_OFFSET(_gloffset_Color3usv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color4b)) GL_PREFIX(Color4b): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -236,6 +228,14 @@ GL_PREFIX(Color4b): JMP(GL_OFFSET(_gloffset_Color4b)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color4bv)) +GL_PREFIX(Color4bv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color4bv)) + JMP(GL_OFFSET(_gloffset_Color4bv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color4d)) GL_PREFIX(Color4d): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -244,6 +244,14 @@ GL_PREFIX(Color4d): JMP(GL_OFFSET(_gloffset_Color4d)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color4dv)) +GL_PREFIX(Color4dv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color4dv)) + JMP(GL_OFFSET(_gloffset_Color4dv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color4f)) GL_PREFIX(Color4f): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -252,6 +260,14 @@ GL_PREFIX(Color4f): JMP(GL_OFFSET(_gloffset_Color4f)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color4fv)) +GL_PREFIX(Color4fv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color4fv)) + JMP(GL_OFFSET(_gloffset_Color4fv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color4i)) GL_PREFIX(Color4i): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -260,6 +276,14 @@ GL_PREFIX(Color4i): JMP(GL_OFFSET(_gloffset_Color4i)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color4iv)) +GL_PREFIX(Color4iv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color4iv)) + JMP(GL_OFFSET(_gloffset_Color4iv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color4s)) GL_PREFIX(Color4s): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -268,6 +292,14 @@ GL_PREFIX(Color4s): JMP(GL_OFFSET(_gloffset_Color4s)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color4sv)) +GL_PREFIX(Color4sv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color4sv)) + JMP(GL_OFFSET(_gloffset_Color4sv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color4ub)) GL_PREFIX(Color4ub): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -276,6 +308,14 @@ GL_PREFIX(Color4ub): JMP(GL_OFFSET(_gloffset_Color4ub)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(Color4ubv)) +GL_PREFIX(Color4ubv): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_Color4ubv)) + JMP(GL_OFFSET(_gloffset_Color4ubv)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Color4ui)) GL_PREFIX(Color4ui): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -284,2260 +324,2260 @@ GL_PREFIX(Color4ui): JMP(GL_OFFSET(_gloffset_Color4ui)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4us)) -GL_PREFIX(Color4us): +GLOBL_FN(GL_PREFIX(Color4uiv)) +GL_PREFIX(Color4uiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4us)) - JMP(GL_OFFSET(_gloffset_Color4us)) + JZ(GLNAME(_glapi_fallback_Color4uiv)) + JMP(GL_OFFSET(_gloffset_Color4uiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color3bv)) -GL_PREFIX(Color3bv): +GLOBL_FN(GL_PREFIX(Color4us)) +GL_PREFIX(Color4us): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color3bv)) - JMP(GL_OFFSET(_gloffset_Color3bv)) + JZ(GLNAME(_glapi_fallback_Color4us)) + JMP(GL_OFFSET(_gloffset_Color4us)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color3dv)) -GL_PREFIX(Color3dv): +GLOBL_FN(GL_PREFIX(Color4usv)) +GL_PREFIX(Color4usv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color3dv)) - JMP(GL_OFFSET(_gloffset_Color3dv)) + JZ(GLNAME(_glapi_fallback_Color4usv)) + JMP(GL_OFFSET(_gloffset_Color4usv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color3fv)) -GL_PREFIX(Color3fv): +GLOBL_FN(GL_PREFIX(EdgeFlag)) +GL_PREFIX(EdgeFlag): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color3fv)) - JMP(GL_OFFSET(_gloffset_Color3fv)) + JZ(GLNAME(_glapi_fallback_EdgeFlag)) + JMP(GL_OFFSET(_gloffset_EdgeFlag)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color3iv)) -GL_PREFIX(Color3iv): +GLOBL_FN(GL_PREFIX(EdgeFlagv)) +GL_PREFIX(EdgeFlagv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color3iv)) - JMP(GL_OFFSET(_gloffset_Color3iv)) + JZ(GLNAME(_glapi_fallback_EdgeFlagv)) + JMP(GL_OFFSET(_gloffset_EdgeFlagv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color3sv)) -GL_PREFIX(Color3sv): +GLOBL_FN(GL_PREFIX(End)) +GL_PREFIX(End): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color3sv)) - JMP(GL_OFFSET(_gloffset_Color3sv)) + JZ(GLNAME(_glapi_fallback_End)) + JMP(GL_OFFSET(_gloffset_End)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color3ubv)) -GL_PREFIX(Color3ubv): +GLOBL_FN(GL_PREFIX(Indexd)) +GL_PREFIX(Indexd): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color3ubv)) - JMP(GL_OFFSET(_gloffset_Color3ubv)) + JZ(GLNAME(_glapi_fallback_Indexd)) + JMP(GL_OFFSET(_gloffset_Indexd)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color3uiv)) -GL_PREFIX(Color3uiv): +GLOBL_FN(GL_PREFIX(Indexdv)) +GL_PREFIX(Indexdv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color3uiv)) - JMP(GL_OFFSET(_gloffset_Color3uiv)) + JZ(GLNAME(_glapi_fallback_Indexdv)) + JMP(GL_OFFSET(_gloffset_Indexdv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color3usv)) -GL_PREFIX(Color3usv): +GLOBL_FN(GL_PREFIX(Indexf)) +GL_PREFIX(Indexf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color3usv)) - JMP(GL_OFFSET(_gloffset_Color3usv)) + JZ(GLNAME(_glapi_fallback_Indexf)) + JMP(GL_OFFSET(_gloffset_Indexf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4bv)) -GL_PREFIX(Color4bv): +GLOBL_FN(GL_PREFIX(Indexfv)) +GL_PREFIX(Indexfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4bv)) - JMP(GL_OFFSET(_gloffset_Color4bv)) + JZ(GLNAME(_glapi_fallback_Indexfv)) + JMP(GL_OFFSET(_gloffset_Indexfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4dv)) -GL_PREFIX(Color4dv): +GLOBL_FN(GL_PREFIX(Indexi)) +GL_PREFIX(Indexi): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4dv)) - JMP(GL_OFFSET(_gloffset_Color4dv)) + JZ(GLNAME(_glapi_fallback_Indexi)) + JMP(GL_OFFSET(_gloffset_Indexi)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4fv)) -GL_PREFIX(Color4fv): +GLOBL_FN(GL_PREFIX(Indexiv)) +GL_PREFIX(Indexiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4fv)) - JMP(GL_OFFSET(_gloffset_Color4fv)) + JZ(GLNAME(_glapi_fallback_Indexiv)) + JMP(GL_OFFSET(_gloffset_Indexiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4iv)) -GL_PREFIX(Color4iv): +GLOBL_FN(GL_PREFIX(Indexs)) +GL_PREFIX(Indexs): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4iv)) - JMP(GL_OFFSET(_gloffset_Color4iv)) + JZ(GLNAME(_glapi_fallback_Indexs)) + JMP(GL_OFFSET(_gloffset_Indexs)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4sv)) -GL_PREFIX(Color4sv): +GLOBL_FN(GL_PREFIX(Indexsv)) +GL_PREFIX(Indexsv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4sv)) - JMP(GL_OFFSET(_gloffset_Color4sv)) + JZ(GLNAME(_glapi_fallback_Indexsv)) + JMP(GL_OFFSET(_gloffset_Indexsv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4ubv)) -GL_PREFIX(Color4ubv): +GLOBL_FN(GL_PREFIX(Normal3b)) +GL_PREFIX(Normal3b): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4ubv)) - JMP(GL_OFFSET(_gloffset_Color4ubv)) + JZ(GLNAME(_glapi_fallback_Normal3b)) + JMP(GL_OFFSET(_gloffset_Normal3b)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4uiv)) -GL_PREFIX(Color4uiv): +GLOBL_FN(GL_PREFIX(Normal3bv)) +GL_PREFIX(Normal3bv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4uiv)) - JMP(GL_OFFSET(_gloffset_Color4uiv)) + JZ(GLNAME(_glapi_fallback_Normal3bv)) + JMP(GL_OFFSET(_gloffset_Normal3bv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Color4usv)) -GL_PREFIX(Color4usv): +GLOBL_FN(GL_PREFIX(Normal3d)) +GL_PREFIX(Normal3d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Color4usv)) - JMP(GL_OFFSET(_gloffset_Color4usv)) + JZ(GLNAME(_glapi_fallback_Normal3d)) + JMP(GL_OFFSET(_gloffset_Normal3d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorMask)) -GL_PREFIX(ColorMask): +GLOBL_FN(GL_PREFIX(Normal3dv)) +GL_PREFIX(Normal3dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorMask)) - JMP(GL_OFFSET(_gloffset_ColorMask)) + JZ(GLNAME(_glapi_fallback_Normal3dv)) + JMP(GL_OFFSET(_gloffset_Normal3dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorMaterial)) -GL_PREFIX(ColorMaterial): +GLOBL_FN(GL_PREFIX(Normal3f)) +GL_PREFIX(Normal3f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorMaterial)) - JMP(GL_OFFSET(_gloffset_ColorMaterial)) + JZ(GLNAME(_glapi_fallback_Normal3f)) + JMP(GL_OFFSET(_gloffset_Normal3f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CopyPixels)) -GL_PREFIX(CopyPixels): +GLOBL_FN(GL_PREFIX(Normal3fv)) +GL_PREFIX(Normal3fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyPixels)) - JMP(GL_OFFSET(_gloffset_CopyPixels)) + JZ(GLNAME(_glapi_fallback_Normal3fv)) + JMP(GL_OFFSET(_gloffset_Normal3fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CullFace)) -GL_PREFIX(CullFace): +GLOBL_FN(GL_PREFIX(Normal3i)) +GL_PREFIX(Normal3i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CullFace)) - JMP(GL_OFFSET(_gloffset_CullFace)) + JZ(GLNAME(_glapi_fallback_Normal3i)) + JMP(GL_OFFSET(_gloffset_Normal3i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DepthFunc)) -GL_PREFIX(DepthFunc): +GLOBL_FN(GL_PREFIX(Normal3iv)) +GL_PREFIX(Normal3iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DepthFunc)) - JMP(GL_OFFSET(_gloffset_DepthFunc)) + JZ(GLNAME(_glapi_fallback_Normal3iv)) + JMP(GL_OFFSET(_gloffset_Normal3iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DepthMask)) -GL_PREFIX(DepthMask): +GLOBL_FN(GL_PREFIX(Normal3s)) +GL_PREFIX(Normal3s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DepthMask)) - JMP(GL_OFFSET(_gloffset_DepthMask)) + JZ(GLNAME(_glapi_fallback_Normal3s)) + JMP(GL_OFFSET(_gloffset_Normal3s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DepthRange)) -GL_PREFIX(DepthRange): +GLOBL_FN(GL_PREFIX(Normal3sv)) +GL_PREFIX(Normal3sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DepthRange)) - JMP(GL_OFFSET(_gloffset_DepthRange)) + JZ(GLNAME(_glapi_fallback_Normal3sv)) + JMP(GL_OFFSET(_gloffset_Normal3sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DeleteLists)) -GL_PREFIX(DeleteLists): +GLOBL_FN(GL_PREFIX(RasterPos2d)) +GL_PREFIX(RasterPos2d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DeleteLists)) - JMP(GL_OFFSET(_gloffset_DeleteLists)) + JZ(GLNAME(_glapi_fallback_RasterPos2d)) + JMP(GL_OFFSET(_gloffset_RasterPos2d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Disable)) -GL_PREFIX(Disable): +GLOBL_FN(GL_PREFIX(RasterPos2dv)) +GL_PREFIX(RasterPos2dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Disable)) - JMP(GL_OFFSET(_gloffset_Disable)) + JZ(GLNAME(_glapi_fallback_RasterPos2dv)) + JMP(GL_OFFSET(_gloffset_RasterPos2dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DrawBuffer)) -GL_PREFIX(DrawBuffer): +GLOBL_FN(GL_PREFIX(RasterPos2f)) +GL_PREFIX(RasterPos2f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DrawBuffer)) - JMP(GL_OFFSET(_gloffset_DrawBuffer)) + JZ(GLNAME(_glapi_fallback_RasterPos2f)) + JMP(GL_OFFSET(_gloffset_RasterPos2f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DrawElements)) -GL_PREFIX(DrawElements): +GLOBL_FN(GL_PREFIX(RasterPos2fv)) +GL_PREFIX(RasterPos2fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DrawElements)) - JMP(GL_OFFSET(_gloffset_DrawElements)) + JZ(GLNAME(_glapi_fallback_RasterPos2fv)) + JMP(GL_OFFSET(_gloffset_RasterPos2fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DrawPixels)) -GL_PREFIX(DrawPixels): +GLOBL_FN(GL_PREFIX(RasterPos2i)) +GL_PREFIX(RasterPos2i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DrawPixels)) - JMP(GL_OFFSET(_gloffset_DrawPixels)) + JZ(GLNAME(_glapi_fallback_RasterPos2i)) + JMP(GL_OFFSET(_gloffset_RasterPos2i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Enable)) -GL_PREFIX(Enable): +GLOBL_FN(GL_PREFIX(RasterPos2iv)) +GL_PREFIX(RasterPos2iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Enable)) - JMP(GL_OFFSET(_gloffset_Enable)) + JZ(GLNAME(_glapi_fallback_RasterPos2iv)) + JMP(GL_OFFSET(_gloffset_RasterPos2iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(End)) -GL_PREFIX(End): +GLOBL_FN(GL_PREFIX(RasterPos2s)) +GL_PREFIX(RasterPos2s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_End)) - JMP(GL_OFFSET(_gloffset_End)) + JZ(GLNAME(_glapi_fallback_RasterPos2s)) + JMP(GL_OFFSET(_gloffset_RasterPos2s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EndList)) -GL_PREFIX(EndList): +GLOBL_FN(GL_PREFIX(RasterPos2sv)) +GL_PREFIX(RasterPos2sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EndList)) - JMP(GL_OFFSET(_gloffset_EndList)) + JZ(GLNAME(_glapi_fallback_RasterPos2sv)) + JMP(GL_OFFSET(_gloffset_RasterPos2sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalCoord1d)) -GL_PREFIX(EvalCoord1d): +GLOBL_FN(GL_PREFIX(RasterPos3d)) +GL_PREFIX(RasterPos3d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalCoord1d)) - JMP(GL_OFFSET(_gloffset_EvalCoord1d)) + JZ(GLNAME(_glapi_fallback_RasterPos3d)) + JMP(GL_OFFSET(_gloffset_RasterPos3d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalCoord1f)) -GL_PREFIX(EvalCoord1f): +GLOBL_FN(GL_PREFIX(RasterPos3dv)) +GL_PREFIX(RasterPos3dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalCoord1f)) - JMP(GL_OFFSET(_gloffset_EvalCoord1f)) + JZ(GLNAME(_glapi_fallback_RasterPos3dv)) + JMP(GL_OFFSET(_gloffset_RasterPos3dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalCoord1dv)) -GL_PREFIX(EvalCoord1dv): +GLOBL_FN(GL_PREFIX(RasterPos3f)) +GL_PREFIX(RasterPos3f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalCoord1dv)) - JMP(GL_OFFSET(_gloffset_EvalCoord1dv)) + JZ(GLNAME(_glapi_fallback_RasterPos3f)) + JMP(GL_OFFSET(_gloffset_RasterPos3f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalCoord1fv)) -GL_PREFIX(EvalCoord1fv): +GLOBL_FN(GL_PREFIX(RasterPos3fv)) +GL_PREFIX(RasterPos3fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalCoord1fv)) - JMP(GL_OFFSET(_gloffset_EvalCoord1fv)) + JZ(GLNAME(_glapi_fallback_RasterPos3fv)) + JMP(GL_OFFSET(_gloffset_RasterPos3fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalCoord2d)) -GL_PREFIX(EvalCoord2d): +GLOBL_FN(GL_PREFIX(RasterPos3i)) +GL_PREFIX(RasterPos3i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalCoord2d)) - JMP(GL_OFFSET(_gloffset_EvalCoord2d)) + JZ(GLNAME(_glapi_fallback_RasterPos3i)) + JMP(GL_OFFSET(_gloffset_RasterPos3i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalCoord2f)) -GL_PREFIX(EvalCoord2f): +GLOBL_FN(GL_PREFIX(RasterPos3iv)) +GL_PREFIX(RasterPos3iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalCoord2f)) - JMP(GL_OFFSET(_gloffset_EvalCoord2f)) + JZ(GLNAME(_glapi_fallback_RasterPos3iv)) + JMP(GL_OFFSET(_gloffset_RasterPos3iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalCoord2dv)) -GL_PREFIX(EvalCoord2dv): +GLOBL_FN(GL_PREFIX(RasterPos3s)) +GL_PREFIX(RasterPos3s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalCoord2dv)) - JMP(GL_OFFSET(_gloffset_EvalCoord2dv)) + JZ(GLNAME(_glapi_fallback_RasterPos3s)) + JMP(GL_OFFSET(_gloffset_RasterPos3s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalCoord2fv)) -GL_PREFIX(EvalCoord2fv): +GLOBL_FN(GL_PREFIX(RasterPos3sv)) +GL_PREFIX(RasterPos3sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalCoord2fv)) - JMP(GL_OFFSET(_gloffset_EvalCoord2fv)) + JZ(GLNAME(_glapi_fallback_RasterPos3sv)) + JMP(GL_OFFSET(_gloffset_RasterPos3sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalPoint1)) -GL_PREFIX(EvalPoint1): +GLOBL_FN(GL_PREFIX(RasterPos4d)) +GL_PREFIX(RasterPos4d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalPoint1)) - JMP(GL_OFFSET(_gloffset_EvalPoint1)) + JZ(GLNAME(_glapi_fallback_RasterPos4d)) + JMP(GL_OFFSET(_gloffset_RasterPos4d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalPoint2)) -GL_PREFIX(EvalPoint2): +GLOBL_FN(GL_PREFIX(RasterPos4dv)) +GL_PREFIX(RasterPos4dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalPoint2)) - JMP(GL_OFFSET(_gloffset_EvalPoint2)) + JZ(GLNAME(_glapi_fallback_RasterPos4dv)) + JMP(GL_OFFSET(_gloffset_RasterPos4dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalMesh1)) -GL_PREFIX(EvalMesh1): +GLOBL_FN(GL_PREFIX(RasterPos4f)) +GL_PREFIX(RasterPos4f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalMesh1)) - JMP(GL_OFFSET(_gloffset_EvalMesh1)) + JZ(GLNAME(_glapi_fallback_RasterPos4f)) + JMP(GL_OFFSET(_gloffset_RasterPos4f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EdgeFlag)) -GL_PREFIX(EdgeFlag): +GLOBL_FN(GL_PREFIX(RasterPos4fv)) +GL_PREFIX(RasterPos4fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EdgeFlag)) - JMP(GL_OFFSET(_gloffset_EdgeFlag)) + JZ(GLNAME(_glapi_fallback_RasterPos4fv)) + JMP(GL_OFFSET(_gloffset_RasterPos4fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EdgeFlagv)) -GL_PREFIX(EdgeFlagv): +GLOBL_FN(GL_PREFIX(RasterPos4i)) +GL_PREFIX(RasterPos4i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EdgeFlagv)) - JMP(GL_OFFSET(_gloffset_EdgeFlagv)) + JZ(GLNAME(_glapi_fallback_RasterPos4i)) + JMP(GL_OFFSET(_gloffset_RasterPos4i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EvalMesh2)) -GL_PREFIX(EvalMesh2): +GLOBL_FN(GL_PREFIX(RasterPos4iv)) +GL_PREFIX(RasterPos4iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EvalMesh2)) - JMP(GL_OFFSET(_gloffset_EvalMesh2)) + JZ(GLNAME(_glapi_fallback_RasterPos4iv)) + JMP(GL_OFFSET(_gloffset_RasterPos4iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(FeedbackBuffer)) -GL_PREFIX(FeedbackBuffer): +GLOBL_FN(GL_PREFIX(RasterPos4s)) +GL_PREFIX(RasterPos4s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_FeedbackBuffer)) - JMP(GL_OFFSET(_gloffset_FeedbackBuffer)) + JZ(GLNAME(_glapi_fallback_RasterPos4s)) + JMP(GL_OFFSET(_gloffset_RasterPos4s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Finish)) -GL_PREFIX(Finish): +GLOBL_FN(GL_PREFIX(RasterPos4sv)) +GL_PREFIX(RasterPos4sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Finish)) - JMP(GL_OFFSET(_gloffset_Finish)) + JZ(GLNAME(_glapi_fallback_RasterPos4sv)) + JMP(GL_OFFSET(_gloffset_RasterPos4sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Flush)) -GL_PREFIX(Flush): +GLOBL_FN(GL_PREFIX(Rectd)) +GL_PREFIX(Rectd): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Flush)) - JMP(GL_OFFSET(_gloffset_Flush)) + JZ(GLNAME(_glapi_fallback_Rectd)) + JMP(GL_OFFSET(_gloffset_Rectd)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Fogf)) -GL_PREFIX(Fogf): +GLOBL_FN(GL_PREFIX(Rectdv)) +GL_PREFIX(Rectdv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Fogf)) - JMP(GL_OFFSET(_gloffset_Fogf)) + JZ(GLNAME(_glapi_fallback_Rectdv)) + JMP(GL_OFFSET(_gloffset_Rectdv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Fogi)) -GL_PREFIX(Fogi): +GLOBL_FN(GL_PREFIX(Rectf)) +GL_PREFIX(Rectf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Fogi)) - JMP(GL_OFFSET(_gloffset_Fogi)) + JZ(GLNAME(_glapi_fallback_Rectf)) + JMP(GL_OFFSET(_gloffset_Rectf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Fogfv)) -GL_PREFIX(Fogfv): +GLOBL_FN(GL_PREFIX(Rectfv)) +GL_PREFIX(Rectfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Fogfv)) - JMP(GL_OFFSET(_gloffset_Fogfv)) + JZ(GLNAME(_glapi_fallback_Rectfv)) + JMP(GL_OFFSET(_gloffset_Rectfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Fogiv)) -GL_PREFIX(Fogiv): +GLOBL_FN(GL_PREFIX(Recti)) +GL_PREFIX(Recti): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Fogiv)) - JMP(GL_OFFSET(_gloffset_Fogiv)) + JZ(GLNAME(_glapi_fallback_Recti)) + JMP(GL_OFFSET(_gloffset_Recti)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(FrontFace)) -GL_PREFIX(FrontFace): +GLOBL_FN(GL_PREFIX(Rectiv)) +GL_PREFIX(Rectiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_FrontFace)) - JMP(GL_OFFSET(_gloffset_FrontFace)) + JZ(GLNAME(_glapi_fallback_Rectiv)) + JMP(GL_OFFSET(_gloffset_Rectiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Frustum)) -GL_PREFIX(Frustum): +GLOBL_FN(GL_PREFIX(Rects)) +GL_PREFIX(Rects): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Frustum)) - JMP(GL_OFFSET(_gloffset_Frustum)) + JZ(GLNAME(_glapi_fallback_Rects)) + JMP(GL_OFFSET(_gloffset_Rects)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GenLists)) -GL_PREFIX(GenLists): +GLOBL_FN(GL_PREFIX(Rectsv)) +GL_PREFIX(Rectsv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GenLists)) - JMP(GL_OFFSET(_gloffset_GenLists)) + JZ(GLNAME(_glapi_fallback_Rectsv)) + JMP(GL_OFFSET(_gloffset_Rectsv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetBooleanv)) -GL_PREFIX(GetBooleanv): +GLOBL_FN(GL_PREFIX(TexCoord1d)) +GL_PREFIX(TexCoord1d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetBooleanv)) - JMP(GL_OFFSET(_gloffset_GetBooleanv)) + JZ(GLNAME(_glapi_fallback_TexCoord1d)) + JMP(GL_OFFSET(_gloffset_TexCoord1d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetClipPlane)) -GL_PREFIX(GetClipPlane): +GLOBL_FN(GL_PREFIX(TexCoord1dv)) +GL_PREFIX(TexCoord1dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetClipPlane)) - JMP(GL_OFFSET(_gloffset_GetClipPlane)) + JZ(GLNAME(_glapi_fallback_TexCoord1dv)) + JMP(GL_OFFSET(_gloffset_TexCoord1dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetDoublev)) -GL_PREFIX(GetDoublev): +GLOBL_FN(GL_PREFIX(TexCoord1f)) +GL_PREFIX(TexCoord1f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetDoublev)) - JMP(GL_OFFSET(_gloffset_GetDoublev)) + JZ(GLNAME(_glapi_fallback_TexCoord1f)) + JMP(GL_OFFSET(_gloffset_TexCoord1f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetError)) -GL_PREFIX(GetError): +GLOBL_FN(GL_PREFIX(TexCoord1fv)) +GL_PREFIX(TexCoord1fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetError)) - JMP(GL_OFFSET(_gloffset_GetError)) + JZ(GLNAME(_glapi_fallback_TexCoord1fv)) + JMP(GL_OFFSET(_gloffset_TexCoord1fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetFloatv)) -GL_PREFIX(GetFloatv): +GLOBL_FN(GL_PREFIX(TexCoord1i)) +GL_PREFIX(TexCoord1i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetFloatv)) - JMP(GL_OFFSET(_gloffset_GetFloatv)) + JZ(GLNAME(_glapi_fallback_TexCoord1i)) + JMP(GL_OFFSET(_gloffset_TexCoord1i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetIntegerv)) -GL_PREFIX(GetIntegerv): +GLOBL_FN(GL_PREFIX(TexCoord1iv)) +GL_PREFIX(TexCoord1iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetIntegerv)) - JMP(GL_OFFSET(_gloffset_GetIntegerv)) + JZ(GLNAME(_glapi_fallback_TexCoord1iv)) + JMP(GL_OFFSET(_gloffset_TexCoord1iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetLightfv)) -GL_PREFIX(GetLightfv): +GLOBL_FN(GL_PREFIX(TexCoord1s)) +GL_PREFIX(TexCoord1s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetLightfv)) - JMP(GL_OFFSET(_gloffset_GetLightfv)) + JZ(GLNAME(_glapi_fallback_TexCoord1s)) + JMP(GL_OFFSET(_gloffset_TexCoord1s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetLightiv)) -GL_PREFIX(GetLightiv): +GLOBL_FN(GL_PREFIX(TexCoord1sv)) +GL_PREFIX(TexCoord1sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetLightiv)) - JMP(GL_OFFSET(_gloffset_GetLightiv)) + JZ(GLNAME(_glapi_fallback_TexCoord1sv)) + JMP(GL_OFFSET(_gloffset_TexCoord1sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetMapdv)) -GL_PREFIX(GetMapdv): +GLOBL_FN(GL_PREFIX(TexCoord2d)) +GL_PREFIX(TexCoord2d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetMapdv)) - JMP(GL_OFFSET(_gloffset_GetMapdv)) + JZ(GLNAME(_glapi_fallback_TexCoord2d)) + JMP(GL_OFFSET(_gloffset_TexCoord2d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetMapfv)) -GL_PREFIX(GetMapfv): +GLOBL_FN(GL_PREFIX(TexCoord2dv)) +GL_PREFIX(TexCoord2dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetMapfv)) - JMP(GL_OFFSET(_gloffset_GetMapfv)) + JZ(GLNAME(_glapi_fallback_TexCoord2dv)) + JMP(GL_OFFSET(_gloffset_TexCoord2dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetMapiv)) -GL_PREFIX(GetMapiv): +GLOBL_FN(GL_PREFIX(TexCoord2f)) +GL_PREFIX(TexCoord2f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetMapiv)) - JMP(GL_OFFSET(_gloffset_GetMapiv)) + JZ(GLNAME(_glapi_fallback_TexCoord2f)) + JMP(GL_OFFSET(_gloffset_TexCoord2f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetMaterialfv)) -GL_PREFIX(GetMaterialfv): +GLOBL_FN(GL_PREFIX(TexCoord2fv)) +GL_PREFIX(TexCoord2fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetMaterialfv)) - JMP(GL_OFFSET(_gloffset_GetMaterialfv)) + JZ(GLNAME(_glapi_fallback_TexCoord2fv)) + JMP(GL_OFFSET(_gloffset_TexCoord2fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetMaterialiv)) -GL_PREFIX(GetMaterialiv): +GLOBL_FN(GL_PREFIX(TexCoord2i)) +GL_PREFIX(TexCoord2i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetMaterialiv)) - JMP(GL_OFFSET(_gloffset_GetMaterialiv)) + JZ(GLNAME(_glapi_fallback_TexCoord2i)) + JMP(GL_OFFSET(_gloffset_TexCoord2i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetPixelMapfv)) -GL_PREFIX(GetPixelMapfv): +GLOBL_FN(GL_PREFIX(TexCoord2iv)) +GL_PREFIX(TexCoord2iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetPixelMapfv)) - JMP(GL_OFFSET(_gloffset_GetPixelMapfv)) + JZ(GLNAME(_glapi_fallback_TexCoord2iv)) + JMP(GL_OFFSET(_gloffset_TexCoord2iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetPixelMapuiv)) -GL_PREFIX(GetPixelMapuiv): +GLOBL_FN(GL_PREFIX(TexCoord2s)) +GL_PREFIX(TexCoord2s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetPixelMapuiv)) - JMP(GL_OFFSET(_gloffset_GetPixelMapuiv)) + JZ(GLNAME(_glapi_fallback_TexCoord2s)) + JMP(GL_OFFSET(_gloffset_TexCoord2s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetPixelMapusv)) -GL_PREFIX(GetPixelMapusv): +GLOBL_FN(GL_PREFIX(TexCoord2sv)) +GL_PREFIX(TexCoord2sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetPixelMapusv)) - JMP(GL_OFFSET(_gloffset_GetPixelMapusv)) + JZ(GLNAME(_glapi_fallback_TexCoord2sv)) + JMP(GL_OFFSET(_gloffset_TexCoord2sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetPolygonStipple)) -GL_PREFIX(GetPolygonStipple): +GLOBL_FN(GL_PREFIX(TexCoord3d)) +GL_PREFIX(TexCoord3d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetPolygonStipple)) - JMP(GL_OFFSET(_gloffset_GetPolygonStipple)) + JZ(GLNAME(_glapi_fallback_TexCoord3d)) + JMP(GL_OFFSET(_gloffset_TexCoord3d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetString)) -GL_PREFIX(GetString): +GLOBL_FN(GL_PREFIX(TexCoord3dv)) +GL_PREFIX(TexCoord3dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetString)) - JMP(GL_OFFSET(_gloffset_GetString)) + JZ(GLNAME(_glapi_fallback_TexCoord3dv)) + JMP(GL_OFFSET(_gloffset_TexCoord3dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexEnvfv)) -GL_PREFIX(GetTexEnvfv): +GLOBL_FN(GL_PREFIX(TexCoord3f)) +GL_PREFIX(TexCoord3f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexEnvfv)) - JMP(GL_OFFSET(_gloffset_GetTexEnvfv)) + JZ(GLNAME(_glapi_fallback_TexCoord3f)) + JMP(GL_OFFSET(_gloffset_TexCoord3f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexEnviv)) -GL_PREFIX(GetTexEnviv): +GLOBL_FN(GL_PREFIX(TexCoord3fv)) +GL_PREFIX(TexCoord3fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexEnviv)) - JMP(GL_OFFSET(_gloffset_GetTexEnviv)) + JZ(GLNAME(_glapi_fallback_TexCoord3fv)) + JMP(GL_OFFSET(_gloffset_TexCoord3fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexGeniv)) -GL_PREFIX(GetTexGeniv): +GLOBL_FN(GL_PREFIX(TexCoord3i)) +GL_PREFIX(TexCoord3i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexGeniv)) - JMP(GL_OFFSET(_gloffset_GetTexGeniv)) + JZ(GLNAME(_glapi_fallback_TexCoord3i)) + JMP(GL_OFFSET(_gloffset_TexCoord3i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexGendv)) -GL_PREFIX(GetTexGendv): +GLOBL_FN(GL_PREFIX(TexCoord3iv)) +GL_PREFIX(TexCoord3iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexGendv)) - JMP(GL_OFFSET(_gloffset_GetTexGendv)) + JZ(GLNAME(_glapi_fallback_TexCoord3iv)) + JMP(GL_OFFSET(_gloffset_TexCoord3iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexGenfv)) -GL_PREFIX(GetTexGenfv): +GLOBL_FN(GL_PREFIX(TexCoord3s)) +GL_PREFIX(TexCoord3s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexGenfv)) - JMP(GL_OFFSET(_gloffset_GetTexGenfv)) + JZ(GLNAME(_glapi_fallback_TexCoord3s)) + JMP(GL_OFFSET(_gloffset_TexCoord3s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexImage)) -GL_PREFIX(GetTexImage): +GLOBL_FN(GL_PREFIX(TexCoord3sv)) +GL_PREFIX(TexCoord3sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexImage)) - JMP(GL_OFFSET(_gloffset_GetTexImage)) + JZ(GLNAME(_glapi_fallback_TexCoord3sv)) + JMP(GL_OFFSET(_gloffset_TexCoord3sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexLevelParameterfv)) -GL_PREFIX(GetTexLevelParameterfv): +GLOBL_FN(GL_PREFIX(TexCoord4d)) +GL_PREFIX(TexCoord4d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexLevelParameterfv)) - JMP(GL_OFFSET(_gloffset_GetTexLevelParameterfv)) + JZ(GLNAME(_glapi_fallback_TexCoord4d)) + JMP(GL_OFFSET(_gloffset_TexCoord4d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexLevelParameteriv)) -GL_PREFIX(GetTexLevelParameteriv): +GLOBL_FN(GL_PREFIX(TexCoord4dv)) +GL_PREFIX(TexCoord4dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexLevelParameteriv)) - JMP(GL_OFFSET(_gloffset_GetTexLevelParameteriv)) + JZ(GLNAME(_glapi_fallback_TexCoord4dv)) + JMP(GL_OFFSET(_gloffset_TexCoord4dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexParameterfv)) -GL_PREFIX(GetTexParameterfv): +GLOBL_FN(GL_PREFIX(TexCoord4f)) +GL_PREFIX(TexCoord4f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexParameterfv)) - JMP(GL_OFFSET(_gloffset_GetTexParameterfv)) + JZ(GLNAME(_glapi_fallback_TexCoord4f)) + JMP(GL_OFFSET(_gloffset_TexCoord4f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetTexParameteriv)) -GL_PREFIX(GetTexParameteriv): +GLOBL_FN(GL_PREFIX(TexCoord4fv)) +GL_PREFIX(TexCoord4fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetTexParameteriv)) - JMP(GL_OFFSET(_gloffset_GetTexParameteriv)) + JZ(GLNAME(_glapi_fallback_TexCoord4fv)) + JMP(GL_OFFSET(_gloffset_TexCoord4fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Hint)) -GL_PREFIX(Hint): +GLOBL_FN(GL_PREFIX(TexCoord4i)) +GL_PREFIX(TexCoord4i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Hint)) - JMP(GL_OFFSET(_gloffset_Hint)) + JZ(GLNAME(_glapi_fallback_TexCoord4i)) + JMP(GL_OFFSET(_gloffset_TexCoord4i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Indexd)) -GL_PREFIX(Indexd): +GLOBL_FN(GL_PREFIX(TexCoord4iv)) +GL_PREFIX(TexCoord4iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Indexd)) - JMP(GL_OFFSET(_gloffset_Indexd)) + JZ(GLNAME(_glapi_fallback_TexCoord4iv)) + JMP(GL_OFFSET(_gloffset_TexCoord4iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Indexdv)) -GL_PREFIX(Indexdv): +GLOBL_FN(GL_PREFIX(TexCoord4s)) +GL_PREFIX(TexCoord4s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Indexdv)) - JMP(GL_OFFSET(_gloffset_Indexdv)) + JZ(GLNAME(_glapi_fallback_TexCoord4s)) + JMP(GL_OFFSET(_gloffset_TexCoord4s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Indexf)) -GL_PREFIX(Indexf): +GLOBL_FN(GL_PREFIX(TexCoord4sv)) +GL_PREFIX(TexCoord4sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Indexf)) - JMP(GL_OFFSET(_gloffset_Indexf)) + JZ(GLNAME(_glapi_fallback_TexCoord4sv)) + JMP(GL_OFFSET(_gloffset_TexCoord4sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Indexfv)) -GL_PREFIX(Indexfv): +GLOBL_FN(GL_PREFIX(Vertex2d)) +GL_PREFIX(Vertex2d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Indexfv)) - JMP(GL_OFFSET(_gloffset_Indexfv)) + JZ(GLNAME(_glapi_fallback_Vertex2d)) + JMP(GL_OFFSET(_gloffset_Vertex2d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Indexi)) -GL_PREFIX(Indexi): +GLOBL_FN(GL_PREFIX(Vertex2dv)) +GL_PREFIX(Vertex2dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Indexi)) - JMP(GL_OFFSET(_gloffset_Indexi)) + JZ(GLNAME(_glapi_fallback_Vertex2dv)) + JMP(GL_OFFSET(_gloffset_Vertex2dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Indexiv)) -GL_PREFIX(Indexiv): +GLOBL_FN(GL_PREFIX(Vertex2f)) +GL_PREFIX(Vertex2f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Indexiv)) - JMP(GL_OFFSET(_gloffset_Indexiv)) + JZ(GLNAME(_glapi_fallback_Vertex2f)) + JMP(GL_OFFSET(_gloffset_Vertex2f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Indexs)) -GL_PREFIX(Indexs): +GLOBL_FN(GL_PREFIX(Vertex2fv)) +GL_PREFIX(Vertex2fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Indexs)) - JMP(GL_OFFSET(_gloffset_Indexs)) + JZ(GLNAME(_glapi_fallback_Vertex2fv)) + JMP(GL_OFFSET(_gloffset_Vertex2fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Indexsv)) -GL_PREFIX(Indexsv): +GLOBL_FN(GL_PREFIX(Vertex2i)) +GL_PREFIX(Vertex2i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Indexsv)) - JMP(GL_OFFSET(_gloffset_Indexsv)) + JZ(GLNAME(_glapi_fallback_Vertex2i)) + JMP(GL_OFFSET(_gloffset_Vertex2i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(IndexMask)) -GL_PREFIX(IndexMask): +GLOBL_FN(GL_PREFIX(Vertex2iv)) +GL_PREFIX(Vertex2iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_IndexMask)) - JMP(GL_OFFSET(_gloffset_IndexMask)) + JZ(GLNAME(_glapi_fallback_Vertex2iv)) + JMP(GL_OFFSET(_gloffset_Vertex2iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(InitNames)) -GL_PREFIX(InitNames): +GLOBL_FN(GL_PREFIX(Vertex2s)) +GL_PREFIX(Vertex2s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_InitNames)) - JMP(GL_OFFSET(_gloffset_InitNames)) + JZ(GLNAME(_glapi_fallback_Vertex2s)) + JMP(GL_OFFSET(_gloffset_Vertex2s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(IsEnabled)) -GL_PREFIX(IsEnabled): +GLOBL_FN(GL_PREFIX(Vertex2sv)) +GL_PREFIX(Vertex2sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_IsEnabled)) - JMP(GL_OFFSET(_gloffset_IsEnabled)) + JZ(GLNAME(_glapi_fallback_Vertex2sv)) + JMP(GL_OFFSET(_gloffset_Vertex2sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(IsList)) -GL_PREFIX(IsList): +GLOBL_FN(GL_PREFIX(Vertex3d)) +GL_PREFIX(Vertex3d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_IsList)) - JMP(GL_OFFSET(_gloffset_IsList)) + JZ(GLNAME(_glapi_fallback_Vertex3d)) + JMP(GL_OFFSET(_gloffset_Vertex3d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Lightf)) -GL_PREFIX(Lightf): +GLOBL_FN(GL_PREFIX(Vertex3dv)) +GL_PREFIX(Vertex3dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Lightf)) - JMP(GL_OFFSET(_gloffset_Lightf)) + JZ(GLNAME(_glapi_fallback_Vertex3dv)) + JMP(GL_OFFSET(_gloffset_Vertex3dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Lighti)) -GL_PREFIX(Lighti): +GLOBL_FN(GL_PREFIX(Vertex3f)) +GL_PREFIX(Vertex3f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Lighti)) - JMP(GL_OFFSET(_gloffset_Lighti)) + JZ(GLNAME(_glapi_fallback_Vertex3f)) + JMP(GL_OFFSET(_gloffset_Vertex3f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Lightfv)) -GL_PREFIX(Lightfv): +GLOBL_FN(GL_PREFIX(Vertex3fv)) +GL_PREFIX(Vertex3fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Lightfv)) - JMP(GL_OFFSET(_gloffset_Lightfv)) + JZ(GLNAME(_glapi_fallback_Vertex3fv)) + JMP(GL_OFFSET(_gloffset_Vertex3fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Lightiv)) -GL_PREFIX(Lightiv): +GLOBL_FN(GL_PREFIX(Vertex3i)) +GL_PREFIX(Vertex3i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Lightiv)) - JMP(GL_OFFSET(_gloffset_Lightiv)) + JZ(GLNAME(_glapi_fallback_Vertex3i)) + JMP(GL_OFFSET(_gloffset_Vertex3i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LightModelf)) -GL_PREFIX(LightModelf): +GLOBL_FN(GL_PREFIX(Vertex3iv)) +GL_PREFIX(Vertex3iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LightModelf)) - JMP(GL_OFFSET(_gloffset_LightModelf)) + JZ(GLNAME(_glapi_fallback_Vertex3iv)) + JMP(GL_OFFSET(_gloffset_Vertex3iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LightModeli)) -GL_PREFIX(LightModeli): +GLOBL_FN(GL_PREFIX(Vertex3s)) +GL_PREFIX(Vertex3s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LightModeli)) - JMP(GL_OFFSET(_gloffset_LightModeli)) + JZ(GLNAME(_glapi_fallback_Vertex3s)) + JMP(GL_OFFSET(_gloffset_Vertex3s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LightModelfv)) -GL_PREFIX(LightModelfv): +GLOBL_FN(GL_PREFIX(Vertex3sv)) +GL_PREFIX(Vertex3sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LightModelfv)) - JMP(GL_OFFSET(_gloffset_LightModelfv)) + JZ(GLNAME(_glapi_fallback_Vertex3sv)) + JMP(GL_OFFSET(_gloffset_Vertex3sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LightModeliv)) -GL_PREFIX(LightModeliv): +GLOBL_FN(GL_PREFIX(Vertex4d)) +GL_PREFIX(Vertex4d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LightModeliv)) - JMP(GL_OFFSET(_gloffset_LightModeliv)) + JZ(GLNAME(_glapi_fallback_Vertex4d)) + JMP(GL_OFFSET(_gloffset_Vertex4d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LineWidth)) -GL_PREFIX(LineWidth): +GLOBL_FN(GL_PREFIX(Vertex4dv)) +GL_PREFIX(Vertex4dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LineWidth)) - JMP(GL_OFFSET(_gloffset_LineWidth)) + JZ(GLNAME(_glapi_fallback_Vertex4dv)) + JMP(GL_OFFSET(_gloffset_Vertex4dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LineStipple)) -GL_PREFIX(LineStipple): +GLOBL_FN(GL_PREFIX(Vertex4f)) +GL_PREFIX(Vertex4f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LineStipple)) - JMP(GL_OFFSET(_gloffset_LineStipple)) + JZ(GLNAME(_glapi_fallback_Vertex4f)) + JMP(GL_OFFSET(_gloffset_Vertex4f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ListBase)) -GL_PREFIX(ListBase): +GLOBL_FN(GL_PREFIX(Vertex4fv)) +GL_PREFIX(Vertex4fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ListBase)) - JMP(GL_OFFSET(_gloffset_ListBase)) + JZ(GLNAME(_glapi_fallback_Vertex4fv)) + JMP(GL_OFFSET(_gloffset_Vertex4fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LoadIdentity)) -GL_PREFIX(LoadIdentity): +GLOBL_FN(GL_PREFIX(Vertex4i)) +GL_PREFIX(Vertex4i): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LoadIdentity)) - JMP(GL_OFFSET(_gloffset_LoadIdentity)) + JZ(GLNAME(_glapi_fallback_Vertex4i)) + JMP(GL_OFFSET(_gloffset_Vertex4i)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LoadMatrixd)) -GL_PREFIX(LoadMatrixd): +GLOBL_FN(GL_PREFIX(Vertex4iv)) +GL_PREFIX(Vertex4iv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LoadMatrixd)) - JMP(GL_OFFSET(_gloffset_LoadMatrixd)) + JZ(GLNAME(_glapi_fallback_Vertex4iv)) + JMP(GL_OFFSET(_gloffset_Vertex4iv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LoadMatrixf)) -GL_PREFIX(LoadMatrixf): +GLOBL_FN(GL_PREFIX(Vertex4s)) +GL_PREFIX(Vertex4s): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LoadMatrixf)) - JMP(GL_OFFSET(_gloffset_LoadMatrixf)) + JZ(GLNAME(_glapi_fallback_Vertex4s)) + JMP(GL_OFFSET(_gloffset_Vertex4s)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LoadName)) -GL_PREFIX(LoadName): +GLOBL_FN(GL_PREFIX(Vertex4sv)) +GL_PREFIX(Vertex4sv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LoadName)) - JMP(GL_OFFSET(_gloffset_LoadName)) + JZ(GLNAME(_glapi_fallback_Vertex4sv)) + JMP(GL_OFFSET(_gloffset_Vertex4sv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LogicOp)) -GL_PREFIX(LogicOp): +GLOBL_FN(GL_PREFIX(ClipPlane)) +GL_PREFIX(ClipPlane): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LogicOp)) - JMP(GL_OFFSET(_gloffset_LogicOp)) + JZ(GLNAME(_glapi_fallback_ClipPlane)) + JMP(GL_OFFSET(_gloffset_ClipPlane)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Map1d)) -GL_PREFIX(Map1d): +GLOBL_FN(GL_PREFIX(ColorMaterial)) +GL_PREFIX(ColorMaterial): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Map1d)) - JMP(GL_OFFSET(_gloffset_Map1d)) + JZ(GLNAME(_glapi_fallback_ColorMaterial)) + JMP(GL_OFFSET(_gloffset_ColorMaterial)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Map1f)) -GL_PREFIX(Map1f): +GLOBL_FN(GL_PREFIX(CullFace)) +GL_PREFIX(CullFace): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Map1f)) - JMP(GL_OFFSET(_gloffset_Map1f)) + JZ(GLNAME(_glapi_fallback_CullFace)) + JMP(GL_OFFSET(_gloffset_CullFace)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Map2d)) -GL_PREFIX(Map2d): +GLOBL_FN(GL_PREFIX(Fogf)) +GL_PREFIX(Fogf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Map2d)) - JMP(GL_OFFSET(_gloffset_Map2d)) + JZ(GLNAME(_glapi_fallback_Fogf)) + JMP(GL_OFFSET(_gloffset_Fogf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Map2f)) -GL_PREFIX(Map2f): +GLOBL_FN(GL_PREFIX(Fogfv)) +GL_PREFIX(Fogfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Map2f)) - JMP(GL_OFFSET(_gloffset_Map2f)) + JZ(GLNAME(_glapi_fallback_Fogfv)) + JMP(GL_OFFSET(_gloffset_Fogfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MapGrid1d)) -GL_PREFIX(MapGrid1d): +GLOBL_FN(GL_PREFIX(Fogi)) +GL_PREFIX(Fogi): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MapGrid1d)) - JMP(GL_OFFSET(_gloffset_MapGrid1d)) + JZ(GLNAME(_glapi_fallback_Fogi)) + JMP(GL_OFFSET(_gloffset_Fogi)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MapGrid1f)) -GL_PREFIX(MapGrid1f): +GLOBL_FN(GL_PREFIX(Fogiv)) +GL_PREFIX(Fogiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MapGrid1f)) - JMP(GL_OFFSET(_gloffset_MapGrid1f)) + JZ(GLNAME(_glapi_fallback_Fogiv)) + JMP(GL_OFFSET(_gloffset_Fogiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MapGrid2d)) -GL_PREFIX(MapGrid2d): +GLOBL_FN(GL_PREFIX(FrontFace)) +GL_PREFIX(FrontFace): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MapGrid2d)) - JMP(GL_OFFSET(_gloffset_MapGrid2d)) + JZ(GLNAME(_glapi_fallback_FrontFace)) + JMP(GL_OFFSET(_gloffset_FrontFace)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MapGrid2f)) -GL_PREFIX(MapGrid2f): +GLOBL_FN(GL_PREFIX(Hint)) +GL_PREFIX(Hint): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MapGrid2f)) - JMP(GL_OFFSET(_gloffset_MapGrid2f)) + JZ(GLNAME(_glapi_fallback_Hint)) + JMP(GL_OFFSET(_gloffset_Hint)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Materialf)) -GL_PREFIX(Materialf): +GLOBL_FN(GL_PREFIX(Lightf)) +GL_PREFIX(Lightf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Materialf)) - JMP(GL_OFFSET(_gloffset_Materialf)) + JZ(GLNAME(_glapi_fallback_Lightf)) + JMP(GL_OFFSET(_gloffset_Lightf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Materiali)) -GL_PREFIX(Materiali): +GLOBL_FN(GL_PREFIX(Lightfv)) +GL_PREFIX(Lightfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Materiali)) - JMP(GL_OFFSET(_gloffset_Materiali)) + JZ(GLNAME(_glapi_fallback_Lightfv)) + JMP(GL_OFFSET(_gloffset_Lightfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Materialfv)) -GL_PREFIX(Materialfv): +GLOBL_FN(GL_PREFIX(Lighti)) +GL_PREFIX(Lighti): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Materialfv)) - JMP(GL_OFFSET(_gloffset_Materialfv)) + JZ(GLNAME(_glapi_fallback_Lighti)) + JMP(GL_OFFSET(_gloffset_Lighti)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Materialiv)) -GL_PREFIX(Materialiv): +GLOBL_FN(GL_PREFIX(Lightiv)) +GL_PREFIX(Lightiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Materialiv)) - JMP(GL_OFFSET(_gloffset_Materialiv)) + JZ(GLNAME(_glapi_fallback_Lightiv)) + JMP(GL_OFFSET(_gloffset_Lightiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MatrixMode)) -GL_PREFIX(MatrixMode): +GLOBL_FN(GL_PREFIX(LightModelf)) +GL_PREFIX(LightModelf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MatrixMode)) - JMP(GL_OFFSET(_gloffset_MatrixMode)) + JZ(GLNAME(_glapi_fallback_LightModelf)) + JMP(GL_OFFSET(_gloffset_LightModelf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MultMatrixd)) -GL_PREFIX(MultMatrixd): +GLOBL_FN(GL_PREFIX(LightModelfv)) +GL_PREFIX(LightModelfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MultMatrixd)) - JMP(GL_OFFSET(_gloffset_MultMatrixd)) + JZ(GLNAME(_glapi_fallback_LightModelfv)) + JMP(GL_OFFSET(_gloffset_LightModelfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MultMatrixf)) -GL_PREFIX(MultMatrixf): +GLOBL_FN(GL_PREFIX(LightModeli)) +GL_PREFIX(LightModeli): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MultMatrixf)) - JMP(GL_OFFSET(_gloffset_MultMatrixf)) + JZ(GLNAME(_glapi_fallback_LightModeli)) + JMP(GL_OFFSET(_gloffset_LightModeli)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(NewList)) -GL_PREFIX(NewList): +GLOBL_FN(GL_PREFIX(LightModeliv)) +GL_PREFIX(LightModeliv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_NewList)) - JMP(GL_OFFSET(_gloffset_NewList)) + JZ(GLNAME(_glapi_fallback_LightModeliv)) + JMP(GL_OFFSET(_gloffset_LightModeliv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3b)) -GL_PREFIX(Normal3b): +GLOBL_FN(GL_PREFIX(LineStipple)) +GL_PREFIX(LineStipple): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3b)) - JMP(GL_OFFSET(_gloffset_Normal3b)) + JZ(GLNAME(_glapi_fallback_LineStipple)) + JMP(GL_OFFSET(_gloffset_LineStipple)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3bv)) -GL_PREFIX(Normal3bv): +GLOBL_FN(GL_PREFIX(LineWidth)) +GL_PREFIX(LineWidth): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3bv)) - JMP(GL_OFFSET(_gloffset_Normal3bv)) + JZ(GLNAME(_glapi_fallback_LineWidth)) + JMP(GL_OFFSET(_gloffset_LineWidth)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3d)) -GL_PREFIX(Normal3d): +GLOBL_FN(GL_PREFIX(Materialf)) +GL_PREFIX(Materialf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3d)) - JMP(GL_OFFSET(_gloffset_Normal3d)) + JZ(GLNAME(_glapi_fallback_Materialf)) + JMP(GL_OFFSET(_gloffset_Materialf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3dv)) -GL_PREFIX(Normal3dv): +GLOBL_FN(GL_PREFIX(Materialfv)) +GL_PREFIX(Materialfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3dv)) - JMP(GL_OFFSET(_gloffset_Normal3dv)) + JZ(GLNAME(_glapi_fallback_Materialfv)) + JMP(GL_OFFSET(_gloffset_Materialfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3f)) -GL_PREFIX(Normal3f): +GLOBL_FN(GL_PREFIX(Materiali)) +GL_PREFIX(Materiali): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3f)) - JMP(GL_OFFSET(_gloffset_Normal3f)) + JZ(GLNAME(_glapi_fallback_Materiali)) + JMP(GL_OFFSET(_gloffset_Materiali)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3fv)) -GL_PREFIX(Normal3fv): +GLOBL_FN(GL_PREFIX(Materialiv)) +GL_PREFIX(Materialiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3fv)) - JMP(GL_OFFSET(_gloffset_Normal3fv)) + JZ(GLNAME(_glapi_fallback_Materialiv)) + JMP(GL_OFFSET(_gloffset_Materialiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3i)) -GL_PREFIX(Normal3i): +GLOBL_FN(GL_PREFIX(PointSize)) +GL_PREFIX(PointSize): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3i)) - JMP(GL_OFFSET(_gloffset_Normal3i)) + JZ(GLNAME(_glapi_fallback_PointSize)) + JMP(GL_OFFSET(_gloffset_PointSize)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3iv)) -GL_PREFIX(Normal3iv): +GLOBL_FN(GL_PREFIX(PolygonMode)) +GL_PREFIX(PolygonMode): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3iv)) - JMP(GL_OFFSET(_gloffset_Normal3iv)) + JZ(GLNAME(_glapi_fallback_PolygonMode)) + JMP(GL_OFFSET(_gloffset_PolygonMode)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3s)) -GL_PREFIX(Normal3s): +GLOBL_FN(GL_PREFIX(PolygonStipple)) +GL_PREFIX(PolygonStipple): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3s)) - JMP(GL_OFFSET(_gloffset_Normal3s)) + JZ(GLNAME(_glapi_fallback_PolygonStipple)) + JMP(GL_OFFSET(_gloffset_PolygonStipple)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Normal3sv)) -GL_PREFIX(Normal3sv): +GLOBL_FN(GL_PREFIX(Scissor)) +GL_PREFIX(Scissor): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Normal3sv)) - JMP(GL_OFFSET(_gloffset_Normal3sv)) + JZ(GLNAME(_glapi_fallback_Scissor)) + JMP(GL_OFFSET(_gloffset_Scissor)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Ortho)) -GL_PREFIX(Ortho): +GLOBL_FN(GL_PREFIX(ShadeModel)) +GL_PREFIX(ShadeModel): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Ortho)) - JMP(GL_OFFSET(_gloffset_Ortho)) + JZ(GLNAME(_glapi_fallback_ShadeModel)) + JMP(GL_OFFSET(_gloffset_ShadeModel)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PassThrough)) -GL_PREFIX(PassThrough): +GLOBL_FN(GL_PREFIX(TexParameterf)) +GL_PREFIX(TexParameterf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PassThrough)) - JMP(GL_OFFSET(_gloffset_PassThrough)) + JZ(GLNAME(_glapi_fallback_TexParameterf)) + JMP(GL_OFFSET(_gloffset_TexParameterf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelMapfv)) -GL_PREFIX(PixelMapfv): +GLOBL_FN(GL_PREFIX(TexParameterfv)) +GL_PREFIX(TexParameterfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelMapfv)) - JMP(GL_OFFSET(_gloffset_PixelMapfv)) + JZ(GLNAME(_glapi_fallback_TexParameterfv)) + JMP(GL_OFFSET(_gloffset_TexParameterfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelMapuiv)) -GL_PREFIX(PixelMapuiv): +GLOBL_FN(GL_PREFIX(TexParameteri)) +GL_PREFIX(TexParameteri): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelMapuiv)) - JMP(GL_OFFSET(_gloffset_PixelMapuiv)) + JZ(GLNAME(_glapi_fallback_TexParameteri)) + JMP(GL_OFFSET(_gloffset_TexParameteri)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelMapusv)) -GL_PREFIX(PixelMapusv): +GLOBL_FN(GL_PREFIX(TexParameteriv)) +GL_PREFIX(TexParameteriv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelMapusv)) - JMP(GL_OFFSET(_gloffset_PixelMapusv)) + JZ(GLNAME(_glapi_fallback_TexParameteriv)) + JMP(GL_OFFSET(_gloffset_TexParameteriv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelStoref)) -GL_PREFIX(PixelStoref): +GLOBL_FN(GL_PREFIX(TexImage1D)) +GL_PREFIX(TexImage1D): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelStoref)) - JMP(GL_OFFSET(_gloffset_PixelStoref)) + JZ(GLNAME(_glapi_fallback_TexImage1D)) + JMP(GL_OFFSET(_gloffset_TexImage1D)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelStorei)) -GL_PREFIX(PixelStorei): +GLOBL_FN(GL_PREFIX(TexImage2D)) +GL_PREFIX(TexImage2D): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelStorei)) - JMP(GL_OFFSET(_gloffset_PixelStorei)) + JZ(GLNAME(_glapi_fallback_TexImage2D)) + JMP(GL_OFFSET(_gloffset_TexImage2D)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelTransferf)) -GL_PREFIX(PixelTransferf): +GLOBL_FN(GL_PREFIX(TexEnvf)) +GL_PREFIX(TexEnvf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelTransferf)) - JMP(GL_OFFSET(_gloffset_PixelTransferf)) + JZ(GLNAME(_glapi_fallback_TexEnvf)) + JMP(GL_OFFSET(_gloffset_TexEnvf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelTransferi)) -GL_PREFIX(PixelTransferi): +GLOBL_FN(GL_PREFIX(TexEnvfv)) +GL_PREFIX(TexEnvfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelTransferi)) - JMP(GL_OFFSET(_gloffset_PixelTransferi)) + JZ(GLNAME(_glapi_fallback_TexEnvfv)) + JMP(GL_OFFSET(_gloffset_TexEnvfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelZoom)) -GL_PREFIX(PixelZoom): +GLOBL_FN(GL_PREFIX(TexEnvi)) +GL_PREFIX(TexEnvi): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelZoom)) - JMP(GL_OFFSET(_gloffset_PixelZoom)) + JZ(GLNAME(_glapi_fallback_TexEnvi)) + JMP(GL_OFFSET(_gloffset_TexEnvi)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PointSize)) -GL_PREFIX(PointSize): +GLOBL_FN(GL_PREFIX(TexEnviv)) +GL_PREFIX(TexEnviv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PointSize)) - JMP(GL_OFFSET(_gloffset_PointSize)) + JZ(GLNAME(_glapi_fallback_TexEnviv)) + JMP(GL_OFFSET(_gloffset_TexEnviv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PolygonMode)) -GL_PREFIX(PolygonMode): +GLOBL_FN(GL_PREFIX(TexGend)) +GL_PREFIX(TexGend): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PolygonMode)) - JMP(GL_OFFSET(_gloffset_PolygonMode)) + JZ(GLNAME(_glapi_fallback_TexGend)) + JMP(GL_OFFSET(_gloffset_TexGend)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PolygonStipple)) -GL_PREFIX(PolygonStipple): +GLOBL_FN(GL_PREFIX(TexGendv)) +GL_PREFIX(TexGendv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PolygonStipple)) - JMP(GL_OFFSET(_gloffset_PolygonStipple)) + JZ(GLNAME(_glapi_fallback_TexGendv)) + JMP(GL_OFFSET(_gloffset_TexGendv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PopAttrib)) -GL_PREFIX(PopAttrib): +GLOBL_FN(GL_PREFIX(TexGenf)) +GL_PREFIX(TexGenf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PopAttrib)) - JMP(GL_OFFSET(_gloffset_PopAttrib)) + JZ(GLNAME(_glapi_fallback_TexGenf)) + JMP(GL_OFFSET(_gloffset_TexGenf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PopMatrix)) -GL_PREFIX(PopMatrix): +GLOBL_FN(GL_PREFIX(TexGenfv)) +GL_PREFIX(TexGenfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PopMatrix)) - JMP(GL_OFFSET(_gloffset_PopMatrix)) + JZ(GLNAME(_glapi_fallback_TexGenfv)) + JMP(GL_OFFSET(_gloffset_TexGenfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PopName)) -GL_PREFIX(PopName): +GLOBL_FN(GL_PREFIX(TexGeni)) +GL_PREFIX(TexGeni): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PopName)) - JMP(GL_OFFSET(_gloffset_PopName)) + JZ(GLNAME(_glapi_fallback_TexGeni)) + JMP(GL_OFFSET(_gloffset_TexGeni)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PushAttrib)) -GL_PREFIX(PushAttrib): +GLOBL_FN(GL_PREFIX(TexGeniv)) +GL_PREFIX(TexGeniv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PushAttrib)) - JMP(GL_OFFSET(_gloffset_PushAttrib)) + JZ(GLNAME(_glapi_fallback_TexGeniv)) + JMP(GL_OFFSET(_gloffset_TexGeniv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PushMatrix)) -GL_PREFIX(PushMatrix): +GLOBL_FN(GL_PREFIX(FeedbackBuffer)) +GL_PREFIX(FeedbackBuffer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PushMatrix)) - JMP(GL_OFFSET(_gloffset_PushMatrix)) + JZ(GLNAME(_glapi_fallback_FeedbackBuffer)) + JMP(GL_OFFSET(_gloffset_FeedbackBuffer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PushName)) -GL_PREFIX(PushName): +GLOBL_FN(GL_PREFIX(SelectBuffer)) +GL_PREFIX(SelectBuffer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PushName)) - JMP(GL_OFFSET(_gloffset_PushName)) + JZ(GLNAME(_glapi_fallback_SelectBuffer)) + JMP(GL_OFFSET(_gloffset_SelectBuffer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos2d)) -GL_PREFIX(RasterPos2d): +GLOBL_FN(GL_PREFIX(RenderMode)) +GL_PREFIX(RenderMode): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos2d)) - JMP(GL_OFFSET(_gloffset_RasterPos2d)) + JZ(GLNAME(_glapi_fallback_RenderMode)) + JMP(GL_OFFSET(_gloffset_RenderMode)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos2f)) -GL_PREFIX(RasterPos2f): +GLOBL_FN(GL_PREFIX(InitNames)) +GL_PREFIX(InitNames): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos2f)) - JMP(GL_OFFSET(_gloffset_RasterPos2f)) + JZ(GLNAME(_glapi_fallback_InitNames)) + JMP(GL_OFFSET(_gloffset_InitNames)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos2i)) -GL_PREFIX(RasterPos2i): +GLOBL_FN(GL_PREFIX(LoadName)) +GL_PREFIX(LoadName): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos2i)) - JMP(GL_OFFSET(_gloffset_RasterPos2i)) + JZ(GLNAME(_glapi_fallback_LoadName)) + JMP(GL_OFFSET(_gloffset_LoadName)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos2s)) -GL_PREFIX(RasterPos2s): +GLOBL_FN(GL_PREFIX(PassThrough)) +GL_PREFIX(PassThrough): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos2s)) - JMP(GL_OFFSET(_gloffset_RasterPos2s)) + JZ(GLNAME(_glapi_fallback_PassThrough)) + JMP(GL_OFFSET(_gloffset_PassThrough)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos3d)) -GL_PREFIX(RasterPos3d): +GLOBL_FN(GL_PREFIX(PopName)) +GL_PREFIX(PopName): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos3d)) - JMP(GL_OFFSET(_gloffset_RasterPos3d)) + JZ(GLNAME(_glapi_fallback_PopName)) + JMP(GL_OFFSET(_gloffset_PopName)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos3f)) -GL_PREFIX(RasterPos3f): +GLOBL_FN(GL_PREFIX(PushName)) +GL_PREFIX(PushName): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos3f)) - JMP(GL_OFFSET(_gloffset_RasterPos3f)) + JZ(GLNAME(_glapi_fallback_PushName)) + JMP(GL_OFFSET(_gloffset_PushName)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos3i)) -GL_PREFIX(RasterPos3i): +GLOBL_FN(GL_PREFIX(DrawBuffer)) +GL_PREFIX(DrawBuffer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos3i)) - JMP(GL_OFFSET(_gloffset_RasterPos3i)) + JZ(GLNAME(_glapi_fallback_DrawBuffer)) + JMP(GL_OFFSET(_gloffset_DrawBuffer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos3s)) -GL_PREFIX(RasterPos3s): +GLOBL_FN(GL_PREFIX(Clear)) +GL_PREFIX(Clear): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos3s)) - JMP(GL_OFFSET(_gloffset_RasterPos3s)) + JZ(GLNAME(_glapi_fallback_Clear)) + JMP(GL_OFFSET(_gloffset_Clear)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos4d)) -GL_PREFIX(RasterPos4d): +GLOBL_FN(GL_PREFIX(ClearAccum)) +GL_PREFIX(ClearAccum): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos4d)) - JMP(GL_OFFSET(_gloffset_RasterPos4d)) + JZ(GLNAME(_glapi_fallback_ClearAccum)) + JMP(GL_OFFSET(_gloffset_ClearAccum)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos4f)) -GL_PREFIX(RasterPos4f): +GLOBL_FN(GL_PREFIX(ClearIndex)) +GL_PREFIX(ClearIndex): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos4f)) - JMP(GL_OFFSET(_gloffset_RasterPos4f)) + JZ(GLNAME(_glapi_fallback_ClearIndex)) + JMP(GL_OFFSET(_gloffset_ClearIndex)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos4i)) -GL_PREFIX(RasterPos4i): +GLOBL_FN(GL_PREFIX(ClearColor)) +GL_PREFIX(ClearColor): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos4i)) - JMP(GL_OFFSET(_gloffset_RasterPos4i)) + JZ(GLNAME(_glapi_fallback_ClearColor)) + JMP(GL_OFFSET(_gloffset_ClearColor)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos4s)) -GL_PREFIX(RasterPos4s): +GLOBL_FN(GL_PREFIX(ClearStencil)) +GL_PREFIX(ClearStencil): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos4s)) - JMP(GL_OFFSET(_gloffset_RasterPos4s)) + JZ(GLNAME(_glapi_fallback_ClearStencil)) + JMP(GL_OFFSET(_gloffset_ClearStencil)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos2dv)) -GL_PREFIX(RasterPos2dv): +GLOBL_FN(GL_PREFIX(ClearDepth)) +GL_PREFIX(ClearDepth): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos2dv)) - JMP(GL_OFFSET(_gloffset_RasterPos2dv)) + JZ(GLNAME(_glapi_fallback_ClearDepth)) + JMP(GL_OFFSET(_gloffset_ClearDepth)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos2fv)) -GL_PREFIX(RasterPos2fv): +GLOBL_FN(GL_PREFIX(StencilMask)) +GL_PREFIX(StencilMask): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos2fv)) - JMP(GL_OFFSET(_gloffset_RasterPos2fv)) + JZ(GLNAME(_glapi_fallback_StencilMask)) + JMP(GL_OFFSET(_gloffset_StencilMask)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos2iv)) -GL_PREFIX(RasterPos2iv): +GLOBL_FN(GL_PREFIX(ColorMask)) +GL_PREFIX(ColorMask): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos2iv)) - JMP(GL_OFFSET(_gloffset_RasterPos2iv)) + JZ(GLNAME(_glapi_fallback_ColorMask)) + JMP(GL_OFFSET(_gloffset_ColorMask)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos2sv)) -GL_PREFIX(RasterPos2sv): +GLOBL_FN(GL_PREFIX(DepthMask)) +GL_PREFIX(DepthMask): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos2sv)) - JMP(GL_OFFSET(_gloffset_RasterPos2sv)) + JZ(GLNAME(_glapi_fallback_DepthMask)) + JMP(GL_OFFSET(_gloffset_DepthMask)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos3dv)) -GL_PREFIX(RasterPos3dv): +GLOBL_FN(GL_PREFIX(IndexMask)) +GL_PREFIX(IndexMask): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos3dv)) - JMP(GL_OFFSET(_gloffset_RasterPos3dv)) + JZ(GLNAME(_glapi_fallback_IndexMask)) + JMP(GL_OFFSET(_gloffset_IndexMask)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos3fv)) -GL_PREFIX(RasterPos3fv): +GLOBL_FN(GL_PREFIX(Accum)) +GL_PREFIX(Accum): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos3fv)) - JMP(GL_OFFSET(_gloffset_RasterPos3fv)) + JZ(GLNAME(_glapi_fallback_Accum)) + JMP(GL_OFFSET(_gloffset_Accum)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos3iv)) -GL_PREFIX(RasterPos3iv): +GLOBL_FN(GL_PREFIX(Disable)) +GL_PREFIX(Disable): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos3iv)) - JMP(GL_OFFSET(_gloffset_RasterPos3iv)) + JZ(GLNAME(_glapi_fallback_Disable)) + JMP(GL_OFFSET(_gloffset_Disable)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos3sv)) -GL_PREFIX(RasterPos3sv): +GLOBL_FN(GL_PREFIX(Enable)) +GL_PREFIX(Enable): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos3sv)) - JMP(GL_OFFSET(_gloffset_RasterPos3sv)) + JZ(GLNAME(_glapi_fallback_Enable)) + JMP(GL_OFFSET(_gloffset_Enable)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos4dv)) -GL_PREFIX(RasterPos4dv): +GLOBL_FN(GL_PREFIX(Finish)) +GL_PREFIX(Finish): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos4dv)) - JMP(GL_OFFSET(_gloffset_RasterPos4dv)) + JZ(GLNAME(_glapi_fallback_Finish)) + JMP(GL_OFFSET(_gloffset_Finish)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos4fv)) -GL_PREFIX(RasterPos4fv): +GLOBL_FN(GL_PREFIX(Flush)) +GL_PREFIX(Flush): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos4fv)) - JMP(GL_OFFSET(_gloffset_RasterPos4fv)) + JZ(GLNAME(_glapi_fallback_Flush)) + JMP(GL_OFFSET(_gloffset_Flush)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos4iv)) -GL_PREFIX(RasterPos4iv): +GLOBL_FN(GL_PREFIX(PopAttrib)) +GL_PREFIX(PopAttrib): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos4iv)) - JMP(GL_OFFSET(_gloffset_RasterPos4iv)) + JZ(GLNAME(_glapi_fallback_PopAttrib)) + JMP(GL_OFFSET(_gloffset_PopAttrib)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RasterPos4sv)) -GL_PREFIX(RasterPos4sv): +GLOBL_FN(GL_PREFIX(PushAttrib)) +GL_PREFIX(PushAttrib): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RasterPos4sv)) - JMP(GL_OFFSET(_gloffset_RasterPos4sv)) + JZ(GLNAME(_glapi_fallback_PushAttrib)) + JMP(GL_OFFSET(_gloffset_PushAttrib)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ReadBuffer)) -GL_PREFIX(ReadBuffer): +GLOBL_FN(GL_PREFIX(Map1d)) +GL_PREFIX(Map1d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ReadBuffer)) - JMP(GL_OFFSET(_gloffset_ReadBuffer)) + JZ(GLNAME(_glapi_fallback_Map1d)) + JMP(GL_OFFSET(_gloffset_Map1d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ReadPixels)) -GL_PREFIX(ReadPixels): +GLOBL_FN(GL_PREFIX(Map1f)) +GL_PREFIX(Map1f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ReadPixels)) - JMP(GL_OFFSET(_gloffset_ReadPixels)) + JZ(GLNAME(_glapi_fallback_Map1f)) + JMP(GL_OFFSET(_gloffset_Map1f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rectd)) -GL_PREFIX(Rectd): +GLOBL_FN(GL_PREFIX(Map2d)) +GL_PREFIX(Map2d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rectd)) - JMP(GL_OFFSET(_gloffset_Rectd)) + JZ(GLNAME(_glapi_fallback_Map2d)) + JMP(GL_OFFSET(_gloffset_Map2d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rectdv)) -GL_PREFIX(Rectdv): +GLOBL_FN(GL_PREFIX(Map2f)) +GL_PREFIX(Map2f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rectdv)) - JMP(GL_OFFSET(_gloffset_Rectdv)) + JZ(GLNAME(_glapi_fallback_Map2f)) + JMP(GL_OFFSET(_gloffset_Map2f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rectf)) -GL_PREFIX(Rectf): +GLOBL_FN(GL_PREFIX(MapGrid1d)) +GL_PREFIX(MapGrid1d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rectf)) - JMP(GL_OFFSET(_gloffset_Rectf)) + JZ(GLNAME(_glapi_fallback_MapGrid1d)) + JMP(GL_OFFSET(_gloffset_MapGrid1d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rectfv)) -GL_PREFIX(Rectfv): +GLOBL_FN(GL_PREFIX(MapGrid1f)) +GL_PREFIX(MapGrid1f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rectfv)) - JMP(GL_OFFSET(_gloffset_Rectfv)) + JZ(GLNAME(_glapi_fallback_MapGrid1f)) + JMP(GL_OFFSET(_gloffset_MapGrid1f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Recti)) -GL_PREFIX(Recti): +GLOBL_FN(GL_PREFIX(MapGrid2d)) +GL_PREFIX(MapGrid2d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Recti)) - JMP(GL_OFFSET(_gloffset_Recti)) + JZ(GLNAME(_glapi_fallback_MapGrid2d)) + JMP(GL_OFFSET(_gloffset_MapGrid2d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rectiv)) -GL_PREFIX(Rectiv): +GLOBL_FN(GL_PREFIX(MapGrid2f)) +GL_PREFIX(MapGrid2f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rectiv)) - JMP(GL_OFFSET(_gloffset_Rectiv)) + JZ(GLNAME(_glapi_fallback_MapGrid2f)) + JMP(GL_OFFSET(_gloffset_MapGrid2f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rects)) -GL_PREFIX(Rects): +GLOBL_FN(GL_PREFIX(EvalCoord1d)) +GL_PREFIX(EvalCoord1d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rects)) - JMP(GL_OFFSET(_gloffset_Rects)) + JZ(GLNAME(_glapi_fallback_EvalCoord1d)) + JMP(GL_OFFSET(_gloffset_EvalCoord1d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rectsv)) -GL_PREFIX(Rectsv): +GLOBL_FN(GL_PREFIX(EvalCoord1dv)) +GL_PREFIX(EvalCoord1dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rectsv)) - JMP(GL_OFFSET(_gloffset_Rectsv)) + JZ(GLNAME(_glapi_fallback_EvalCoord1dv)) + JMP(GL_OFFSET(_gloffset_EvalCoord1dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(RenderMode)) -GL_PREFIX(RenderMode): +GLOBL_FN(GL_PREFIX(EvalCoord1f)) +GL_PREFIX(EvalCoord1f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_RenderMode)) - JMP(GL_OFFSET(_gloffset_RenderMode)) + JZ(GLNAME(_glapi_fallback_EvalCoord1f)) + JMP(GL_OFFSET(_gloffset_EvalCoord1f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rotated)) -GL_PREFIX(Rotated): +GLOBL_FN(GL_PREFIX(EvalCoord1fv)) +GL_PREFIX(EvalCoord1fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rotated)) - JMP(GL_OFFSET(_gloffset_Rotated)) + JZ(GLNAME(_glapi_fallback_EvalCoord1fv)) + JMP(GL_OFFSET(_gloffset_EvalCoord1fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Rotatef)) -GL_PREFIX(Rotatef): +GLOBL_FN(GL_PREFIX(EvalCoord2d)) +GL_PREFIX(EvalCoord2d): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Rotatef)) - JMP(GL_OFFSET(_gloffset_Rotatef)) + JZ(GLNAME(_glapi_fallback_EvalCoord2d)) + JMP(GL_OFFSET(_gloffset_EvalCoord2d)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SelectBuffer)) -GL_PREFIX(SelectBuffer): +GLOBL_FN(GL_PREFIX(EvalCoord2dv)) +GL_PREFIX(EvalCoord2dv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SelectBuffer)) - JMP(GL_OFFSET(_gloffset_SelectBuffer)) + JZ(GLNAME(_glapi_fallback_EvalCoord2dv)) + JMP(GL_OFFSET(_gloffset_EvalCoord2dv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Scaled)) -GL_PREFIX(Scaled): +GLOBL_FN(GL_PREFIX(EvalCoord2f)) +GL_PREFIX(EvalCoord2f): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Scaled)) - JMP(GL_OFFSET(_gloffset_Scaled)) + JZ(GLNAME(_glapi_fallback_EvalCoord2f)) + JMP(GL_OFFSET(_gloffset_EvalCoord2f)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Scalef)) -GL_PREFIX(Scalef): +GLOBL_FN(GL_PREFIX(EvalCoord2fv)) +GL_PREFIX(EvalCoord2fv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Scalef)) - JMP(GL_OFFSET(_gloffset_Scalef)) + JZ(GLNAME(_glapi_fallback_EvalCoord2fv)) + JMP(GL_OFFSET(_gloffset_EvalCoord2fv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Scissor)) -GL_PREFIX(Scissor): +GLOBL_FN(GL_PREFIX(EvalMesh1)) +GL_PREFIX(EvalMesh1): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Scissor)) - JMP(GL_OFFSET(_gloffset_Scissor)) + JZ(GLNAME(_glapi_fallback_EvalMesh1)) + JMP(GL_OFFSET(_gloffset_EvalMesh1)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ShadeModel)) -GL_PREFIX(ShadeModel): +GLOBL_FN(GL_PREFIX(EvalPoint1)) +GL_PREFIX(EvalPoint1): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ShadeModel)) - JMP(GL_OFFSET(_gloffset_ShadeModel)) + JZ(GLNAME(_glapi_fallback_EvalPoint1)) + JMP(GL_OFFSET(_gloffset_EvalPoint1)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(StencilFunc)) -GL_PREFIX(StencilFunc): +GLOBL_FN(GL_PREFIX(EvalMesh2)) +GL_PREFIX(EvalMesh2): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_StencilFunc)) - JMP(GL_OFFSET(_gloffset_StencilFunc)) + JZ(GLNAME(_glapi_fallback_EvalMesh2)) + JMP(GL_OFFSET(_gloffset_EvalMesh2)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(StencilMask)) -GL_PREFIX(StencilMask): +GLOBL_FN(GL_PREFIX(EvalPoint2)) +GL_PREFIX(EvalPoint2): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_StencilMask)) - JMP(GL_OFFSET(_gloffset_StencilMask)) + JZ(GLNAME(_glapi_fallback_EvalPoint2)) + JMP(GL_OFFSET(_gloffset_EvalPoint2)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(StencilOp)) -GL_PREFIX(StencilOp): +GLOBL_FN(GL_PREFIX(AlphaFunc)) +GL_PREFIX(AlphaFunc): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_StencilOp)) - JMP(GL_OFFSET(_gloffset_StencilOp)) + JZ(GLNAME(_glapi_fallback_AlphaFunc)) + JMP(GL_OFFSET(_gloffset_AlphaFunc)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord1d)) -GL_PREFIX(TexCoord1d): +GLOBL_FN(GL_PREFIX(BlendFunc)) +GL_PREFIX(BlendFunc): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord1d)) - JMP(GL_OFFSET(_gloffset_TexCoord1d)) + JZ(GLNAME(_glapi_fallback_BlendFunc)) + JMP(GL_OFFSET(_gloffset_BlendFunc)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord1f)) -GL_PREFIX(TexCoord1f): +GLOBL_FN(GL_PREFIX(LogicOp)) +GL_PREFIX(LogicOp): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord1f)) - JMP(GL_OFFSET(_gloffset_TexCoord1f)) + JZ(GLNAME(_glapi_fallback_LogicOp)) + JMP(GL_OFFSET(_gloffset_LogicOp)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord1i)) -GL_PREFIX(TexCoord1i): +GLOBL_FN(GL_PREFIX(StencilFunc)) +GL_PREFIX(StencilFunc): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord1i)) - JMP(GL_OFFSET(_gloffset_TexCoord1i)) + JZ(GLNAME(_glapi_fallback_StencilFunc)) + JMP(GL_OFFSET(_gloffset_StencilFunc)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord1s)) -GL_PREFIX(TexCoord1s): +GLOBL_FN(GL_PREFIX(StencilOp)) +GL_PREFIX(StencilOp): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord1s)) - JMP(GL_OFFSET(_gloffset_TexCoord1s)) + JZ(GLNAME(_glapi_fallback_StencilOp)) + JMP(GL_OFFSET(_gloffset_StencilOp)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord2d)) -GL_PREFIX(TexCoord2d): +GLOBL_FN(GL_PREFIX(DepthFunc)) +GL_PREFIX(DepthFunc): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord2d)) - JMP(GL_OFFSET(_gloffset_TexCoord2d)) + JZ(GLNAME(_glapi_fallback_DepthFunc)) + JMP(GL_OFFSET(_gloffset_DepthFunc)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord2f)) -GL_PREFIX(TexCoord2f): +GLOBL_FN(GL_PREFIX(PixelZoom)) +GL_PREFIX(PixelZoom): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord2f)) - JMP(GL_OFFSET(_gloffset_TexCoord2f)) + JZ(GLNAME(_glapi_fallback_PixelZoom)) + JMP(GL_OFFSET(_gloffset_PixelZoom)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord2s)) -GL_PREFIX(TexCoord2s): +GLOBL_FN(GL_PREFIX(PixelTransferf)) +GL_PREFIX(PixelTransferf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord2s)) - JMP(GL_OFFSET(_gloffset_TexCoord2s)) + JZ(GLNAME(_glapi_fallback_PixelTransferf)) + JMP(GL_OFFSET(_gloffset_PixelTransferf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord2i)) -GL_PREFIX(TexCoord2i): +GLOBL_FN(GL_PREFIX(PixelTransferi)) +GL_PREFIX(PixelTransferi): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord2i)) - JMP(GL_OFFSET(_gloffset_TexCoord2i)) + JZ(GLNAME(_glapi_fallback_PixelTransferi)) + JMP(GL_OFFSET(_gloffset_PixelTransferi)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord3d)) -GL_PREFIX(TexCoord3d): +GLOBL_FN(GL_PREFIX(PixelStoref)) +GL_PREFIX(PixelStoref): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord3d)) - JMP(GL_OFFSET(_gloffset_TexCoord3d)) + JZ(GLNAME(_glapi_fallback_PixelStoref)) + JMP(GL_OFFSET(_gloffset_PixelStoref)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord3f)) -GL_PREFIX(TexCoord3f): +GLOBL_FN(GL_PREFIX(PixelStorei)) +GL_PREFIX(PixelStorei): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord3f)) - JMP(GL_OFFSET(_gloffset_TexCoord3f)) + JZ(GLNAME(_glapi_fallback_PixelStorei)) + JMP(GL_OFFSET(_gloffset_PixelStorei)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord3i)) -GL_PREFIX(TexCoord3i): +GLOBL_FN(GL_PREFIX(PixelMapfv)) +GL_PREFIX(PixelMapfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord3i)) - JMP(GL_OFFSET(_gloffset_TexCoord3i)) + JZ(GLNAME(_glapi_fallback_PixelMapfv)) + JMP(GL_OFFSET(_gloffset_PixelMapfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord3s)) -GL_PREFIX(TexCoord3s): +GLOBL_FN(GL_PREFIX(PixelMapuiv)) +GL_PREFIX(PixelMapuiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord3s)) - JMP(GL_OFFSET(_gloffset_TexCoord3s)) + JZ(GLNAME(_glapi_fallback_PixelMapuiv)) + JMP(GL_OFFSET(_gloffset_PixelMapuiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord4d)) -GL_PREFIX(TexCoord4d): +GLOBL_FN(GL_PREFIX(PixelMapusv)) +GL_PREFIX(PixelMapusv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord4d)) - JMP(GL_OFFSET(_gloffset_TexCoord4d)) + JZ(GLNAME(_glapi_fallback_PixelMapusv)) + JMP(GL_OFFSET(_gloffset_PixelMapusv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord4f)) -GL_PREFIX(TexCoord4f): +GLOBL_FN(GL_PREFIX(ReadBuffer)) +GL_PREFIX(ReadBuffer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord4f)) - JMP(GL_OFFSET(_gloffset_TexCoord4f)) + JZ(GLNAME(_glapi_fallback_ReadBuffer)) + JMP(GL_OFFSET(_gloffset_ReadBuffer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord4i)) -GL_PREFIX(TexCoord4i): +GLOBL_FN(GL_PREFIX(CopyPixels)) +GL_PREFIX(CopyPixels): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord4i)) - JMP(GL_OFFSET(_gloffset_TexCoord4i)) + JZ(GLNAME(_glapi_fallback_CopyPixels)) + JMP(GL_OFFSET(_gloffset_CopyPixels)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord4s)) -GL_PREFIX(TexCoord4s): +GLOBL_FN(GL_PREFIX(ReadPixels)) +GL_PREFIX(ReadPixels): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord4s)) - JMP(GL_OFFSET(_gloffset_TexCoord4s)) + JZ(GLNAME(_glapi_fallback_ReadPixels)) + JMP(GL_OFFSET(_gloffset_ReadPixels)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord1dv)) -GL_PREFIX(TexCoord1dv): +GLOBL_FN(GL_PREFIX(DrawPixels)) +GL_PREFIX(DrawPixels): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord1dv)) - JMP(GL_OFFSET(_gloffset_TexCoord1dv)) + JZ(GLNAME(_glapi_fallback_DrawPixels)) + JMP(GL_OFFSET(_gloffset_DrawPixels)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord1fv)) -GL_PREFIX(TexCoord1fv): +GLOBL_FN(GL_PREFIX(GetBooleanv)) +GL_PREFIX(GetBooleanv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord1fv)) - JMP(GL_OFFSET(_gloffset_TexCoord1fv)) + JZ(GLNAME(_glapi_fallback_GetBooleanv)) + JMP(GL_OFFSET(_gloffset_GetBooleanv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord1iv)) -GL_PREFIX(TexCoord1iv): +GLOBL_FN(GL_PREFIX(GetClipPlane)) +GL_PREFIX(GetClipPlane): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord1iv)) - JMP(GL_OFFSET(_gloffset_TexCoord1iv)) + JZ(GLNAME(_glapi_fallback_GetClipPlane)) + JMP(GL_OFFSET(_gloffset_GetClipPlane)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord1sv)) -GL_PREFIX(TexCoord1sv): +GLOBL_FN(GL_PREFIX(GetDoublev)) +GL_PREFIX(GetDoublev): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord1sv)) - JMP(GL_OFFSET(_gloffset_TexCoord1sv)) + JZ(GLNAME(_glapi_fallback_GetDoublev)) + JMP(GL_OFFSET(_gloffset_GetDoublev)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord2dv)) -GL_PREFIX(TexCoord2dv): +GLOBL_FN(GL_PREFIX(GetError)) +GL_PREFIX(GetError): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord2dv)) - JMP(GL_OFFSET(_gloffset_TexCoord2dv)) + JZ(GLNAME(_glapi_fallback_GetError)) + JMP(GL_OFFSET(_gloffset_GetError)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord2fv)) -GL_PREFIX(TexCoord2fv): +GLOBL_FN(GL_PREFIX(GetFloatv)) +GL_PREFIX(GetFloatv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord2fv)) - JMP(GL_OFFSET(_gloffset_TexCoord2fv)) + JZ(GLNAME(_glapi_fallback_GetFloatv)) + JMP(GL_OFFSET(_gloffset_GetFloatv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord2iv)) -GL_PREFIX(TexCoord2iv): +GLOBL_FN(GL_PREFIX(GetIntegerv)) +GL_PREFIX(GetIntegerv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord2iv)) - JMP(GL_OFFSET(_gloffset_TexCoord2iv)) + JZ(GLNAME(_glapi_fallback_GetIntegerv)) + JMP(GL_OFFSET(_gloffset_GetIntegerv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord2sv)) -GL_PREFIX(TexCoord2sv): +GLOBL_FN(GL_PREFIX(GetLightfv)) +GL_PREFIX(GetLightfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord2sv)) - JMP(GL_OFFSET(_gloffset_TexCoord2sv)) + JZ(GLNAME(_glapi_fallback_GetLightfv)) + JMP(GL_OFFSET(_gloffset_GetLightfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord3dv)) -GL_PREFIX(TexCoord3dv): +GLOBL_FN(GL_PREFIX(GetLightiv)) +GL_PREFIX(GetLightiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord3dv)) - JMP(GL_OFFSET(_gloffset_TexCoord3dv)) + JZ(GLNAME(_glapi_fallback_GetLightiv)) + JMP(GL_OFFSET(_gloffset_GetLightiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord3fv)) -GL_PREFIX(TexCoord3fv): +GLOBL_FN(GL_PREFIX(GetMapdv)) +GL_PREFIX(GetMapdv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord3fv)) - JMP(GL_OFFSET(_gloffset_TexCoord3fv)) + JZ(GLNAME(_glapi_fallback_GetMapdv)) + JMP(GL_OFFSET(_gloffset_GetMapdv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord3iv)) -GL_PREFIX(TexCoord3iv): +GLOBL_FN(GL_PREFIX(GetMapfv)) +GL_PREFIX(GetMapfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord3iv)) - JMP(GL_OFFSET(_gloffset_TexCoord3iv)) + JZ(GLNAME(_glapi_fallback_GetMapfv)) + JMP(GL_OFFSET(_gloffset_GetMapfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord3sv)) -GL_PREFIX(TexCoord3sv): +GLOBL_FN(GL_PREFIX(GetMapiv)) +GL_PREFIX(GetMapiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord3sv)) - JMP(GL_OFFSET(_gloffset_TexCoord3sv)) + JZ(GLNAME(_glapi_fallback_GetMapiv)) + JMP(GL_OFFSET(_gloffset_GetMapiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord4dv)) -GL_PREFIX(TexCoord4dv): +GLOBL_FN(GL_PREFIX(GetMaterialfv)) +GL_PREFIX(GetMaterialfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord4dv)) - JMP(GL_OFFSET(_gloffset_TexCoord4dv)) + JZ(GLNAME(_glapi_fallback_GetMaterialfv)) + JMP(GL_OFFSET(_gloffset_GetMaterialfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord4fv)) -GL_PREFIX(TexCoord4fv): +GLOBL_FN(GL_PREFIX(GetMaterialiv)) +GL_PREFIX(GetMaterialiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord4fv)) - JMP(GL_OFFSET(_gloffset_TexCoord4fv)) + JZ(GLNAME(_glapi_fallback_GetMaterialiv)) + JMP(GL_OFFSET(_gloffset_GetMaterialiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord4iv)) -GL_PREFIX(TexCoord4iv): +GLOBL_FN(GL_PREFIX(GetPixelMapfv)) +GL_PREFIX(GetPixelMapfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord4iv)) - JMP(GL_OFFSET(_gloffset_TexCoord4iv)) + JZ(GLNAME(_glapi_fallback_GetPixelMapfv)) + JMP(GL_OFFSET(_gloffset_GetPixelMapfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoord4sv)) -GL_PREFIX(TexCoord4sv): +GLOBL_FN(GL_PREFIX(GetPixelMapuiv)) +GL_PREFIX(GetPixelMapuiv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoord4sv)) - JMP(GL_OFFSET(_gloffset_TexCoord4sv)) + JZ(GLNAME(_glapi_fallback_GetPixelMapuiv)) + JMP(GL_OFFSET(_gloffset_GetPixelMapuiv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexGend)) -GL_PREFIX(TexGend): +GLOBL_FN(GL_PREFIX(GetPixelMapusv)) +GL_PREFIX(GetPixelMapusv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexGend)) - JMP(GL_OFFSET(_gloffset_TexGend)) + JZ(GLNAME(_glapi_fallback_GetPixelMapusv)) + JMP(GL_OFFSET(_gloffset_GetPixelMapusv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexGendv)) -GL_PREFIX(TexGendv): +GLOBL_FN(GL_PREFIX(GetPolygonStipple)) +GL_PREFIX(GetPolygonStipple): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexGendv)) - JMP(GL_OFFSET(_gloffset_TexGendv)) + JZ(GLNAME(_glapi_fallback_GetPolygonStipple)) + JMP(GL_OFFSET(_gloffset_GetPolygonStipple)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexGenf)) -GL_PREFIX(TexGenf): +GLOBL_FN(GL_PREFIX(GetString)) +GL_PREFIX(GetString): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexGenf)) - JMP(GL_OFFSET(_gloffset_TexGenf)) + JZ(GLNAME(_glapi_fallback_GetString)) + JMP(GL_OFFSET(_gloffset_GetString)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexGenfv)) -GL_PREFIX(TexGenfv): +GLOBL_FN(GL_PREFIX(GetTexEnvfv)) +GL_PREFIX(GetTexEnvfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexGenfv)) - JMP(GL_OFFSET(_gloffset_TexGenfv)) + JZ(GLNAME(_glapi_fallback_GetTexEnvfv)) + JMP(GL_OFFSET(_gloffset_GetTexEnvfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexGeni)) -GL_PREFIX(TexGeni): +GLOBL_FN(GL_PREFIX(GetTexEnviv)) +GL_PREFIX(GetTexEnviv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexGeni)) - JMP(GL_OFFSET(_gloffset_TexGeni)) + JZ(GLNAME(_glapi_fallback_GetTexEnviv)) + JMP(GL_OFFSET(_gloffset_GetTexEnviv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexGeniv)) -GL_PREFIX(TexGeniv): +GLOBL_FN(GL_PREFIX(GetTexGendv)) +GL_PREFIX(GetTexGendv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexGeniv)) - JMP(GL_OFFSET(_gloffset_TexGeniv)) + JZ(GLNAME(_glapi_fallback_GetTexGendv)) + JMP(GL_OFFSET(_gloffset_GetTexGendv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexEnvf)) -GL_PREFIX(TexEnvf): +GLOBL_FN(GL_PREFIX(GetTexGenfv)) +GL_PREFIX(GetTexGenfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexEnvf)) - JMP(GL_OFFSET(_gloffset_TexEnvf)) + JZ(GLNAME(_glapi_fallback_GetTexGenfv)) + JMP(GL_OFFSET(_gloffset_GetTexGenfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexEnvfv)) -GL_PREFIX(TexEnvfv): +GLOBL_FN(GL_PREFIX(GetTexGeniv)) +GL_PREFIX(GetTexGeniv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexEnvfv)) - JMP(GL_OFFSET(_gloffset_TexEnvfv)) + JZ(GLNAME(_glapi_fallback_GetTexGeniv)) + JMP(GL_OFFSET(_gloffset_GetTexGeniv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexEnvi)) -GL_PREFIX(TexEnvi): +GLOBL_FN(GL_PREFIX(GetTexImage)) +GL_PREFIX(GetTexImage): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexEnvi)) - JMP(GL_OFFSET(_gloffset_TexEnvi)) + JZ(GLNAME(_glapi_fallback_GetTexImage)) + JMP(GL_OFFSET(_gloffset_GetTexImage)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexEnviv)) -GL_PREFIX(TexEnviv): +GLOBL_FN(GL_PREFIX(GetTexParameterfv)) +GL_PREFIX(GetTexParameterfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexEnviv)) - JMP(GL_OFFSET(_gloffset_TexEnviv)) + JZ(GLNAME(_glapi_fallback_GetTexParameterfv)) + JMP(GL_OFFSET(_gloffset_GetTexParameterfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexImage1D)) -GL_PREFIX(TexImage1D): +GLOBL_FN(GL_PREFIX(GetTexParameteriv)) +GL_PREFIX(GetTexParameteriv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexImage1D)) - JMP(GL_OFFSET(_gloffset_TexImage1D)) + JZ(GLNAME(_glapi_fallback_GetTexParameteriv)) + JMP(GL_OFFSET(_gloffset_GetTexParameteriv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexImage2D)) -GL_PREFIX(TexImage2D): +GLOBL_FN(GL_PREFIX(GetTexLevelParameterfv)) +GL_PREFIX(GetTexLevelParameterfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexImage2D)) - JMP(GL_OFFSET(_gloffset_TexImage2D)) + JZ(GLNAME(_glapi_fallback_GetTexLevelParameterfv)) + JMP(GL_OFFSET(_gloffset_GetTexLevelParameterfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexParameterf)) -GL_PREFIX(TexParameterf): +GLOBL_FN(GL_PREFIX(GetTexLevelParameteriv)) +GL_PREFIX(GetTexLevelParameteriv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexParameterf)) - JMP(GL_OFFSET(_gloffset_TexParameterf)) + JZ(GLNAME(_glapi_fallback_GetTexLevelParameteriv)) + JMP(GL_OFFSET(_gloffset_GetTexLevelParameteriv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexParameterfv)) -GL_PREFIX(TexParameterfv): +GLOBL_FN(GL_PREFIX(IsEnabled)) +GL_PREFIX(IsEnabled): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexParameterfv)) - JMP(GL_OFFSET(_gloffset_TexParameterfv)) + JZ(GLNAME(_glapi_fallback_IsEnabled)) + JMP(GL_OFFSET(_gloffset_IsEnabled)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexParameteri)) -GL_PREFIX(TexParameteri): +GLOBL_FN(GL_PREFIX(IsList)) +GL_PREFIX(IsList): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexParameteri)) - JMP(GL_OFFSET(_gloffset_TexParameteri)) + JZ(GLNAME(_glapi_fallback_IsList)) + JMP(GL_OFFSET(_gloffset_IsList)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexParameteriv)) -GL_PREFIX(TexParameteriv): +GLOBL_FN(GL_PREFIX(DepthRange)) +GL_PREFIX(DepthRange): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexParameteriv)) - JMP(GL_OFFSET(_gloffset_TexParameteriv)) + JZ(GLNAME(_glapi_fallback_DepthRange)) + JMP(GL_OFFSET(_gloffset_DepthRange)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Translated)) -GL_PREFIX(Translated): +GLOBL_FN(GL_PREFIX(Frustum)) +GL_PREFIX(Frustum): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Translated)) - JMP(GL_OFFSET(_gloffset_Translated)) + JZ(GLNAME(_glapi_fallback_Frustum)) + JMP(GL_OFFSET(_gloffset_Frustum)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Translatef)) -GL_PREFIX(Translatef): +GLOBL_FN(GL_PREFIX(LoadIdentity)) +GL_PREFIX(LoadIdentity): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Translatef)) - JMP(GL_OFFSET(_gloffset_Translatef)) + JZ(GLNAME(_glapi_fallback_LoadIdentity)) + JMP(GL_OFFSET(_gloffset_LoadIdentity)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex2d)) -GL_PREFIX(Vertex2d): +GLOBL_FN(GL_PREFIX(LoadMatrixf)) +GL_PREFIX(LoadMatrixf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex2d)) - JMP(GL_OFFSET(_gloffset_Vertex2d)) + JZ(GLNAME(_glapi_fallback_LoadMatrixf)) + JMP(GL_OFFSET(_gloffset_LoadMatrixf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex2dv)) -GL_PREFIX(Vertex2dv): +GLOBL_FN(GL_PREFIX(LoadMatrixd)) +GL_PREFIX(LoadMatrixd): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex2dv)) - JMP(GL_OFFSET(_gloffset_Vertex2dv)) + JZ(GLNAME(_glapi_fallback_LoadMatrixd)) + JMP(GL_OFFSET(_gloffset_LoadMatrixd)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex2f)) -GL_PREFIX(Vertex2f): +GLOBL_FN(GL_PREFIX(MatrixMode)) +GL_PREFIX(MatrixMode): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex2f)) - JMP(GL_OFFSET(_gloffset_Vertex2f)) + JZ(GLNAME(_glapi_fallback_MatrixMode)) + JMP(GL_OFFSET(_gloffset_MatrixMode)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex2fv)) -GL_PREFIX(Vertex2fv): +GLOBL_FN(GL_PREFIX(MultMatrixf)) +GL_PREFIX(MultMatrixf): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex2fv)) - JMP(GL_OFFSET(_gloffset_Vertex2fv)) + JZ(GLNAME(_glapi_fallback_MultMatrixf)) + JMP(GL_OFFSET(_gloffset_MultMatrixf)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex2i)) -GL_PREFIX(Vertex2i): +GLOBL_FN(GL_PREFIX(MultMatrixd)) +GL_PREFIX(MultMatrixd): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex2i)) - JMP(GL_OFFSET(_gloffset_Vertex2i)) + JZ(GLNAME(_glapi_fallback_MultMatrixd)) + JMP(GL_OFFSET(_gloffset_MultMatrixd)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex2iv)) -GL_PREFIX(Vertex2iv): +GLOBL_FN(GL_PREFIX(Ortho)) +GL_PREFIX(Ortho): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex2iv)) - JMP(GL_OFFSET(_gloffset_Vertex2iv)) + JZ(GLNAME(_glapi_fallback_Ortho)) + JMP(GL_OFFSET(_gloffset_Ortho)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex2s)) -GL_PREFIX(Vertex2s): +GLOBL_FN(GL_PREFIX(PopMatrix)) +GL_PREFIX(PopMatrix): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex2s)) - JMP(GL_OFFSET(_gloffset_Vertex2s)) + JZ(GLNAME(_glapi_fallback_PopMatrix)) + JMP(GL_OFFSET(_gloffset_PopMatrix)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex2sv)) -GL_PREFIX(Vertex2sv): +GLOBL_FN(GL_PREFIX(PushMatrix)) +GL_PREFIX(PushMatrix): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex2sv)) - JMP(GL_OFFSET(_gloffset_Vertex2sv)) + JZ(GLNAME(_glapi_fallback_PushMatrix)) + JMP(GL_OFFSET(_gloffset_PushMatrix)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex3d)) -GL_PREFIX(Vertex3d): +GLOBL_FN(GL_PREFIX(Rotated)) +GL_PREFIX(Rotated): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex3d)) - JMP(GL_OFFSET(_gloffset_Vertex3d)) + JZ(GLNAME(_glapi_fallback_Rotated)) + JMP(GL_OFFSET(_gloffset_Rotated)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex3dv)) -GL_PREFIX(Vertex3dv): +GLOBL_FN(GL_PREFIX(Rotatef)) +GL_PREFIX(Rotatef): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex3dv)) - JMP(GL_OFFSET(_gloffset_Vertex3dv)) + JZ(GLNAME(_glapi_fallback_Rotatef)) + JMP(GL_OFFSET(_gloffset_Rotatef)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex3f)) -GL_PREFIX(Vertex3f): +GLOBL_FN(GL_PREFIX(Scaled)) +GL_PREFIX(Scaled): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex3f)) - JMP(GL_OFFSET(_gloffset_Vertex3f)) + JZ(GLNAME(_glapi_fallback_Scaled)) + JMP(GL_OFFSET(_gloffset_Scaled)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex3fv)) -GL_PREFIX(Vertex3fv): +GLOBL_FN(GL_PREFIX(Scalef)) +GL_PREFIX(Scalef): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex3fv)) - JMP(GL_OFFSET(_gloffset_Vertex3fv)) + JZ(GLNAME(_glapi_fallback_Scalef)) + JMP(GL_OFFSET(_gloffset_Scalef)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex3i)) -GL_PREFIX(Vertex3i): +GLOBL_FN(GL_PREFIX(Translated)) +GL_PREFIX(Translated): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex3i)) - JMP(GL_OFFSET(_gloffset_Vertex3i)) + JZ(GLNAME(_glapi_fallback_Translated)) + JMP(GL_OFFSET(_gloffset_Translated)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex3iv)) -GL_PREFIX(Vertex3iv): +GLOBL_FN(GL_PREFIX(Translatef)) +GL_PREFIX(Translatef): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex3iv)) - JMP(GL_OFFSET(_gloffset_Vertex3iv)) + JZ(GLNAME(_glapi_fallback_Translatef)) + JMP(GL_OFFSET(_gloffset_Translatef)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex3s)) -GL_PREFIX(Vertex3s): +GLOBL_FN(GL_PREFIX(Viewport)) +GL_PREFIX(Viewport): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex3s)) - JMP(GL_OFFSET(_gloffset_Vertex3s)) + JZ(GLNAME(_glapi_fallback_Viewport)) + JMP(GL_OFFSET(_gloffset_Viewport)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex3sv)) -GL_PREFIX(Vertex3sv): +GLOBL_FN(GL_PREFIX(ArrayElement)) +GL_PREFIX(ArrayElement): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex3sv)) - JMP(GL_OFFSET(_gloffset_Vertex3sv)) + JZ(GLNAME(_glapi_fallback_ArrayElement)) + JMP(GL_OFFSET(_gloffset_ArrayElement)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex4d)) -GL_PREFIX(Vertex4d): +GLOBL_FN(GL_PREFIX(ColorPointer)) +GL_PREFIX(ColorPointer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex4d)) - JMP(GL_OFFSET(_gloffset_Vertex4d)) + JZ(GLNAME(_glapi_fallback_ColorPointer)) + JMP(GL_OFFSET(_gloffset_ColorPointer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex4dv)) -GL_PREFIX(Vertex4dv): +GLOBL_FN(GL_PREFIX(DisableClientState)) +GL_PREFIX(DisableClientState): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex4dv)) - JMP(GL_OFFSET(_gloffset_Vertex4dv)) + JZ(GLNAME(_glapi_fallback_DisableClientState)) + JMP(GL_OFFSET(_gloffset_DisableClientState)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex4f)) -GL_PREFIX(Vertex4f): +GLOBL_FN(GL_PREFIX(DrawArrays)) +GL_PREFIX(DrawArrays): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex4f)) - JMP(GL_OFFSET(_gloffset_Vertex4f)) + JZ(GLNAME(_glapi_fallback_DrawArrays)) + JMP(GL_OFFSET(_gloffset_DrawArrays)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex4fv)) -GL_PREFIX(Vertex4fv): +GLOBL_FN(GL_PREFIX(DrawElements)) +GL_PREFIX(DrawElements): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex4fv)) - JMP(GL_OFFSET(_gloffset_Vertex4fv)) + JZ(GLNAME(_glapi_fallback_DrawElements)) + JMP(GL_OFFSET(_gloffset_DrawElements)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex4i)) -GL_PREFIX(Vertex4i): +GLOBL_FN(GL_PREFIX(EdgeFlagPointer)) +GL_PREFIX(EdgeFlagPointer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex4i)) - JMP(GL_OFFSET(_gloffset_Vertex4i)) + JZ(GLNAME(_glapi_fallback_EdgeFlagPointer)) + JMP(GL_OFFSET(_gloffset_EdgeFlagPointer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex4iv)) -GL_PREFIX(Vertex4iv): +GLOBL_FN(GL_PREFIX(EnableClientState)) +GL_PREFIX(EnableClientState): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex4iv)) - JMP(GL_OFFSET(_gloffset_Vertex4iv)) + JZ(GLNAME(_glapi_fallback_EnableClientState)) + JMP(GL_OFFSET(_gloffset_EnableClientState)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex4s)) -GL_PREFIX(Vertex4s): +GLOBL_FN(GL_PREFIX(GetPointerv)) +GL_PREFIX(GetPointerv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex4s)) - JMP(GL_OFFSET(_gloffset_Vertex4s)) + JZ(GLNAME(_glapi_fallback_GetPointerv)) + JMP(GL_OFFSET(_gloffset_GetPointerv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Vertex4sv)) -GL_PREFIX(Vertex4sv): +GLOBL_FN(GL_PREFIX(IndexPointer)) +GL_PREFIX(IndexPointer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Vertex4sv)) - JMP(GL_OFFSET(_gloffset_Vertex4sv)) + JZ(GLNAME(_glapi_fallback_IndexPointer)) + JMP(GL_OFFSET(_gloffset_IndexPointer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(Viewport)) -GL_PREFIX(Viewport): +GLOBL_FN(GL_PREFIX(InterleavedArrays)) +GL_PREFIX(InterleavedArrays): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Viewport)) - JMP(GL_OFFSET(_gloffset_Viewport)) + JZ(GLNAME(_glapi_fallback_InterleavedArrays)) + JMP(GL_OFFSET(_gloffset_InterleavedArrays)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(AreTexturesResident)) -GL_PREFIX(AreTexturesResident): +GLOBL_FN(GL_PREFIX(NormalPointer)) +GL_PREFIX(NormalPointer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_AreTexturesResident)) - JMP(GL_OFFSET(_gloffset_AreTexturesResident)) + JZ(GLNAME(_glapi_fallback_NormalPointer)) + JMP(GL_OFFSET(_gloffset_NormalPointer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ArrayElement)) -GL_PREFIX(ArrayElement): +GLOBL_FN(GL_PREFIX(TexCoordPointer)) +GL_PREFIX(TexCoordPointer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ArrayElement)) - JMP(GL_OFFSET(_gloffset_ArrayElement)) + JZ(GLNAME(_glapi_fallback_TexCoordPointer)) + JMP(GL_OFFSET(_gloffset_TexCoordPointer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(BindTexture)) -GL_PREFIX(BindTexture): +GLOBL_FN(GL_PREFIX(VertexPointer)) +GL_PREFIX(VertexPointer): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_BindTexture)) - JMP(GL_OFFSET(_gloffset_BindTexture)) + JZ(GLNAME(_glapi_fallback_VertexPointer)) + JMP(GL_OFFSET(_gloffset_VertexPointer)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorPointer)) -GL_PREFIX(ColorPointer): +GLOBL_FN(GL_PREFIX(PolygonOffset)) +GL_PREFIX(PolygonOffset): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorPointer)) - JMP(GL_OFFSET(_gloffset_ColorPointer)) + JZ(GLNAME(_glapi_fallback_PolygonOffset)) + JMP(GL_OFFSET(_gloffset_PolygonOffset)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(CopyTexImage1D)) @@ -2572,44 +2612,44 @@ GL_PREFIX(CopyTexSubImage2D): JMP(GL_OFFSET(_gloffset_CopyTexSubImage2D)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DeleteTextures)) -GL_PREFIX(DeleteTextures): +GLOBL_FN(GL_PREFIX(TexSubImage1D)) +GL_PREFIX(TexSubImage1D): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DeleteTextures)) - JMP(GL_OFFSET(_gloffset_DeleteTextures)) + JZ(GLNAME(_glapi_fallback_TexSubImage1D)) + JMP(GL_OFFSET(_gloffset_TexSubImage1D)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DisableClientState)) -GL_PREFIX(DisableClientState): +GLOBL_FN(GL_PREFIX(TexSubImage2D)) +GL_PREFIX(TexSubImage2D): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DisableClientState)) - JMP(GL_OFFSET(_gloffset_DisableClientState)) + JZ(GLNAME(_glapi_fallback_TexSubImage2D)) + JMP(GL_OFFSET(_gloffset_TexSubImage2D)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DrawArrays)) -GL_PREFIX(DrawArrays): +GLOBL_FN(GL_PREFIX(AreTexturesResident)) +GL_PREFIX(AreTexturesResident): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DrawArrays)) - JMP(GL_OFFSET(_gloffset_DrawArrays)) + JZ(GLNAME(_glapi_fallback_AreTexturesResident)) + JMP(GL_OFFSET(_gloffset_AreTexturesResident)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EdgeFlagPointer)) -GL_PREFIX(EdgeFlagPointer): +GLOBL_FN(GL_PREFIX(BindTexture)) +GL_PREFIX(BindTexture): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EdgeFlagPointer)) - JMP(GL_OFFSET(_gloffset_EdgeFlagPointer)) + JZ(GLNAME(_glapi_fallback_BindTexture)) + JMP(GL_OFFSET(_gloffset_BindTexture)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EnableClientState)) -GL_PREFIX(EnableClientState): +GLOBL_FN(GL_PREFIX(DeleteTextures)) +GL_PREFIX(DeleteTextures): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_EnableClientState)) - JMP(GL_OFFSET(_gloffset_EnableClientState)) + JZ(GLNAME(_glapi_fallback_DeleteTextures)) + JMP(GL_OFFSET(_gloffset_DeleteTextures)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(GenTextures)) @@ -2620,20 +2660,20 @@ GL_PREFIX(GenTextures): JMP(GL_OFFSET(_gloffset_GenTextures)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetPointerv)) -GL_PREFIX(GetPointerv): +GLOBL_FN(GL_PREFIX(IsTexture)) +GL_PREFIX(IsTexture): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetPointerv)) - JMP(GL_OFFSET(_gloffset_GetPointerv)) + JZ(GLNAME(_glapi_fallback_IsTexture)) + JMP(GL_OFFSET(_gloffset_IsTexture)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(IndexPointer)) -GL_PREFIX(IndexPointer): +GLOBL_FN(GL_PREFIX(PrioritizeTextures)) +GL_PREFIX(PrioritizeTextures): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_IndexPointer)) - JMP(GL_OFFSET(_gloffset_IndexPointer)) + JZ(GLNAME(_glapi_fallback_PrioritizeTextures)) + JMP(GL_OFFSET(_gloffset_PrioritizeTextures)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Indexub)) @@ -2652,38 +2692,6 @@ GL_PREFIX(Indexubv): JMP(GL_OFFSET(_gloffset_Indexubv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(InterleavedArrays)) -GL_PREFIX(InterleavedArrays): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_InterleavedArrays)) - JMP(GL_OFFSET(_gloffset_InterleavedArrays)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(IsTexture)) -GL_PREFIX(IsTexture): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_IsTexture)) - JMP(GL_OFFSET(_gloffset_IsTexture)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(NormalPointer)) -GL_PREFIX(NormalPointer): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_NormalPointer)) - JMP(GL_OFFSET(_gloffset_NormalPointer)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PolygonOffset)) -GL_PREFIX(PolygonOffset): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PolygonOffset)) - JMP(GL_OFFSET(_gloffset_PolygonOffset)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(PopClientAttrib)) GL_PREFIX(PopClientAttrib): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -2692,14 +2700,6 @@ GL_PREFIX(PopClientAttrib): JMP(GL_OFFSET(_gloffset_PopClientAttrib)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PrioritizeTextures)) -GL_PREFIX(PrioritizeTextures): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PrioritizeTextures)) - JMP(GL_OFFSET(_gloffset_PrioritizeTextures)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(PushClientAttrib)) GL_PREFIX(PushClientAttrib): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -2708,84 +2708,84 @@ GL_PREFIX(PushClientAttrib): JMP(GL_OFFSET(_gloffset_PushClientAttrib)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoordPointer)) -GL_PREFIX(TexCoordPointer): +GLOBL_FN(GL_PREFIX(BlendColor)) +GL_PREFIX(BlendColor): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexCoordPointer)) - JMP(GL_OFFSET(_gloffset_TexCoordPointer)) + JZ(GLNAME(_glapi_fallback_BlendColor)) + JMP(GL_OFFSET(_gloffset_BlendColor)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexSubImage1D)) -GL_PREFIX(TexSubImage1D): +GLOBL_FN(GL_PREFIX(BlendEquation)) +GL_PREFIX(BlendEquation): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexSubImage1D)) - JMP(GL_OFFSET(_gloffset_TexSubImage1D)) + JZ(GLNAME(_glapi_fallback_BlendEquation)) + JMP(GL_OFFSET(_gloffset_BlendEquation)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexSubImage2D)) -GL_PREFIX(TexSubImage2D): +GLOBL_FN(GL_PREFIX(DrawRangeElements)) +GL_PREFIX(DrawRangeElements): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexSubImage2D)) - JMP(GL_OFFSET(_gloffset_TexSubImage2D)) + JZ(GLNAME(_glapi_fallback_DrawRangeElements)) + JMP(GL_OFFSET(_gloffset_DrawRangeElements)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(VertexPointer)) -GL_PREFIX(VertexPointer): +GLOBL_FN(GL_PREFIX(ColorTable)) +GL_PREFIX(ColorTable): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_VertexPointer)) - JMP(GL_OFFSET(_gloffset_VertexPointer)) + JZ(GLNAME(_glapi_fallback_ColorTable)) + JMP(GL_OFFSET(_gloffset_ColorTable)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CopyTexSubImage3D)) -GL_PREFIX(CopyTexSubImage3D): +GLOBL_FN(GL_PREFIX(ColorTableParameterfv)) +GL_PREFIX(ColorTableParameterfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyTexSubImage3D)) - JMP(GL_OFFSET(_gloffset_CopyTexSubImage3D)) + JZ(GLNAME(_glapi_fallback_ColorTableParameterfv)) + JMP(GL_OFFSET(_gloffset_ColorTableParameterfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DrawRangeElements)) -GL_PREFIX(DrawRangeElements): +GLOBL_FN(GL_PREFIX(ColorTableParameteriv)) +GL_PREFIX(ColorTableParameteriv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DrawRangeElements)) - JMP(GL_OFFSET(_gloffset_DrawRangeElements)) + JZ(GLNAME(_glapi_fallback_ColorTableParameteriv)) + JMP(GL_OFFSET(_gloffset_ColorTableParameteriv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexImage3D)) -GL_PREFIX(TexImage3D): +GLOBL_FN(GL_PREFIX(CopyColorTable)) +GL_PREFIX(CopyColorTable): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexImage3D)) - JMP(GL_OFFSET(_gloffset_TexImage3D)) + JZ(GLNAME(_glapi_fallback_CopyColorTable)) + JMP(GL_OFFSET(_gloffset_CopyColorTable)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexSubImage3D)) -GL_PREFIX(TexSubImage3D): +GLOBL_FN(GL_PREFIX(GetColorTable)) +GL_PREFIX(GetColorTable): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexSubImage3D)) - JMP(GL_OFFSET(_gloffset_TexSubImage3D)) + JZ(GLNAME(_glapi_fallback_GetColorTable)) + JMP(GL_OFFSET(_gloffset_GetColorTable)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(BlendColor)) -GL_PREFIX(BlendColor): +GLOBL_FN(GL_PREFIX(GetColorTableParameterfv)) +GL_PREFIX(GetColorTableParameterfv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_BlendColor)) - JMP(GL_OFFSET(_gloffset_BlendColor)) + JZ(GLNAME(_glapi_fallback_GetColorTableParameterfv)) + JMP(GL_OFFSET(_gloffset_GetColorTableParameterfv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(BlendEquation)) -GL_PREFIX(BlendEquation): +GLOBL_FN(GL_PREFIX(GetColorTableParameteriv)) +GL_PREFIX(GetColorTableParameteriv): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_BlendEquation)) - JMP(GL_OFFSET(_gloffset_BlendEquation)) + JZ(GLNAME(_glapi_fallback_GetColorTableParameteriv)) + JMP(GL_OFFSET(_gloffset_GetColorTableParameteriv)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(ColorSubTable)) @@ -2796,28 +2796,12 @@ GL_PREFIX(ColorSubTable): JMP(GL_OFFSET(_gloffset_ColorSubTable)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorTable)) -GL_PREFIX(ColorTable): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorTable)) - JMP(GL_OFFSET(_gloffset_ColorTable)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorTableParameterfv)) -GL_PREFIX(ColorTableParameterfv): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorTableParameterfv)) - JMP(GL_OFFSET(_gloffset_ColorTableParameterfv)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorTableParameteriv)) -GL_PREFIX(ColorTableParameteriv): +GLOBL_FN(GL_PREFIX(CopyColorSubTable)) +GL_PREFIX(CopyColorSubTable): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorTableParameteriv)) - JMP(GL_OFFSET(_gloffset_ColorTableParameteriv)) + JZ(GLNAME(_glapi_fallback_CopyColorSubTable)) + JMP(GL_OFFSET(_gloffset_CopyColorSubTable)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(ConvolutionFilter1D)) @@ -2868,22 +2852,6 @@ GL_PREFIX(ConvolutionParameteriv): JMP(GL_OFFSET(_gloffset_ConvolutionParameteriv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CopyColorSubTable)) -GL_PREFIX(CopyColorSubTable): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyColorSubTable)) - JMP(GL_OFFSET(_gloffset_CopyColorSubTable)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CopyColorTable)) -GL_PREFIX(CopyColorTable): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyColorTable)) - JMP(GL_OFFSET(_gloffset_CopyColorTable)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(CopyConvolutionFilter1D)) GL_PREFIX(CopyConvolutionFilter1D): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -2900,30 +2868,6 @@ GL_PREFIX(CopyConvolutionFilter2D): JMP(GL_OFFSET(_gloffset_CopyConvolutionFilter2D)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetColorTable)) -GL_PREFIX(GetColorTable): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetColorTable)) - JMP(GL_OFFSET(_gloffset_GetColorTable)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetColorTableParameterfv)) -GL_PREFIX(GetColorTableParameterfv): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetColorTableParameterfv)) - JMP(GL_OFFSET(_gloffset_GetColorTableParameterfv)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetColorTableParameteriv)) -GL_PREFIX(GetColorTableParameteriv): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetColorTableParameteriv)) - JMP(GL_OFFSET(_gloffset_GetColorTableParameteriv)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(GetConvolutionFilter)) GL_PREFIX(GetConvolutionFilter): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -2948,6 +2892,22 @@ GL_PREFIX(GetConvolutionParameteriv): JMP(GL_OFFSET(_gloffset_GetConvolutionParameteriv)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(GetSeparableFilter)) +GL_PREFIX(GetSeparableFilter): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_GetSeparableFilter)) + JMP(GL_OFFSET(_gloffset_GetSeparableFilter)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(SeparableFilter2D)) +GL_PREFIX(SeparableFilter2D): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_SeparableFilter2D)) + JMP(GL_OFFSET(_gloffset_SeparableFilter2D)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(GetHistogram)) GL_PREFIX(GetHistogram): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -2996,14 +2956,6 @@ GL_PREFIX(GetMinmaxParameteriv): JMP(GL_OFFSET(_gloffset_GetMinmaxParameteriv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetSeparableFilter)) -GL_PREFIX(GetSeparableFilter): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetSeparableFilter)) - JMP(GL_OFFSET(_gloffset_GetSeparableFilter)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(Histogram)) GL_PREFIX(Histogram): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -3020,6 +2972,14 @@ GL_PREFIX(Minmax): JMP(GL_OFFSET(_gloffset_Minmax)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(ResetHistogram)) +GL_PREFIX(ResetHistogram): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_ResetHistogram)) + JMP(GL_OFFSET(_gloffset_ResetHistogram)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(ResetMinmax)) GL_PREFIX(ResetMinmax): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -3028,20 +2988,28 @@ GL_PREFIX(ResetMinmax): JMP(GL_OFFSET(_gloffset_ResetMinmax)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ResetHistogram)) -GL_PREFIX(ResetHistogram): +GLOBL_FN(GL_PREFIX(TexImage3D)) +GL_PREFIX(TexImage3D): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ResetHistogram)) - JMP(GL_OFFSET(_gloffset_ResetHistogram)) + JZ(GLNAME(_glapi_fallback_TexImage3D)) + JMP(GL_OFFSET(_gloffset_TexImage3D)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SeparableFilter2D)) -GL_PREFIX(SeparableFilter2D): +GLOBL_FN(GL_PREFIX(TexSubImage3D)) +GL_PREFIX(TexSubImage3D): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SeparableFilter2D)) - JMP(GL_OFFSET(_gloffset_SeparableFilter2D)) + JZ(GLNAME(_glapi_fallback_TexSubImage3D)) + JMP(GL_OFFSET(_gloffset_TexSubImage3D)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CopyTexSubImage3D)) +GL_PREFIX(CopyTexSubImage3D): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CopyTexSubImage3D)) + JMP(GL_OFFSET(_gloffset_CopyTexSubImage3D)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(ActiveTextureARB)) @@ -3316,11 +3284,115 @@ GL_PREFIX(MultiTexCoord4svARB): JMP(GL_OFFSET(_gloffset_MultiTexCoord4svARB)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(LoadTransposeMatrixfARB)) +GL_PREFIX(LoadTransposeMatrixfARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_LoadTransposeMatrixfARB)) + JMP(GL_OFFSET(_gloffset_LoadTransposeMatrixfARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(LoadTransposeMatrixdARB)) +GL_PREFIX(LoadTransposeMatrixdARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_LoadTransposeMatrixdARB)) + JMP(GL_OFFSET(_gloffset_LoadTransposeMatrixdARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(MultTransposeMatrixfARB)) +GL_PREFIX(MultTransposeMatrixfARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_MultTransposeMatrixfARB)) + JMP(GL_OFFSET(_gloffset_MultTransposeMatrixfARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(MultTransposeMatrixdARB)) +GL_PREFIX(MultTransposeMatrixdARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_MultTransposeMatrixdARB)) + JMP(GL_OFFSET(_gloffset_MultTransposeMatrixdARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(SampleCoverageARB)) +GL_PREFIX(SampleCoverageARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_SampleCoverageARB)) + JMP(GL_OFFSET(_gloffset_SampleCoverageARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(SamplePassARB)) +GL_PREFIX(SamplePassARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_SamplePassARB)) + JMP(GL_OFFSET(_gloffset_SamplePassARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CompressedTexImage3DARB)) +GL_PREFIX(CompressedTexImage3DARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CompressedTexImage3DARB)) + JMP(GL_OFFSET(_gloffset_CompressedTexImage3DARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CompressedTexImage2DARB)) +GL_PREFIX(CompressedTexImage2DARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CompressedTexImage2DARB)) + JMP(GL_OFFSET(_gloffset_CompressedTexImage2DARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CompressedTexImage1DARB)) +GL_PREFIX(CompressedTexImage1DARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CompressedTexImage1DARB)) + JMP(GL_OFFSET(_gloffset_CompressedTexImage1DARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CompressedTexSubImage3DARB)) +GL_PREFIX(CompressedTexSubImage3DARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CompressedTexSubImage3DARB)) + JMP(GL_OFFSET(_gloffset_CompressedTexSubImage3DARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CompressedTexSubImage2DARB)) +GL_PREFIX(CompressedTexSubImage2DARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CompressedTexSubImage2DARB)) + JMP(GL_OFFSET(_gloffset_CompressedTexSubImage2DARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CompressedTexSubImage1DARB)) +GL_PREFIX(CompressedTexSubImage1DARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CompressedTexSubImage1DARB)) + JMP(GL_OFFSET(_gloffset_CompressedTexSubImage1DARB)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(GetCompressedTexImageARB)) +GL_PREFIX(GetCompressedTexImageARB): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_GetCompressedTexImageARB)) + JMP(GL_OFFSET(_gloffset_GetCompressedTexImageARB)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(BlendColorEXT)) GL_PREFIX(BlendColorEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_BlendColor)) + JZ(GLNAME(_glapi_fallback_BlendColorEXT)) JMP(GL_OFFSET(_gloffset_BlendColor)) ALIGNTEXT16 @@ -3336,7 +3408,7 @@ GLOBL_FN(GL_PREFIX(TexImage3DEXT)) GL_PREFIX(TexImage3DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexImage3D)) + JZ(GLNAME(_glapi_fallback_TexImage3DEXT)) JMP(GL_OFFSET(_gloffset_TexImage3D)) ALIGNTEXT16 @@ -3344,18 +3416,10 @@ GLOBL_FN(GL_PREFIX(TexSubImage3DEXT)) GL_PREFIX(TexSubImage3DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexSubImage3D)) + JZ(GLNAME(_glapi_fallback_TexSubImage3DEXT)) JMP(GL_OFFSET(_gloffset_TexSubImage3D)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CopyTexSubImage3DEXT)) -GL_PREFIX(CopyTexSubImage3DEXT): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyTexSubImage3D)) - JMP(GL_OFFSET(_gloffset_CopyTexSubImage3D)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(GetTexFilterFuncSGIS)) GL_PREFIX(GetTexFilterFuncSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -3372,19 +3436,11 @@ GL_PREFIX(TexFilterFuncSGIS): JMP(GL_OFFSET(_gloffset_TexFilterFuncSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CopyTexSubImage1DEXT)) -GL_PREFIX(CopyTexSubImage1DEXT): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyTexSubImage1D)) - JMP(GL_OFFSET(_gloffset_CopyTexSubImage1D)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(TexSubImage1DEXT)) GL_PREFIX(TexSubImage1DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexSubImage1D)) + JZ(GLNAME(_glapi_fallback_TexSubImage1DEXT)) JMP(GL_OFFSET(_gloffset_TexSubImage1D)) ALIGNTEXT16 @@ -3392,7 +3448,7 @@ GLOBL_FN(GL_PREFIX(TexSubImage2DEXT)) GL_PREFIX(TexSubImage2DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexSubImage2D)) + JZ(GLNAME(_glapi_fallback_TexSubImage2DEXT)) JMP(GL_OFFSET(_gloffset_TexSubImage2D)) ALIGNTEXT16 @@ -3400,7 +3456,7 @@ GLOBL_FN(GL_PREFIX(CopyTexImage1DEXT)) GL_PREFIX(CopyTexImage1DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyTexImage1D)) + JZ(GLNAME(_glapi_fallback_CopyTexImage1DEXT)) JMP(GL_OFFSET(_gloffset_CopyTexImage1D)) ALIGNTEXT16 @@ -3408,18 +3464,34 @@ GLOBL_FN(GL_PREFIX(CopyTexImage2DEXT)) GL_PREFIX(CopyTexImage2DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyTexImage2D)) + JZ(GLNAME(_glapi_fallback_CopyTexImage2DEXT)) JMP(GL_OFFSET(_gloffset_CopyTexImage2D)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CopyTexSubImage1DEXT)) +GL_PREFIX(CopyTexSubImage1DEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CopyTexSubImage1DEXT)) + JMP(GL_OFFSET(_gloffset_CopyTexSubImage1D)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(CopyTexSubImage2DEXT)) GL_PREFIX(CopyTexSubImage2DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyTexSubImage2D)) + JZ(GLNAME(_glapi_fallback_CopyTexSubImage2DEXT)) JMP(GL_OFFSET(_gloffset_CopyTexSubImage2D)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(CopyTexSubImage3DEXT)) +GL_PREFIX(CopyTexSubImage3DEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_CopyTexSubImage3DEXT)) + JMP(GL_OFFSET(_gloffset_CopyTexSubImage3D)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(GetHistogramEXT)) GL_PREFIX(GetHistogramEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -3472,7 +3544,7 @@ GLOBL_FN(GL_PREFIX(HistogramEXT)) GL_PREFIX(HistogramEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Histogram)) + JZ(GLNAME(_glapi_fallback_HistogramEXT)) JMP(GL_OFFSET(_gloffset_Histogram)) ALIGNTEXT16 @@ -3480,7 +3552,7 @@ GLOBL_FN(GL_PREFIX(MinmaxEXT)) GL_PREFIX(MinmaxEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_Minmax)) + JZ(GLNAME(_glapi_fallback_MinmaxEXT)) JMP(GL_OFFSET(_gloffset_Minmax)) ALIGNTEXT16 @@ -3488,7 +3560,7 @@ GLOBL_FN(GL_PREFIX(ResetHistogramEXT)) GL_PREFIX(ResetHistogramEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ResetHistogram)) + JZ(GLNAME(_glapi_fallback_ResetHistogramEXT)) JMP(GL_OFFSET(_gloffset_ResetHistogram)) ALIGNTEXT16 @@ -3496,7 +3568,7 @@ GLOBL_FN(GL_PREFIX(ResetMinmaxEXT)) GL_PREFIX(ResetMinmaxEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ResetMinmax)) + JZ(GLNAME(_glapi_fallback_ResetMinmaxEXT)) JMP(GL_OFFSET(_gloffset_ResetMinmax)) ALIGNTEXT16 @@ -3504,7 +3576,7 @@ GLOBL_FN(GL_PREFIX(ConvolutionFilter1DEXT)) GL_PREFIX(ConvolutionFilter1DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ConvolutionFilter1D)) + JZ(GLNAME(_glapi_fallback_ConvolutionFilter1DEXT)) JMP(GL_OFFSET(_gloffset_ConvolutionFilter1D)) ALIGNTEXT16 @@ -3512,7 +3584,7 @@ GLOBL_FN(GL_PREFIX(ConvolutionFilter2DEXT)) GL_PREFIX(ConvolutionFilter2DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ConvolutionFilter2D)) + JZ(GLNAME(_glapi_fallback_ConvolutionFilter2DEXT)) JMP(GL_OFFSET(_gloffset_ConvolutionFilter2D)) ALIGNTEXT16 @@ -3520,7 +3592,7 @@ GLOBL_FN(GL_PREFIX(ConvolutionParameterfEXT)) GL_PREFIX(ConvolutionParameterfEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ConvolutionParameterf)) + JZ(GLNAME(_glapi_fallback_ConvolutionParameterfEXT)) JMP(GL_OFFSET(_gloffset_ConvolutionParameterf)) ALIGNTEXT16 @@ -3528,7 +3600,7 @@ GLOBL_FN(GL_PREFIX(ConvolutionParameterfvEXT)) GL_PREFIX(ConvolutionParameterfvEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ConvolutionParameterfv)) + JZ(GLNAME(_glapi_fallback_ConvolutionParameterfvEXT)) JMP(GL_OFFSET(_gloffset_ConvolutionParameterfv)) ALIGNTEXT16 @@ -3536,7 +3608,7 @@ GLOBL_FN(GL_PREFIX(ConvolutionParameteriEXT)) GL_PREFIX(ConvolutionParameteriEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ConvolutionParameteri)) + JZ(GLNAME(_glapi_fallback_ConvolutionParameteriEXT)) JMP(GL_OFFSET(_gloffset_ConvolutionParameteri)) ALIGNTEXT16 @@ -3544,7 +3616,7 @@ GLOBL_FN(GL_PREFIX(ConvolutionParameterivEXT)) GL_PREFIX(ConvolutionParameterivEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ConvolutionParameteriv)) + JZ(GLNAME(_glapi_fallback_ConvolutionParameterivEXT)) JMP(GL_OFFSET(_gloffset_ConvolutionParameteriv)) ALIGNTEXT16 @@ -3552,7 +3624,7 @@ GLOBL_FN(GL_PREFIX(CopyConvolutionFilter1DEXT)) GL_PREFIX(CopyConvolutionFilter1DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyConvolutionFilter1D)) + JZ(GLNAME(_glapi_fallback_CopyConvolutionFilter1DEXT)) JMP(GL_OFFSET(_gloffset_CopyConvolutionFilter1D)) ALIGNTEXT16 @@ -3560,7 +3632,7 @@ GLOBL_FN(GL_PREFIX(CopyConvolutionFilter2DEXT)) GL_PREFIX(CopyConvolutionFilter2DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyConvolutionFilter2D)) + JZ(GLNAME(_glapi_fallback_CopyConvolutionFilter2DEXT)) JMP(GL_OFFSET(_gloffset_CopyConvolutionFilter2D)) ALIGNTEXT16 @@ -3600,15 +3672,23 @@ GLOBL_FN(GL_PREFIX(SeparableFilter2DEXT)) GL_PREFIX(SeparableFilter2DEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SeparableFilter2D)) + JZ(GLNAME(_glapi_fallback_SeparableFilter2DEXT)) JMP(GL_OFFSET(_gloffset_SeparableFilter2D)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(ColorTableSGI)) +GL_PREFIX(ColorTableSGI): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_ColorTableSGI)) + JMP(GL_OFFSET(_gloffset_ColorTable)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(ColorTableParameterfvSGI)) GL_PREFIX(ColorTableParameterfvSGI): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorTableParameterfv)) + JZ(GLNAME(_glapi_fallback_ColorTableParameterfvSGI)) JMP(GL_OFFSET(_gloffset_ColorTableParameterfv)) ALIGNTEXT16 @@ -3616,23 +3696,15 @@ GLOBL_FN(GL_PREFIX(ColorTableParameterivSGI)) GL_PREFIX(ColorTableParameterivSGI): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorTableParameteriv)) + JZ(GLNAME(_glapi_fallback_ColorTableParameterivSGI)) JMP(GL_OFFSET(_gloffset_ColorTableParameteriv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorTableSGI)) -GL_PREFIX(ColorTableSGI): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorTable)) - JMP(GL_OFFSET(_gloffset_ColorTable)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(CopyColorTableSGI)) GL_PREFIX(CopyColorTableSGI): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyColorTable)) + JZ(GLNAME(_glapi_fallback_CopyColorTableSGI)) JMP(GL_OFFSET(_gloffset_CopyColorTable)) ALIGNTEXT16 @@ -3660,493 +3732,324 @@ GL_PREFIX(GetColorTableParameterivSGI): JMP(GL_OFFSET(_gloffset_GetColorTableParameterivSGI)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GenTexturesEXT)) -GL_PREFIX(GenTexturesEXT): +GLOBL_FN(GL_PREFIX(PixelTexGenSGIX)) +GL_PREFIX(PixelTexGenSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GenTexturesEXT)) - JMP(GL_OFFSET(_gloffset_GenTexturesEXT)) + JZ(GLNAME(_glapi_fallback_PixelTexGenSGIX)) + JMP(GL_OFFSET(_gloffset_PixelTexGenSGIX)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DeleteTexturesEXT)) -GL_PREFIX(DeleteTexturesEXT): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DeleteTextures)) - JMP(GL_OFFSET(_gloffset_DeleteTextures)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(BindTextureEXT)) -GL_PREFIX(BindTextureEXT): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_BindTexture)) - JMP(GL_OFFSET(_gloffset_BindTexture)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PrioritizeTexturesEXT)) -GL_PREFIX(PrioritizeTexturesEXT): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PrioritizeTextures)) - JMP(GL_OFFSET(_gloffset_PrioritizeTextures)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(AreTexturesResidentEXT)) -GL_PREFIX(AreTexturesResidentEXT): +GLOBL_FN(GL_PREFIX(PixelTexGenParameteriSGIS)) +GL_PREFIX(PixelTexGenParameteriSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_AreTexturesResidentEXT)) - JMP(GL_OFFSET(_gloffset_AreTexturesResidentEXT)) + JZ(GLNAME(_glapi_fallback_PixelTexGenParameteriSGIS)) + JMP(GL_OFFSET(_gloffset_PixelTexGenParameteriSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(IsTextureEXT)) -GL_PREFIX(IsTextureEXT): +GLOBL_FN(GL_PREFIX(PixelTexGenParameterivSGIS)) +GL_PREFIX(PixelTexGenParameterivSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_IsTextureEXT)) - JMP(GL_OFFSET(_gloffset_IsTextureEXT)) + JZ(GLNAME(_glapi_fallback_PixelTexGenParameterivSGIS)) + JMP(GL_OFFSET(_gloffset_PixelTexGenParameterivSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(BlendEquationEXT)) -GL_PREFIX(BlendEquationEXT): +GLOBL_FN(GL_PREFIX(PixelTexGenParameterfSGIS)) +GL_PREFIX(PixelTexGenParameterfSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_BlendEquation)) - JMP(GL_OFFSET(_gloffset_BlendEquation)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(VertexPointerEXT)) -GL_PREFIX(VertexPointerEXT): - JMP(GLNAME(_glapi_fallback_VertexPointerEXT)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(NormalPointerEXT)) -GL_PREFIX(NormalPointerEXT): - JMP(GLNAME(_glapi_fallback_NormalPointerEXT)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorPointerEXT)) -GL_PREFIX(ColorPointerEXT): - JMP(GLNAME(_glapi_fallback_ColorPointerEXT)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(IndexPointerEXT)) -GL_PREFIX(IndexPointerEXT): - JMP(GLNAME(_glapi_fallback_IndexPointerEXT)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexCoordPointerEXT)) -GL_PREFIX(TexCoordPointerEXT): - JMP(GLNAME(_glapi_fallback_TexCoordPointerEXT)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(EdgeFlagPointerEXT)) -GL_PREFIX(EdgeFlagPointerEXT): - JMP(GLNAME(_glapi_fallback_EdgeFlagPointerEXT)) + JZ(GLNAME(_glapi_fallback_PixelTexGenParameterfSGIS)) + JMP(GL_OFFSET(_gloffset_PixelTexGenParameterfSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetPointervEXT)) -GL_PREFIX(GetPointervEXT): +GLOBL_FN(GL_PREFIX(PixelTexGenParameterfvSGIS)) +GL_PREFIX(PixelTexGenParameterfvSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetPointerv)) - JMP(GL_OFFSET(_gloffset_GetPointerv)) + JZ(GLNAME(_glapi_fallback_PixelTexGenParameterfvSGIS)) + JMP(GL_OFFSET(_gloffset_PixelTexGenParameterfvSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ArrayElementEXT)) -GL_PREFIX(ArrayElementEXT): +GLOBL_FN(GL_PREFIX(GetPixelTexGenParameterivSGIS)) +GL_PREFIX(GetPixelTexGenParameterivSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ArrayElement)) - JMP(GL_OFFSET(_gloffset_ArrayElement)) + JZ(GLNAME(_glapi_fallback_GetPixelTexGenParameterivSGIS)) + JMP(GL_OFFSET(_gloffset_GetPixelTexGenParameterivSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DrawArraysEXT)) -GL_PREFIX(DrawArraysEXT): +GLOBL_FN(GL_PREFIX(GetPixelTexGenParameterfvSGIS)) +GL_PREFIX(GetPixelTexGenParameterfvSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DrawArrays)) - JMP(GL_OFFSET(_gloffset_DrawArrays)) + JZ(GLNAME(_glapi_fallback_GetPixelTexGenParameterfvSGIS)) + JMP(GL_OFFSET(_gloffset_GetPixelTexGenParameterfvSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PointParameterfEXT)) -GL_PREFIX(PointParameterfEXT): +GLOBL_FN(GL_PREFIX(TexImage4DSGIS)) +GL_PREFIX(TexImage4DSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PointParameterfEXT)) - JMP(GL_OFFSET(_gloffset_PointParameterfEXT)) + JZ(GLNAME(_glapi_fallback_TexImage4DSGIS)) + JMP(GL_OFFSET(_gloffset_TexImage4DSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PointParameterfvEXT)) -GL_PREFIX(PointParameterfvEXT): +GLOBL_FN(GL_PREFIX(TexSubImage4DSGIS)) +GL_PREFIX(TexSubImage4DSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PointParameterfvEXT)) - JMP(GL_OFFSET(_gloffset_PointParameterfvEXT)) + JZ(GLNAME(_glapi_fallback_TexSubImage4DSGIS)) + JMP(GL_OFFSET(_gloffset_TexSubImage4DSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(HintPGI)) -GL_PREFIX(HintPGI): +GLOBL_FN(GL_PREFIX(AreTexturesResidentEXT)) +GL_PREFIX(AreTexturesResidentEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_HintPGI)) - JMP(GL_OFFSET(_gloffset_HintPGI)) + JZ(GLNAME(_glapi_fallback_AreTexturesResidentEXT)) + JMP(GL_OFFSET(_gloffset_AreTexturesResidentEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorTableEXT)) -GL_PREFIX(ColorTableEXT): +GLOBL_FN(GL_PREFIX(BindTextureEXT)) +GL_PREFIX(BindTextureEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorTable)) - JMP(GL_OFFSET(_gloffset_ColorTable)) + JZ(GLNAME(_glapi_fallback_BindTextureEXT)) + JMP(GL_OFFSET(_gloffset_BindTexture)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ColorSubTableEXT)) -GL_PREFIX(ColorSubTableEXT): +GLOBL_FN(GL_PREFIX(DeleteTexturesEXT)) +GL_PREFIX(DeleteTexturesEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ColorSubTable)) - JMP(GL_OFFSET(_gloffset_ColorSubTable)) + JZ(GLNAME(_glapi_fallback_DeleteTexturesEXT)) + JMP(GL_OFFSET(_gloffset_DeleteTextures)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetColorTableEXT)) -GL_PREFIX(GetColorTableEXT): +GLOBL_FN(GL_PREFIX(GenTexturesEXT)) +GL_PREFIX(GenTexturesEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetColorTableEXT)) - JMP(GL_OFFSET(_gloffset_GetColorTableEXT)) + JZ(GLNAME(_glapi_fallback_GenTexturesEXT)) + JMP(GL_OFFSET(_gloffset_GenTexturesEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetColorTableParameterfvEXT)) -GL_PREFIX(GetColorTableParameterfvEXT): +GLOBL_FN(GL_PREFIX(IsTextureEXT)) +GL_PREFIX(IsTextureEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetColorTableParameterfvEXT)) - JMP(GL_OFFSET(_gloffset_GetColorTableParameterfvEXT)) + JZ(GLNAME(_glapi_fallback_IsTextureEXT)) + JMP(GL_OFFSET(_gloffset_IsTextureEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetColorTableParameterivEXT)) -GL_PREFIX(GetColorTableParameterivEXT): +GLOBL_FN(GL_PREFIX(PrioritizeTexturesEXT)) +GL_PREFIX(PrioritizeTexturesEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetColorTableParameterivEXT)) - JMP(GL_OFFSET(_gloffset_GetColorTableParameterivEXT)) + JZ(GLNAME(_glapi_fallback_PrioritizeTexturesEXT)) + JMP(GL_OFFSET(_gloffset_PrioritizeTextures)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LockArraysEXT)) -GL_PREFIX(LockArraysEXT): +GLOBL_FN(GL_PREFIX(DetailTexFuncSGIS)) +GL_PREFIX(DetailTexFuncSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LockArraysEXT)) - JMP(GL_OFFSET(_gloffset_LockArraysEXT)) + JZ(GLNAME(_glapi_fallback_DetailTexFuncSGIS)) + JMP(GL_OFFSET(_gloffset_DetailTexFuncSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(UnlockArraysEXT)) -GL_PREFIX(UnlockArraysEXT): +GLOBL_FN(GL_PREFIX(GetDetailTexFuncSGIS)) +GL_PREFIX(GetDetailTexFuncSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_UnlockArraysEXT)) - JMP(GL_OFFSET(_gloffset_UnlockArraysEXT)) + JZ(GLNAME(_glapi_fallback_GetDetailTexFuncSGIS)) + JMP(GL_OFFSET(_gloffset_GetDetailTexFuncSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(BlendFuncSeparateINGR)) -GL_PREFIX(BlendFuncSeparateINGR): +GLOBL_FN(GL_PREFIX(SharpenTexFuncSGIS)) +GL_PREFIX(SharpenTexFuncSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_BlendFuncSeparateEXT)) - JMP(GL_OFFSET(_gloffset_BlendFuncSeparateEXT)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos2iMESA)) -GL_PREFIX(WindowPos2iMESA): - JMP(GLNAME(_glapi_fallback_WindowPos2iMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos2sMESA)) -GL_PREFIX(WindowPos2sMESA): - JMP(GLNAME(_glapi_fallback_WindowPos2sMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos2fMESA)) -GL_PREFIX(WindowPos2fMESA): - JMP(GLNAME(_glapi_fallback_WindowPos2fMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos2dMESA)) -GL_PREFIX(WindowPos2dMESA): - JMP(GLNAME(_glapi_fallback_WindowPos2dMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos2ivMESA)) -GL_PREFIX(WindowPos2ivMESA): - JMP(GLNAME(_glapi_fallback_WindowPos2ivMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos2svMESA)) -GL_PREFIX(WindowPos2svMESA): - JMP(GLNAME(_glapi_fallback_WindowPos2svMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos2fvMESA)) -GL_PREFIX(WindowPos2fvMESA): - JMP(GLNAME(_glapi_fallback_WindowPos2fvMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos2dvMESA)) -GL_PREFIX(WindowPos2dvMESA): - JMP(GLNAME(_glapi_fallback_WindowPos2dvMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos3iMESA)) -GL_PREFIX(WindowPos3iMESA): - JMP(GLNAME(_glapi_fallback_WindowPos3iMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos3sMESA)) -GL_PREFIX(WindowPos3sMESA): - JMP(GLNAME(_glapi_fallback_WindowPos3sMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos3fMESA)) -GL_PREFIX(WindowPos3fMESA): - JMP(GLNAME(_glapi_fallback_WindowPos3fMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos3dMESA)) -GL_PREFIX(WindowPos3dMESA): - JMP(GLNAME(_glapi_fallback_WindowPos3dMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos3ivMESA)) -GL_PREFIX(WindowPos3ivMESA): - JMP(GLNAME(_glapi_fallback_WindowPos3ivMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos3svMESA)) -GL_PREFIX(WindowPos3svMESA): - JMP(GLNAME(_glapi_fallback_WindowPos3svMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos3fvMESA)) -GL_PREFIX(WindowPos3fvMESA): - JMP(GLNAME(_glapi_fallback_WindowPos3fvMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos3dvMESA)) -GL_PREFIX(WindowPos3dvMESA): - JMP(GLNAME(_glapi_fallback_WindowPos3dvMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos4iMESA)) -GL_PREFIX(WindowPos4iMESA): - JMP(GLNAME(_glapi_fallback_WindowPos4iMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos4sMESA)) -GL_PREFIX(WindowPos4sMESA): - JMP(GLNAME(_glapi_fallback_WindowPos4sMESA)) + JZ(GLNAME(_glapi_fallback_SharpenTexFuncSGIS)) + JMP(GL_OFFSET(_gloffset_SharpenTexFuncSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos4fMESA)) -GL_PREFIX(WindowPos4fMESA): +GLOBL_FN(GL_PREFIX(GetSharpenTexFuncSGIS)) +GL_PREFIX(GetSharpenTexFuncSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_WindowPos4fMESA)) - JMP(GL_OFFSET(_gloffset_WindowPos4fMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos4dMESA)) -GL_PREFIX(WindowPos4dMESA): - JMP(GLNAME(_glapi_fallback_WindowPos4dMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos4ivMESA)) -GL_PREFIX(WindowPos4ivMESA): - JMP(GLNAME(_glapi_fallback_WindowPos4ivMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos4svMESA)) -GL_PREFIX(WindowPos4svMESA): - JMP(GLNAME(_glapi_fallback_WindowPos4svMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos4fvMESA)) -GL_PREFIX(WindowPos4fvMESA): - JMP(GLNAME(_glapi_fallback_WindowPos4fvMESA)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(WindowPos4dvMESA)) -GL_PREFIX(WindowPos4dvMESA): - JMP(GLNAME(_glapi_fallback_WindowPos4dvMESA)) + JZ(GLNAME(_glapi_fallback_GetSharpenTexFuncSGIS)) + JMP(GL_OFFSET(_gloffset_GetSharpenTexFuncSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(ResizeBuffersMESA)) -GL_PREFIX(ResizeBuffersMESA): +GLOBL_FN(GL_PREFIX(SampleMaskSGIS)) +GL_PREFIX(SampleMaskSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_ResizeBuffersMESA)) - JMP(GL_OFFSET(_gloffset_ResizeBuffersMESA)) + JZ(GLNAME(_glapi_fallback_SampleMaskSGIS)) + JMP(GL_OFFSET(_gloffset_SampleMaskSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LoadTransposeMatrixdARB)) -GL_PREFIX(LoadTransposeMatrixdARB): +GLOBL_FN(GL_PREFIX(SamplePatternSGIS)) +GL_PREFIX(SamplePatternSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LoadTransposeMatrixdARB)) - JMP(GL_OFFSET(_gloffset_LoadTransposeMatrixdARB)) + JZ(GLNAME(_glapi_fallback_SamplePatternSGIS)) + JMP(GL_OFFSET(_gloffset_SamplePatternSGIS)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(LoadTransposeMatrixfARB)) -GL_PREFIX(LoadTransposeMatrixfARB): +GLOBL_FN(GL_PREFIX(ArrayElementEXT)) +GL_PREFIX(ArrayElementEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_LoadTransposeMatrixfARB)) - JMP(GL_OFFSET(_gloffset_LoadTransposeMatrixfARB)) + JZ(GLNAME(_glapi_fallback_ArrayElementEXT)) + JMP(GL_OFFSET(_gloffset_ArrayElement)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MultTransposeMatrixdARB)) -GL_PREFIX(MultTransposeMatrixdARB): +GLOBL_FN(GL_PREFIX(ColorPointerEXT)) +GL_PREFIX(ColorPointerEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MultTransposeMatrixdARB)) - JMP(GL_OFFSET(_gloffset_MultTransposeMatrixdARB)) + JZ(GLNAME(_glapi_fallback_ColorPointerEXT)) + JMP(GL_OFFSET(_gloffset_ColorPointerEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(MultTransposeMatrixfARB)) -GL_PREFIX(MultTransposeMatrixfARB): +GLOBL_FN(GL_PREFIX(DrawArraysEXT)) +GL_PREFIX(DrawArraysEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_MultTransposeMatrixfARB)) - JMP(GL_OFFSET(_gloffset_MultTransposeMatrixfARB)) + JZ(GLNAME(_glapi_fallback_DrawArraysEXT)) + JMP(GL_OFFSET(_gloffset_DrawArrays)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelTexGenParameterfSGIS)) -GL_PREFIX(PixelTexGenParameterfSGIS): +GLOBL_FN(GL_PREFIX(EdgeFlagPointerEXT)) +GL_PREFIX(EdgeFlagPointerEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelTexGenParameterfSGIS)) - JMP(GL_OFFSET(_gloffset_PixelTexGenParameterfSGIS)) + JZ(GLNAME(_glapi_fallback_EdgeFlagPointerEXT)) + JMP(GL_OFFSET(_gloffset_EdgeFlagPointerEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PixelTexGenParameteriSGIS)) -GL_PREFIX(PixelTexGenParameteriSGIS): +GLOBL_FN(GL_PREFIX(GetPointervEXT)) +GL_PREFIX(GetPointervEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PixelTexGenParameteriSGIS)) - JMP(GL_OFFSET(_gloffset_PixelTexGenParameteriSGIS)) + JZ(GLNAME(_glapi_fallback_GetPointervEXT)) + JMP(GL_OFFSET(_gloffset_GetPointerv)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetPixelTexGenParameterfvSGIS)) -GL_PREFIX(GetPixelTexGenParameterfvSGIS): +GLOBL_FN(GL_PREFIX(IndexPointerEXT)) +GL_PREFIX(IndexPointerEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetPixelTexGenParameterfvSGIS)) - JMP(GL_OFFSET(_gloffset_GetPixelTexGenParameterfvSGIS)) + JZ(GLNAME(_glapi_fallback_IndexPointerEXT)) + JMP(GL_OFFSET(_gloffset_IndexPointerEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetPixelTexGenParameterivSGIS)) -GL_PREFIX(GetPixelTexGenParameterivSGIS): +GLOBL_FN(GL_PREFIX(NormalPointerEXT)) +GL_PREFIX(NormalPointerEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetPixelTexGenParameterivSGIS)) - JMP(GL_OFFSET(_gloffset_GetPixelTexGenParameterivSGIS)) + JZ(GLNAME(_glapi_fallback_NormalPointerEXT)) + JMP(GL_OFFSET(_gloffset_NormalPointerEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexImage4DSGIS)) -GL_PREFIX(TexImage4DSGIS): +GLOBL_FN(GL_PREFIX(TexCoordPointerEXT)) +GL_PREFIX(TexCoordPointerEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexImage4DSGIS)) - JMP(GL_OFFSET(_gloffset_TexImage4DSGIS)) + JZ(GLNAME(_glapi_fallback_TexCoordPointerEXT)) + JMP(GL_OFFSET(_gloffset_TexCoordPointerEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TexSubImage4DSGIS)) -GL_PREFIX(TexSubImage4DSGIS): +GLOBL_FN(GL_PREFIX(VertexPointerEXT)) +GL_PREFIX(VertexPointerEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TexSubImage4DSGIS)) - JMP(GL_OFFSET(_gloffset_TexSubImage4DSGIS)) + JZ(GLNAME(_glapi_fallback_VertexPointerEXT)) + JMP(GL_OFFSET(_gloffset_VertexPointerEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(DetailTexFuncSGIS)) -GL_PREFIX(DetailTexFuncSGIS): +GLOBL_FN(GL_PREFIX(BlendEquationEXT)) +GL_PREFIX(BlendEquationEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_DetailTexFuncSGIS)) - JMP(GL_OFFSET(_gloffset_DetailTexFuncSGIS)) + JZ(GLNAME(_glapi_fallback_BlendEquationEXT)) + JMP(GL_OFFSET(_gloffset_BlendEquation)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetDetailTexFuncSGIS)) -GL_PREFIX(GetDetailTexFuncSGIS): +GLOBL_FN(GL_PREFIX(SpriteParameterfSGIX)) +GL_PREFIX(SpriteParameterfSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetDetailTexFuncSGIS)) - JMP(GL_OFFSET(_gloffset_GetDetailTexFuncSGIS)) + JZ(GLNAME(_glapi_fallback_SpriteParameterfSGIX)) + JMP(GL_OFFSET(_gloffset_SpriteParameterfSGIX)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetSharpenTexFuncSGIS)) -GL_PREFIX(GetSharpenTexFuncSGIS): +GLOBL_FN(GL_PREFIX(SpriteParameterfvSGIX)) +GL_PREFIX(SpriteParameterfvSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetSharpenTexFuncSGIS)) - JMP(GL_OFFSET(_gloffset_GetSharpenTexFuncSGIS)) + JZ(GLNAME(_glapi_fallback_SpriteParameterfvSGIX)) + JMP(GL_OFFSET(_gloffset_SpriteParameterfvSGIX)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SharpenTexFuncSGIS)) -GL_PREFIX(SharpenTexFuncSGIS): +GLOBL_FN(GL_PREFIX(SpriteParameteriSGIX)) +GL_PREFIX(SpriteParameteriSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SharpenTexFuncSGIS)) - JMP(GL_OFFSET(_gloffset_SharpenTexFuncSGIS)) + JZ(GLNAME(_glapi_fallback_SpriteParameteriSGIX)) + JMP(GL_OFFSET(_gloffset_SpriteParameteriSGIX)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SampleMaskSGIS)) -GL_PREFIX(SampleMaskSGIS): +GLOBL_FN(GL_PREFIX(SpriteParameterivSGIX)) +GL_PREFIX(SpriteParameterivSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SampleMaskSGIS)) - JMP(GL_OFFSET(_gloffset_SampleMaskSGIS)) + JZ(GLNAME(_glapi_fallback_SpriteParameterivSGIX)) + JMP(GL_OFFSET(_gloffset_SpriteParameterivSGIX)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SamplePatternSGIS)) -GL_PREFIX(SamplePatternSGIS): +GLOBL_FN(GL_PREFIX(PointParameterfEXT)) +GL_PREFIX(PointParameterfEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SamplePatternSGIS)) - JMP(GL_OFFSET(_gloffset_SamplePatternSGIS)) + JZ(GLNAME(_glapi_fallback_PointParameterfEXT)) + JMP(GL_OFFSET(_gloffset_PointParameterfEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SpriteParameterfSGIX)) -GL_PREFIX(SpriteParameterfSGIX): +GLOBL_FN(GL_PREFIX(PointParameterfvEXT)) +GL_PREFIX(PointParameterfvEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SpriteParameterfSGIX)) - JMP(GL_OFFSET(_gloffset_SpriteParameterfSGIX)) + JZ(GLNAME(_glapi_fallback_PointParameterfvEXT)) + JMP(GL_OFFSET(_gloffset_PointParameterfvEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SpriteParameteriSGIX)) -GL_PREFIX(SpriteParameteriSGIX): +GLOBL_FN(GL_PREFIX(PointParameterfSGIS)) +GL_PREFIX(PointParameterfSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SpriteParameteriSGIX)) - JMP(GL_OFFSET(_gloffset_SpriteParameteriSGIX)) + JZ(GLNAME(_glapi_fallback_PointParameterfSGIS)) + JMP(GL_OFFSET(_gloffset_PointParameterfEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SpriteParameterfvSGIX)) -GL_PREFIX(SpriteParameterfvSGIX): +GLOBL_FN(GL_PREFIX(PointParameterfvSGIS)) +GL_PREFIX(PointParameterfvSGIS): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SpriteParameterfvSGIX)) - JMP(GL_OFFSET(_gloffset_SpriteParameterfvSGIX)) + JZ(GLNAME(_glapi_fallback_PointParameterfvSGIS)) + JMP(GL_OFFSET(_gloffset_PointParameterfvEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SpriteParameterivSGIX)) -GL_PREFIX(SpriteParameterivSGIX): +GLOBL_FN(GL_PREFIX(GetInstrumentsSGIX)) +GL_PREFIX(GetInstrumentsSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SpriteParameterivSGIX)) - JMP(GL_OFFSET(_gloffset_SpriteParameterivSGIX)) + JZ(GLNAME(_glapi_fallback_GetInstrumentsSGIX)) + JMP(GL_OFFSET(_gloffset_GetInstrumentsSGIX)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(InstrumentsBufferSGIX)) @@ -4157,20 +4060,12 @@ GL_PREFIX(InstrumentsBufferSGIX): JMP(GL_OFFSET(_gloffset_InstrumentsBufferSGIX)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(StartInstrumentsSGIX)) -GL_PREFIX(StartInstrumentsSGIX): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_StartInstrumentsSGIX)) - JMP(GL_OFFSET(_gloffset_StartInstrumentsSGIX)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(StopInstrumentsSGIX)) -GL_PREFIX(StopInstrumentsSGIX): +GLOBL_FN(GL_PREFIX(PollInstrumentsSGIX)) +GL_PREFIX(PollInstrumentsSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_StopInstrumentsSGIX)) - JMP(GL_OFFSET(_gloffset_StopInstrumentsSGIX)) + JZ(GLNAME(_glapi_fallback_PollInstrumentsSGIX)) + JMP(GL_OFFSET(_gloffset_PollInstrumentsSGIX)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(ReadInstrumentsSGIX)) @@ -4181,20 +4076,20 @@ GL_PREFIX(ReadInstrumentsSGIX): JMP(GL_OFFSET(_gloffset_ReadInstrumentsSGIX)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(PollInstrumentsSGIX)) -GL_PREFIX(PollInstrumentsSGIX): +GLOBL_FN(GL_PREFIX(StartInstrumentsSGIX)) +GL_PREFIX(StartInstrumentsSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_PollInstrumentsSGIX)) - JMP(GL_OFFSET(_gloffset_PollInstrumentsSGIX)) + JZ(GLNAME(_glapi_fallback_StartInstrumentsSGIX)) + JMP(GL_OFFSET(_gloffset_StartInstrumentsSGIX)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(GetInstrumentsSGIX)) -GL_PREFIX(GetInstrumentsSGIX): +GLOBL_FN(GL_PREFIX(StopInstrumentsSGIX)) +GL_PREFIX(StopInstrumentsSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_GetInstrumentsSGIX)) - JMP(GL_OFFSET(_gloffset_GetInstrumentsSGIX)) + JZ(GLNAME(_glapi_fallback_StopInstrumentsSGIX)) + JMP(GL_OFFSET(_gloffset_StopInstrumentsSGIX)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(FrameZoomSGIX)) @@ -4205,6 +4100,14 @@ GL_PREFIX(FrameZoomSGIX): JMP(GL_OFFSET(_gloffset_FrameZoomSGIX)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(TagSampleBufferSGIX)) +GL_PREFIX(TagSampleBufferSGIX): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_TagSampleBufferSGIX)) + JMP(GL_OFFSET(_gloffset_TagSampleBufferSGIX)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(ReferencePlaneSGIX)) GL_PREFIX(ReferencePlaneSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -4221,14 +4124,62 @@ GL_PREFIX(FlushRasterSGIX): JMP(GL_OFFSET(_gloffset_FlushRasterSGIX)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(ColorSubTableEXT)) +GL_PREFIX(ColorSubTableEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_ColorSubTableEXT)) + JMP(GL_OFFSET(_gloffset_ColorSubTable)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(CopyColorSubTableEXT)) GL_PREFIX(CopyColorSubTableEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CopyColorSubTable)) + JZ(GLNAME(_glapi_fallback_CopyColorSubTableEXT)) JMP(GL_OFFSET(_gloffset_CopyColorSubTable)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(HintPGI)) +GL_PREFIX(HintPGI): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_HintPGI)) + JMP(GL_OFFSET(_gloffset_HintPGI)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(ColorTableEXT)) +GL_PREFIX(ColorTableEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_ColorTableEXT)) + JMP(GL_OFFSET(_gloffset_ColorTable)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(GetColorTableEXT)) +GL_PREFIX(GetColorTableEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_GetColorTableEXT)) + JMP(GL_OFFSET(_gloffset_GetColorTableEXT)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(GetColorTableParameterivEXT)) +GL_PREFIX(GetColorTableParameterivEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_GetColorTableParameterivEXT)) + JMP(GL_OFFSET(_gloffset_GetColorTableParameterivEXT)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(GetColorTableParameterfvEXT)) +GL_PREFIX(GetColorTableParameterfvEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_GetColorTableParameterfvEXT)) + JMP(GL_OFFSET(_gloffset_GetColorTableParameterfvEXT)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(GetListParameterfvSGIX)) GL_PREFIX(GetListParameterfvSGIX): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -4293,44 +4244,36 @@ GL_PREFIX(IndexFuncEXT): JMP(GL_OFFSET(_gloffset_IndexFuncEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CullParameterdvEXT)) -GL_PREFIX(CullParameterdvEXT): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CullParameterdvEXT)) - JMP(GL_OFFSET(_gloffset_CullParameterdvEXT)) - -ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(CullParameterfvEXT)) -GL_PREFIX(CullParameterfvEXT): +GLOBL_FN(GL_PREFIX(LockArraysEXT)) +GL_PREFIX(LockArraysEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_CullParameterfvEXT)) - JMP(GL_OFFSET(_gloffset_CullParameterfvEXT)) + JZ(GLNAME(_glapi_fallback_LockArraysEXT)) + JMP(GL_OFFSET(_gloffset_LockArraysEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SampleCoverageARB)) -GL_PREFIX(SampleCoverageARB): +GLOBL_FN(GL_PREFIX(UnlockArraysEXT)) +GL_PREFIX(UnlockArraysEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SampleCoverageARB)) - JMP(GL_OFFSET(_gloffset_SampleCoverageARB)) + JZ(GLNAME(_glapi_fallback_UnlockArraysEXT)) + JMP(GL_OFFSET(_gloffset_UnlockArraysEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(SamplePassARB)) -GL_PREFIX(SamplePassARB): +GLOBL_FN(GL_PREFIX(CullParameterdvEXT)) +GL_PREFIX(CullParameterdvEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_SamplePassARB)) - JMP(GL_OFFSET(_gloffset_SamplePassARB)) + JZ(GLNAME(_glapi_fallback_CullParameterdvEXT)) + JMP(GL_OFFSET(_gloffset_CullParameterdvEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(TagSampleBufferSGIX)) -GL_PREFIX(TagSampleBufferSGIX): +GLOBL_FN(GL_PREFIX(CullParameterfvEXT)) +GL_PREFIX(CullParameterfvEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_TagSampleBufferSGIX)) - JMP(GL_OFFSET(_gloffset_TagSampleBufferSGIX)) + JZ(GLNAME(_glapi_fallback_CullParameterfvEXT)) + JMP(GL_OFFSET(_gloffset_CullParameterfvEXT)) ALIGNTEXT16 GLOBL_FN(GL_PREFIX(FragmentColorMaterialSGIX)) @@ -4477,6 +4420,14 @@ GL_PREFIX(LightEnviSGIX): JMP(GL_OFFSET(_gloffset_LightEnviSGIX)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(DrawRangeElementsEXT)) +GL_PREFIX(DrawRangeElementsEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_DrawRangeElementsEXT)) + JMP(GL_OFFSET(_gloffset_DrawRangeElements)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(FogCoordfEXT)) GL_PREFIX(FogCoordfEXT): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -4549,14 +4500,6 @@ GL_PREFIX(VertexWeightPointerEXT): JMP(GL_OFFSET(_gloffset_VertexWeightPointerEXT)) ALIGNTEXT16 -GLOBL_FN(GL_PREFIX(VertexArrayRangeNV)) -GL_PREFIX(VertexArrayRangeNV): - MOV_L(GLNAME(_glapi_Dispatch), EAX) - TEST_L(EAX, EAX) - JZ(GLNAME(_glapi_fallback_VertexArrayRangeNV)) - JMP(GL_OFFSET(_gloffset_VertexArrayRangeNV)) - -ALIGNTEXT16 GLOBL_FN(GL_PREFIX(FlushVertexArrayRangeNV)) GL_PREFIX(FlushVertexArrayRangeNV): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -4565,6 +4508,14 @@ GL_PREFIX(FlushVertexArrayRangeNV): JMP(GL_OFFSET(_gloffset_FlushVertexArrayRangeNV)) ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(VertexArrayRangeNV)) +GL_PREFIX(VertexArrayRangeNV): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_VertexArrayRangeNV)) + JMP(GL_OFFSET(_gloffset_VertexArrayRangeNV)) + +ALIGNTEXT16 GLOBL_FN(GL_PREFIX(CombinerParameterfvNV)) GL_PREFIX(CombinerParameterfvNV): MOV_L(GLNAME(_glapi_Dispatch), EAX) @@ -4668,4 +4619,229 @@ GL_PREFIX(GetFinalCombinerInputParameterivNV): JZ(GLNAME(_glapi_fallback_GetFinalCombinerInputParameterivNV)) JMP(GL_OFFSET(_gloffset_GetFinalCombinerInputParameterivNV)) +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(ResizeBuffersMESA)) +GL_PREFIX(ResizeBuffersMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_ResizeBuffersMESA)) + JMP(GL_OFFSET(_gloffset_ResizeBuffersMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos2dMESA)) +GL_PREFIX(WindowPos2dMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos2dMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos2dMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos2dvMESA)) +GL_PREFIX(WindowPos2dvMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos2dvMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos2dvMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos2fMESA)) +GL_PREFIX(WindowPos2fMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos2fMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos2fMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos2fvMESA)) +GL_PREFIX(WindowPos2fvMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos2fvMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos2fvMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos2iMESA)) +GL_PREFIX(WindowPos2iMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos2iMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos2iMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos2ivMESA)) +GL_PREFIX(WindowPos2ivMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos2ivMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos2ivMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos2sMESA)) +GL_PREFIX(WindowPos2sMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos2sMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos2sMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos2svMESA)) +GL_PREFIX(WindowPos2svMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos2svMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos2svMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos3dMESA)) +GL_PREFIX(WindowPos3dMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos3dMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos3dMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos3dvMESA)) +GL_PREFIX(WindowPos3dvMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos3dvMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos3dvMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos3fMESA)) +GL_PREFIX(WindowPos3fMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos3fMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos3fMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos3fvMESA)) +GL_PREFIX(WindowPos3fvMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos3fvMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos3fvMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos3iMESA)) +GL_PREFIX(WindowPos3iMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos3iMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos3iMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos3ivMESA)) +GL_PREFIX(WindowPos3ivMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos3ivMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos3ivMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos3sMESA)) +GL_PREFIX(WindowPos3sMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos3sMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos3sMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos3svMESA)) +GL_PREFIX(WindowPos3svMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos3svMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos3svMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos4dMESA)) +GL_PREFIX(WindowPos4dMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos4dMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos4dMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos4dvMESA)) +GL_PREFIX(WindowPos4dvMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos4dvMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos4dvMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos4fMESA)) +GL_PREFIX(WindowPos4fMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos4fMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos4fMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos4fvMESA)) +GL_PREFIX(WindowPos4fvMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos4fvMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos4fvMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos4iMESA)) +GL_PREFIX(WindowPos4iMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos4iMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos4iMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos4ivMESA)) +GL_PREFIX(WindowPos4ivMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos4ivMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos4ivMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos4sMESA)) +GL_PREFIX(WindowPos4sMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos4sMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos4sMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(WindowPos4svMESA)) +GL_PREFIX(WindowPos4svMESA): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_WindowPos4svMESA)) + JMP(GL_OFFSET(_gloffset_WindowPos4svMESA)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(TbufferMask3DFX)) +GL_PREFIX(TbufferMask3DFX): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_TbufferMask3DFX)) + JMP(GL_OFFSET(_gloffset_TbufferMask3DFX)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(SampleMaskEXT)) +GL_PREFIX(SampleMaskEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_SampleMaskEXT)) + JMP(GL_OFFSET(_gloffset_SampleMaskSGIS)) + +ALIGNTEXT16 +GLOBL_FN(GL_PREFIX(SamplePatternEXT)) +GL_PREFIX(SamplePatternEXT): + MOV_L(GLNAME(_glapi_Dispatch), EAX) + TEST_L(EAX, EAX) + JZ(GLNAME(_glapi_fallback_SamplePatternEXT)) + JMP(GL_OFFSET(_gloffset_SamplePatternSGIS)) + + #endif /* __WIN32__ */ diff --git a/xc/extras/Mesa/src/X86/vertex_3dnow.S b/xc/extras/Mesa/src/X86/vertex_3dnow.S index f93db21c1..2c0060362 100644 --- a/xc/extras/Mesa/src/X86/vertex_3dnow.S +++ b/xc/extras/Mesa/src/X86/vertex_3dnow.S @@ -11,7 +11,7 @@ -/*#define MAT_SX 0 /* accessed by REGIND !! */ +/*#define MAT_SX 0 accessed by REGIND !! */ #define MAT_SY 20 #define MAT_SZ 40 #define MAT_TX 48 diff --git a/xc/extras/Mesa/src/X86/x86.c b/xc/extras/Mesa/src/X86/x86.c index 223cf61c8..1b24811d4 100644 --- a/xc/extras/Mesa/src/X86/x86.c +++ b/xc/extras/Mesa/src/X86/x86.c @@ -28,17 +28,14 @@ */ -#include <limits.h> -#include <stdio.h> -#include <stdlib.h> -#include <math.h> - +#include "glheader.h" #include "context.h" #include "types.h" #include "vertices.h" #include "xform.h" #include "x86.h" +#ifdef USE_X86_ASM extern void _ASMAPI gl_v16_x86_cliptest_points4(GLfloat *first_vert, GLfloat *last_vert, GLubyte *or_mask, @@ -51,7 +48,7 @@ extern void _ASMAPI gl_v16_x86_general_xform(GLfloat *dest, const GLfloat *src, GLuint src_stride, GLuint count); - +#endif #define XFORM_ARGS GLvector4f *to_vec, \ @@ -85,8 +82,7 @@ extern void _ASMAPI gl_v16_x86_general_xform(GLfloat *dest, gl_transform_tab[cma][vsize][MATRIX_3D] \ = gl_##pfx##_transform_points##vsize##_3d_##masked; -void gl_init_x86_asm_transforms( void ) -{ + #ifdef USE_X86_ASM DECLARE_XFORM_GROUP( x86, 2, raw ) DECLARE_XFORM_GROUP( x86, 3, raw ) @@ -100,8 +96,12 @@ void gl_init_x86_asm_transforms( void ) GLubyte clipMask[], GLubyte *orMask, GLubyte *andMask ); +#endif + - +void gl_init_x86_asm_transforms( void ) +{ +#ifdef USE_X86_ASM ASSIGN_XFORM_GROUP( x86, 0, 2, raw ) ASSIGN_XFORM_GROUP( x86, 0, 3, raw ) ASSIGN_XFORM_GROUP( x86, 0, 4, raw ) @@ -110,6 +110,7 @@ void gl_init_x86_asm_transforms( void ) ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 3, masked ) ASSIGN_XFORM_GROUP( x86, CULL_MASK_ACTIVE, 4, masked ) + /* XXX this function has been found to cause FP overflow exceptions */ gl_clip_tab[4] = gl_x86_cliptest_points4; #ifdef DEBUG diff --git a/xc/extras/Mesa/src/alphabuf.c b/xc/extras/Mesa/src/alphabuf.c index 50bc80d4b..6f2332407 100644 --- a/xc/extras/Mesa/src/alphabuf.c +++ b/xc/extras/Mesa/src/alphabuf.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -60,7 +60,7 @@ alloc_alpha_buffers( GLcontext *ctx, GLframebuffer *buf ) { GLint bytes = buf->Width * buf->Height * sizeof(GLubyte); - ASSERT(ctx->Visual->SoftwareAlpha); + ASSERT(ctx->DrawBuffer->UseSoftwareAlphaBuffers); if (buf->FrontLeftAlpha) { FREE( buf->FrontLeftAlpha ); @@ -122,7 +122,8 @@ alloc_alpha_buffers( GLcontext *ctx, GLframebuffer *buf ) /* * Allocate a new front and back alpha buffer. */ -void gl_alloc_alpha_buffers( GLcontext *ctx ) +void +_mesa_alloc_alpha_buffers( GLcontext *ctx ) { alloc_alpha_buffers( ctx, ctx->DrawBuffer ); if (ctx->ReadBuffer != ctx->DrawBuffer) { @@ -134,12 +135,13 @@ void gl_alloc_alpha_buffers( GLcontext *ctx ) /* * Clear all the alpha buffers */ -void gl_clear_alpha_buffers( GLcontext *ctx ) +void +_mesa_clear_alpha_buffers( GLcontext *ctx ) { const GLubyte aclear = (GLint) (ctx->Color.ClearColor[3] * 255.0F); GLuint bufferBit; - ASSERT(ctx->Visual->SoftwareAlpha); + ASSERT(ctx->DrawBuffer->UseSoftwareAlphaBuffers); ASSERT(ctx->Color.ColorMask[ACOMP]); /* loop over four possible alpha buffers */ @@ -183,8 +185,9 @@ void gl_clear_alpha_buffers( GLcontext *ctx ) -void gl_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - CONST GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + CONST GLubyte rgba[][4], const GLubyte mask[] ) { GLubyte *aptr = ALPHA_DRAW_ADDR( x, y ); GLuint i; @@ -205,8 +208,9 @@ void gl_write_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, } -void gl_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, - GLubyte alpha, const GLubyte mask[] ) +void +_mesa_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, + GLubyte alpha, const GLubyte mask[] ) { GLubyte *aptr = ALPHA_DRAW_ADDR( x, y ); GLuint i; @@ -227,9 +231,10 @@ void gl_write_mono_alpha_span( GLcontext *ctx, GLuint n, GLint x, GLint y, } -void gl_write_alpha_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - CONST GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_write_alpha_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + CONST GLubyte rgba[][4], const GLubyte mask[] ) { GLuint i; @@ -250,9 +255,10 @@ void gl_write_alpha_pixels( GLcontext *ctx, } -void gl_write_mono_alpha_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte alpha, const GLubyte mask[] ) +void +_mesa_write_mono_alpha_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte alpha, const GLubyte mask[] ) { GLuint i; @@ -274,8 +280,9 @@ void gl_write_mono_alpha_pixels( GLcontext *ctx, -void gl_read_alpha_span( GLcontext *ctx, - GLuint n, GLint x, GLint y, GLubyte rgba[][4] ) +void +_mesa_read_alpha_span( GLcontext *ctx, + GLuint n, GLint x, GLint y, GLubyte rgba[][4] ) { GLubyte *aptr = ALPHA_READ_ADDR( x, y ); GLuint i; @@ -285,9 +292,10 @@ void gl_read_alpha_span( GLcontext *ctx, } -void gl_read_alpha_pixels( GLcontext *ctx, - GLuint n, const GLint x[], const GLint y[], - GLubyte rgba[][4], const GLubyte mask[] ) +void +_mesa_read_alpha_pixels( GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], const GLubyte mask[] ) { GLuint i; for (i=0;i<n;i++) { diff --git a/xc/extras/Mesa/src/attrib.c b/xc/extras/Mesa/src/attrib.c index 53f59765d..2e750ffdb 100644 --- a/xc/extras/Mesa/src/attrib.c +++ b/xc/extras/Mesa/src/attrib.c @@ -103,7 +103,7 @@ _mesa_PushAttrib(GLbitfield mask) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glPushAttrib"); if (MESA_VERBOSE&VERBOSE_API) - fprintf(stderr, "glPushAttrib %x\n", mask); + fprintf(stderr, "glPushAttrib %x\n", (int)mask); if (ctx->AttribStackDepth>=MAX_ATTRIB_STACK_DEPTH) { gl_error( ctx, GL_STACK_OVERFLOW, "glPushAttrib" ); @@ -166,6 +166,9 @@ _mesa_PushAttrib(GLbitfield mask) attr->ClipPlane[i] = ctx->Transform.ClipEnabled[i]; } attr->ColorMaterial = ctx->Light.ColorMaterialEnabled; + attr->Convolution1D = ctx->Pixel.Convolution1DEnabled; + attr->Convolution2D = ctx->Pixel.Convolution2DEnabled; + attr->Separable2D = ctx->Pixel.Separable2DEnabled; attr->CullFace = ctx->Polygon.CullFlag; attr->DepthTest = ctx->Depth.Test; attr->Dither = ctx->Color.DitherFlag; @@ -176,6 +179,8 @@ _mesa_PushAttrib(GLbitfield mask) attr->Lighting = ctx->Light.Enabled; attr->LineSmooth = ctx->Line.SmoothFlag; attr->LineStipple = ctx->Line.StippleFlag; + attr->Histogram = ctx->Pixel.HistogramEnabled; + attr->MinMax = ctx->Pixel.MinMaxEnabled; attr->IndexLogicOp = ctx->Color.IndexLogicOpEnabled; attr->ColorLogicOp = ctx->Color.ColorLogicOpEnabled; attr->Map1Color4 = ctx->Eval.Map1Color4; @@ -197,6 +202,7 @@ _mesa_PushAttrib(GLbitfield mask) attr->Map2Vertex3 = ctx->Eval.Map2Vertex3; attr->Map2Vertex4 = ctx->Eval.Map2Vertex4; attr->Normalize = ctx->Transform.Normalize; + attr->PixelTexture = ctx->Pixel.PixelTextureEnabled; attr->PointSmooth = ctx->Point.SmoothFlag; attr->PolygonOffsetPoint = ctx->Polygon.OffsetPoint; attr->PolygonOffsetLine = ctx->Polygon.OffsetLine; @@ -422,21 +428,43 @@ _mesa_PopAttrib(void) GLubyte oldAlphaRef = ctx->Color.AlphaRef; GLenum oldBlendSrc = ctx->Color.BlendSrcRGB; GLenum oldBlendDst = ctx->Color.BlendDstRGB; + GLenum oldLogicOp = ctx->Color.LogicOp; MEMCPY( &ctx->Color, attr->data, sizeof(struct gl_colorbuffer_attrib) ); if (ctx->Color.DrawBuffer != oldDrawBuffer) { _mesa_DrawBuffer( ctx->Color.DrawBuffer); } - if ((ctx->Color.AlphaFunc != oldAlphaFunc || - ctx->Color.AlphaRef != oldAlphaRef) && - ctx->Driver.AlphaFunc) - (*ctx->Driver.AlphaFunc)( ctx, ctx->Color.AlphaFunc, - ctx->Color.AlphaRef / 255.0F); if ((ctx->Color.BlendSrcRGB != oldBlendSrc || - ctx->Color.BlendSrcRGB != oldBlendDst) && + ctx->Color.BlendDstRGB != oldBlendDst) && ctx->Driver.BlendFunc) (*ctx->Driver.BlendFunc)( ctx, ctx->Color.BlendSrcRGB, ctx->Color.BlendDstRGB); + if (ctx->Color.LogicOp != oldLogicOp && + ctx->Driver.LogicOpcode) { + ctx->Driver.LogicOpcode( ctx, ctx->Color.LogicOp ); + } + if (ctx->Visual->RGBAflag) { + GLubyte r = (GLint) (ctx->Color.ClearColor[0] * 255.0F); + GLubyte g = (GLint) (ctx->Color.ClearColor[1] * 255.0F); + GLubyte b = (GLint) (ctx->Color.ClearColor[2] * 255.0F); + GLubyte a = (GLint) (ctx->Color.ClearColor[3] * 255.0F); + (*ctx->Driver.ClearColor)( ctx, r, g, b, a ); + if ((ctx->Color.AlphaFunc != oldAlphaFunc || + ctx->Color.AlphaRef != oldAlphaRef) && + ctx->Driver.AlphaFunc) + (*ctx->Driver.AlphaFunc)( ctx, ctx->Color.AlphaFunc, + ctx->Color.AlphaRef / 255.0F); + if (ctx->Driver.ColorMask) { + (*ctx->Driver.ColorMask)(ctx, + ctx->Color.ColorMask[0], + ctx->Color.ColorMask[1], + ctx->Color.ColorMask[2], + ctx->Color.ColorMask[3]); + } + } + else { + (*ctx->Driver.ClearIndex)( ctx, ctx->Color.ClearIndex); + } } break; case GL_CURRENT_BIT: @@ -482,6 +510,9 @@ _mesa_PopAttrib(void) TEST_AND_UPDATE(ctx->Polygon.CullFlag, enable->CullFace, GL_CULL_FACE); TEST_AND_UPDATE(ctx->Depth.Test, enable->DepthTest, GL_DEPTH_TEST); TEST_AND_UPDATE(ctx->Color.DitherFlag, enable->Dither, GL_DITHER); + TEST_AND_UPDATE(ctx->Pixel.Convolution1DEnabled, enable->Convolution1D, GL_CONVOLUTION_1D); + TEST_AND_UPDATE(ctx->Pixel.Convolution2DEnabled, enable->Convolution2D, GL_CONVOLUTION_2D); + TEST_AND_UPDATE(ctx->Pixel.Separable2DEnabled, enable->Separable2D, GL_SEPARABLE_2D); TEST_AND_UPDATE(ctx->Fog.Enabled, enable->Fog, GL_FOG); TEST_AND_UPDATE(ctx->Light.Enabled, enable->Lighting, GL_LIGHTING); TEST_AND_UPDATE(ctx->Line.SmoothFlag, enable->LineSmooth, GL_LINE_SMOOTH); @@ -508,6 +539,7 @@ _mesa_PopAttrib(void) TEST_AND_UPDATE(ctx->Eval.Map2Vertex4, enable->Map2Vertex4, GL_MAP2_VERTEX_4); TEST_AND_UPDATE(ctx->Transform.Normalize, enable->Normalize, GL_NORMALIZE); TEST_AND_UPDATE(ctx->Transform.RescaleNormals, enable->RescaleNormals, GL_RESCALE_NORMAL_EXT); + TEST_AND_UPDATE(ctx->Pixel.PixelTextureEnabled, enable->PixelTexture, GL_POINT_SMOOTH); TEST_AND_UPDATE(ctx->Point.SmoothFlag, enable->PointSmooth, GL_POINT_SMOOTH); TEST_AND_UPDATE(ctx->Polygon.OffsetPoint, enable->PolygonOffsetPoint, GL_POLYGON_OFFSET_POINT); TEST_AND_UPDATE(ctx->Polygon.OffsetLine, enable->PolygonOffsetLine, GL_POLYGON_OFFSET_LINE); @@ -634,6 +666,11 @@ _mesa_PopAttrib(void) (*ctx->Driver.Enable)( ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag ); (*ctx->Driver.Enable)( ctx, GL_LINE_STIPPLE, ctx->Line.StippleFlag ); } + if (ctx->Driver.LineStipple) + (*ctx->Driver.LineStipple)(ctx, ctx->Line.StippleFactor, + ctx->Line.StipplePattern); + if (ctx->Driver.LineWidth) + (*ctx->Driver.LineWidth)(ctx, ctx->Line.Width); break; case GL_LIST_BIT: MEMCPY( &ctx->List, attr->data, sizeof(struct gl_list_attrib) ); @@ -670,6 +707,8 @@ _mesa_PopAttrib(void) break; case GL_POLYGON_STIPPLE_BIT: MEMCPY( ctx->PolygonStipple, attr->data, 32*sizeof(GLuint) ); + if (ctx->Driver.PolygonStipple) + ctx->Driver.PolygonStipple( ctx, (const GLubyte *) attr->data ); break; case GL_SCISSOR_BIT: MEMCPY( &ctx->Scissor, attr->data, diff --git a/xc/extras/Mesa/src/bitmap.c b/xc/extras/Mesa/src/bitmap.c index 563dff9af..eefee932f 100644 --- a/xc/extras/Mesa/src/bitmap.c +++ b/xc/extras/Mesa/src/bitmap.c @@ -53,7 +53,7 @@ render_bitmap( GLcontext *ctx, GLint px, GLint py, { struct pixel_buffer *PB = ctx->PB; GLint row, col; - GLint pz; + GLdepth fragZ; ASSERT(ctx->RenderMode == GL_RENDER); @@ -68,16 +68,16 @@ render_bitmap( GLcontext *ctx, GLint px, GLint py, g = (GLint) (ctx->Current.RasterColor[1] * 255.0F); b = (GLint) (ctx->Current.RasterColor[2] * 255.0F); a = (GLint) (ctx->Current.RasterColor[3] * 255.0F); - PB_SET_COLOR( ctx, PB, r, g, b, a ); + PB_SET_COLOR( PB, r, g, b, a ); } else { - PB_SET_INDEX( ctx, PB, ctx->Current.RasterIndex ); + PB_SET_INDEX( PB, ctx->Current.RasterIndex ); } - pz = (GLint) ( ctx->Current.RasterPos[2] * DEPTH_SCALE ); + fragZ = (GLdepth) ( ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF); for (row=0; row<height; row++) { - const GLubyte *src = (const GLubyte *) gl_pixel_addr_in_image( unpack, + const GLubyte *src = (const GLubyte *) _mesa_image_address( unpack, bitmap, width, height, GL_COLOR_INDEX, GL_BITMAP, 0, row, 0 ); if (unpack->LsbFirst) { @@ -85,7 +85,7 @@ render_bitmap( GLcontext *ctx, GLint px, GLint py, GLubyte mask = 1U << (unpack->SkipPixels & 0x7); for (col=0; col<width; col++) { if (*src & mask) { - PB_WRITE_PIXEL( PB, px+col, py+row, pz ); + PB_WRITE_PIXEL( PB, px+col, py+row, fragZ ); } if (mask == 128U) { src++; @@ -107,7 +107,7 @@ render_bitmap( GLcontext *ctx, GLint px, GLint py, GLubyte mask = 128U >> (unpack->SkipPixels & 0x7); for (col=0; col<width; col++) { if (*src & mask) { - PB_WRITE_PIXEL( PB, px+col, py+row, pz ); + PB_WRITE_PIXEL( PB, px+col, py+row, fragZ ); } if (mask == 1U) { src++; @@ -167,6 +167,8 @@ _mesa_Bitmap( GLsizei width, GLsizei height, gl_reduced_prim_change( ctx, GL_BITMAP ); } + ctx->OcclusionResult = GL_TRUE; + if (ctx->Driver.Bitmap) { /* let device driver try to render the bitmap */ completed = (*ctx->Driver.Bitmap)( ctx, x, y, width, height, diff --git a/xc/extras/Mesa/src/colortab.c b/xc/extras/Mesa/src/colortab.c index 63b93435a..e15014dfe 100644 --- a/xc/extras/Mesa/src/colortab.c +++ b/xc/extras/Mesa/src/colortab.c @@ -32,28 +32,20 @@ #include "context.h" #include "image.h" #include "macros.h" +#include "mem.h" +#include "mmath.h" +#include "span.h" #endif /* - * Return GL_TRUE if k is a power of two, else return GL_FALSE. + * Given an internalFormat token passed to glColorTable, + * return the corresponding base format. + * Return -1 if invalid token. */ -static GLboolean -power_of_two( GLint k ) -{ - GLint i, m = 1; - for (i=0; i<32; i++) { - if (k == m) - return GL_TRUE; - m = m << 1; - } - return GL_FALSE; -} - - static GLint -decode_internal_format( GLint format ) +base_colortab_format( GLenum format ) { switch (format) { case GL_ALPHA: @@ -62,14 +54,12 @@ decode_internal_format( GLint format ) case GL_ALPHA12: case GL_ALPHA16: return GL_ALPHA; - case 1: case GL_LUMINANCE: case GL_LUMINANCE4: case GL_LUMINANCE8: case GL_LUMINANCE12: case GL_LUMINANCE16: return GL_LUMINANCE; - case 2: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: case GL_LUMINANCE6_ALPHA2: @@ -84,7 +74,6 @@ decode_internal_format( GLint format ) case GL_INTENSITY12: case GL_INTENSITY16: return GL_INTENSITY; - case 3: case GL_RGB: case GL_R3_G3_B2: case GL_RGB4: @@ -94,7 +83,6 @@ decode_internal_format( GLint format ) case GL_RGB12: case GL_RGB16: return GL_RGB; - case 4: case GL_RGBA: case GL_RGBA2: case GL_RGBA4: @@ -110,97 +98,333 @@ decode_internal_format( GLint format ) } +void +_mesa_init_colortable( struct gl_color_table *p ) +{ + p->TableType = GL_UNSIGNED_BYTE; + /* allocate a width=1 table by default */ + p->Table = CALLOC(4 * sizeof(GLubyte)); + if (p->Table) { + GLubyte *t = (GLubyte *) p->Table; + t[0] = 255; + t[1] = 255; + t[2] = 255; + t[3] = 255; + } + p->Size = 1; + p->IntFormat = GL_RGBA; + p->Format = GL_RGBA; + p->RedSize = 8; + p->GreenSize = 8; + p->BlueSize = 8; + p->AlphaSize = 8; + p->IntensitySize = 0; + p->LuminanceSize = 0; +} + + + +void +_mesa_free_colortable_data( struct gl_color_table *p ) +{ + if (p->Table) { + FREE(p->Table); + p->Table = NULL; + } +} + + +/* + * Examine table's format and set the component sizes accordingly. + */ +static void +set_component_sizes( struct gl_color_table *table ) +{ + switch (table->Format) { + case GL_ALPHA: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 8; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; + case GL_LUMINANCE: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 0; + table->IntensitySize = 0; + table->LuminanceSize = 8; + break; + case GL_LUMINANCE_ALPHA: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 8; + table->IntensitySize = 0; + table->LuminanceSize = 8; + break; + case GL_INTENSITY: + table->RedSize = 0; + table->GreenSize = 0; + table->BlueSize = 0; + table->AlphaSize = 0; + table->IntensitySize = 8; + table->LuminanceSize = 0; + break; + case GL_RGB: + table->RedSize = 8; + table->GreenSize = 8; + table->BlueSize = 8; + table->AlphaSize = 0; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; + case GL_RGBA: + table->RedSize = 8; + table->GreenSize = 8; + table->BlueSize = 8; + table->AlphaSize = 8; + table->IntensitySize = 0; + table->LuminanceSize = 0; + break; + default: + gl_problem(NULL, "unexpected format in set_component_sizes"); + } +} + + + void _mesa_ColorTable( GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, - const GLvoid *table ) + const GLvoid *data ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_object *texObj; - struct gl_color_table *palette; + struct gl_texture_object *texObj = NULL; + struct gl_color_table *table = NULL; GLboolean proxy = GL_FALSE; + GLint baseFormat; + GLfloat rScale = 1.0, gScale = 1.0, bScale = 1.0, aScale = 1.0; + GLfloat rBias = 0.0, gBias = 0.0, bBias = 0.0, aBias = 0.0; + GLboolean floatTable = GL_FALSE; + GLint comps; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorTable"); switch (target) { case GL_TEXTURE_1D: texObj = texUnit->CurrentD[1]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_TEXTURE_2D: texObj = texUnit->CurrentD[2]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_TEXTURE_3D: texObj = texUnit->CurrentD[3]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_PROXY_TEXTURE_1D: texObj = ctx->Texture.Proxy1D; - palette = &texObj->Palette; + table = &texObj->Palette; proxy = GL_TRUE; break; case GL_PROXY_TEXTURE_2D: texObj = ctx->Texture.Proxy2D; - palette = &texObj->Palette; + table = &texObj->Palette; proxy = GL_TRUE; break; case GL_PROXY_TEXTURE_3D: texObj = ctx->Texture.Proxy3D; - palette = &texObj->Palette; + table = &texObj->Palette; proxy = GL_TRUE; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - texObj = NULL; - palette = &ctx->Texture.Palette; + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + floatTable = GL_TRUE; + rScale = ctx->Pixel.ColorTableScale[0]; + gScale = ctx->Pixel.ColorTableScale[1]; + bScale = ctx->Pixel.ColorTableScale[2]; + aScale = ctx->Pixel.ColorTableScale[3]; + rBias = ctx->Pixel.ColorTableBias[0]; + gBias = ctx->Pixel.ColorTableBias[1]; + bBias = ctx->Pixel.ColorTableBias[2]; + aBias = ctx->Pixel.ColorTableBias[3]; + break; + case GL_PROXY_COLOR_TABLE: + table = &ctx->ProxyColorTable; + proxy = GL_TRUE; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + floatTable = GL_TRUE; + rScale = ctx->Pixel.PCCTscale[0]; + gScale = ctx->Pixel.PCCTscale[1]; + bScale = ctx->Pixel.PCCTscale[2]; + aScale = ctx->Pixel.PCCTscale[3]; + rBias = ctx->Pixel.PCCTbias[0]; + gBias = ctx->Pixel.PCCTbias[1]; + bBias = ctx->Pixel.PCCTbias[2]; + aBias = ctx->Pixel.PCCTbias[3]; + break; + case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->ProxyPostConvolutionColorTable; + proxy = GL_TRUE; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; + floatTable = GL_TRUE; + rScale = ctx->Pixel.PCMCTscale[0]; + gScale = ctx->Pixel.PCMCTscale[1]; + bScale = ctx->Pixel.PCMCTscale[2]; + aScale = ctx->Pixel.PCMCTscale[3]; + rBias = ctx->Pixel.PCMCTbias[0]; + gBias = ctx->Pixel.PCMCTbias[1]; + bBias = ctx->Pixel.PCMCTbias[2]; + aBias = ctx->Pixel.PCMCTbias[3]; + break; + case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->ProxyPostColorMatrixColorTable; + proxy = GL_TRUE; break; default: gl_error(ctx, GL_INVALID_ENUM, "glColorTable(target)"); return; } - assert(palette); + assert(table); - if (!gl_is_legal_format_and_type(format, type)) { + if (!_mesa_is_legal_format_and_type(format, type)) { gl_error(ctx, GL_INVALID_ENUM, "glColorTable(format or type)"); return; } - if (decode_internal_format(internalFormat) < 0) { - gl_error( ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)" ); + baseFormat = base_colortab_format(internalFormat); + if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { + gl_error(ctx, GL_INVALID_ENUM, "glColorTable(internalFormat)"); return; } - if (width < 1 || width > MAX_TEXTURE_PALETTE_SIZE || !power_of_two(width)) { - gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)"); + if (width < 1 || width > ctx->Const.MaxColorTableSize + || _mesa_bitcount(width) != 1) { + if (width > ctx->Const.MaxColorTableSize) + gl_error(ctx, GL_TABLE_TOO_LARGE, "glColorTable(width)"); + else + gl_error(ctx, GL_INVALID_VALUE, "glColorTable(width)"); if (proxy) { - palette->Size = 0; - palette->IntFormat = (GLenum) 0; - palette->Format = (GLenum) 0; + table->Size = 0; + table->IntFormat = (GLenum) 0; + table->Format = (GLenum) 0; } return; } - palette->Size = width; - palette->IntFormat = internalFormat; - palette->Format = (GLenum) decode_internal_format(internalFormat); + table->Size = width; + table->IntFormat = internalFormat; + table->Format = (GLenum) baseFormat; + set_component_sizes(table); + + comps = _mesa_components_in_format(table->Format); + assert(comps > 0); /* error should have been caught sooner */ + if (!proxy) { - _mesa_unpack_ubyte_color_span(ctx, width, palette->Format, - palette->Table, /* dest */ - format, type, table, - &ctx->Unpack, GL_FALSE); - } - if (texObj) { - /* per-texture object palette */ - if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); + /* free old table, if any */ + if (table->Table) { + FREE(table->Table); } - } - else { - /* shared texture palette */ + if (floatTable) { + GLubyte tableUB[MAX_COLOR_TABLE_SIZE * 4]; + GLfloat *tableF; + GLuint i; + + _mesa_unpack_ubyte_color_span(ctx, width, table->Format, + tableUB, /* dest */ + format, type, data, + &ctx->Unpack, GL_TRUE); + + table->TableType = GL_FLOAT; + table->Table = MALLOC(comps * width * sizeof(GLfloat)); + if (!table->Table) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); + return; + } + + /* Apply scale and bias and convert GLubyte values to GLfloats + * in [0, 1]. Store results in the tableF[]. + */ + rScale /= 255.0; + gScale /= 255.0; + bScale /= 255.0; + aScale /= 255.0; + tableF = (GLfloat *) table->Table; + + switch (table->Format) { + case GL_INTENSITY: + for (i = 0; i < width; i++) { + tableF[i] = tableUB[i] * rScale + rBias; + } + break; + case GL_LUMINANCE: + for (i = 0; i < width; i++) { + tableF[i] = tableUB[i] * rScale + rBias; + } + break; + case GL_ALPHA: + for (i = 0; i < width; i++) { + tableF[i] = tableUB[i] * aScale + aBias; + } + break; + case GL_LUMINANCE_ALPHA: + for (i = 0; i < width; i++) { + tableF[i*2+0] = tableUB[i*2+0] * rScale + rBias; + tableF[i*2+1] = tableUB[i*2+1] * aScale + aBias; + } + break; + case GL_RGB: + for (i = 0; i < width; i++) { + tableF[i*3+0] = tableUB[i*3+0] * rScale + rBias; + tableF[i*3+1] = tableUB[i*3+1] * gScale + gBias; + tableF[i*3+2] = tableUB[i*3+2] * bScale + bBias; + } + break; + case GL_RGBA: + for (i = 0; i < width; i++) { + tableF[i*4+0] = tableUB[i*4+0] * rScale + rBias; + tableF[i*4+1] = tableUB[i*4+1] * gScale + gBias; + tableF[i*4+2] = tableUB[i*4+2] * bScale + bBias; + tableF[i*4+3] = tableUB[i*4+3] * aScale + aBias; + } + break; + default: + gl_problem(ctx, "Bad format in _mesa_ColorTable"); + return; + } + } + else { + /* store GLubyte table */ + table->TableType = GL_UNSIGNED_BYTE; + table->Table = MALLOC(comps * width * sizeof(GLubyte)); + if (!table->Table) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glColorTable"); + return; + } + _mesa_unpack_ubyte_color_span(ctx, width, table->Format, + table->Table, /* dest */ + format, type, data, + &ctx->Unpack, GL_TRUE); + } /* floatTable */ + } /* proxy */ + + if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { + /* texture object palette, texObj==NULL means the shared palette */ if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, NULL ); + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); } } } @@ -210,42 +434,49 @@ _mesa_ColorTable( GLenum target, GLenum internalFormat, void _mesa_ColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, - const GLvoid *table ) + const GLvoid *data ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_object *texObj; - struct gl_color_table *palette; + struct gl_texture_object *texObj = NULL; + struct gl_color_table *table = NULL; GLint comps; - GLubyte *dest; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glColorSubTable"); switch (target) { case GL_TEXTURE_1D: texObj = texUnit->CurrentD[1]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_TEXTURE_2D: texObj = texUnit->CurrentD[2]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_TEXTURE_3D: texObj = texUnit->CurrentD[3]; - palette = &texObj->Palette; + table = &texObj->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - texObj = NULL; - palette = &ctx->Texture.Palette; + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; break; default: gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(target)"); return; } - assert(palette); + assert(table); - if (!gl_is_legal_format_and_type(format, type)) { + if (!_mesa_is_legal_format_and_type(format, type)) { gl_error(ctx, GL_INVALID_ENUM, "glColorSubTable(format or type)"); return; } @@ -255,196 +486,619 @@ _mesa_ColorSubTable( GLenum target, GLsizei start, return; } - comps = gl_components_in_format(format); - assert(comps > 0); /* error should be caught sooner */ + comps = _mesa_components_in_format(table->Format); + assert(comps > 0); /* error should have been caught sooner */ - if (start + count > palette->Size) { + if (start + count > table->Size) { gl_error(ctx, GL_INVALID_VALUE, "glColorSubTable(count)"); return; } - dest = palette->Table + start * comps * sizeof(GLubyte); - _mesa_unpack_ubyte_color_span(ctx, count, palette->Format, dest, - format, type, table, - &ctx->Unpack, GL_FALSE); - if (texObj) { - /* per-texture object palette */ - if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); - } + if (!table->Table) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glColorSubTable"); + return; + } + + if (table->TableType == GL_UNSIGNED_BYTE) { + GLubyte *dest = (GLubyte *) table->Table + start * comps * sizeof(GLubyte); + _mesa_unpack_ubyte_color_span(ctx, count, table->Format, dest, + format, type, data, &ctx->Unpack, GL_TRUE); } else { - /* shared texture palette */ + GLfloat *dest = (GLfloat *) table->Table + start * comps * sizeof(GLfloat); + ASSERT(table->TableType == GL_FLOAT); + _mesa_unpack_float_color_span(ctx, count, table->Format, dest, + format, type, data, &ctx->Unpack, + GL_FALSE, GL_TRUE); + } + + if (texObj || target == GL_SHARED_TEXTURE_PALETTE_EXT) { + /* per-texture object palette */ if (ctx->Driver.UpdateTexturePalette) { - (*ctx->Driver.UpdateTexturePalette)( ctx, NULL ); + (*ctx->Driver.UpdateTexturePalette)( ctx, texObj ); } } } +/* XXX not tested */ +void +_mesa_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GLubyte data[MAX_WIDTH][4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyColorTable"); + + /* Select buffer to read from */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel.DriverReadBuffer ); + + if (width > MAX_WIDTH) + width = MAX_WIDTH; + + /* read the data from framebuffer */ + gl_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data ); + + /* Restore reading from draw buffer (the default) */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, + ctx->Color.DriverDrawBuffer ); + + _mesa_ColorTable(target, internalformat, width, + GL_RGBA, GL_UNSIGNED_BYTE, data); +} + + + +/* XXX not tested */ +void +_mesa_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GLubyte data[MAX_WIDTH][4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyColorSubTable"); + + /* Select buffer to read from */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->ReadBuffer, + ctx->Pixel.DriverReadBuffer ); + + if (width > MAX_WIDTH) + width = MAX_WIDTH; + + /* read the data from framebuffer */ + gl_read_rgba_span( ctx, ctx->ReadBuffer, width, x, y, data ); + + /* Restore reading from draw buffer (the default) */ + (*ctx->Driver.SetReadBuffer)( ctx, ctx->DrawBuffer, + ctx->Color.DriverDrawBuffer ); + + _mesa_ColorSubTable(target, start, width, GL_RGBA, GL_UNSIGNED_BYTE, data); +} + + + void _mesa_GetColorTable( GLenum target, GLenum format, - GLenum type, GLvoid *table ) + GLenum type, GLvoid *data ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_color_table *palette; - GLubyte rgba[MAX_TEXTURE_PALETTE_SIZE][4]; + struct gl_color_table *table = NULL; + GLubyte rgba[MAX_COLOR_TABLE_SIZE][4]; GLint i; ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTable"); switch (target) { case GL_TEXTURE_1D: - palette = &texUnit->CurrentD[1]->Palette; + table = &texUnit->CurrentD[1]->Palette; break; case GL_TEXTURE_2D: - palette = &texUnit->CurrentD[2]->Palette; + table = &texUnit->CurrentD[2]->Palette; break; case GL_TEXTURE_3D: - palette = &texUnit->CurrentD[3]->Palette; + table = &texUnit->CurrentD[3]->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - palette = &ctx->Texture.Palette; + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; break; default: gl_error(ctx, GL_INVALID_ENUM, "glGetColorTable(target)"); return; } - assert(palette); + assert(table); - switch (palette->Format) { + switch (table->Format) { case GL_ALPHA: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = 0; - rgba[i][GCOMP] = 0; - rgba[i][BCOMP] = 0; - rgba[i][ACOMP] = palette->Table[i]; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = 0; + rgba[i][GCOMP] = 0; + rgba[i][BCOMP] = 0; + rgba[i][ACOMP] = (GLint) (tableF[i] * 255.0F); + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = 0; + rgba[i][GCOMP] = 0; + rgba[i][BCOMP] = 0; + rgba[i][ACOMP] = tableUB[i]; + } } break; case GL_LUMINANCE: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i]; - rgba[i][GCOMP] = palette->Table[i]; - rgba[i][BCOMP] = palette->Table[i]; - rgba[i][ACOMP] = 255; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][ACOMP] = 255; + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i]; + rgba[i][GCOMP] = tableUB[i]; + rgba[i][BCOMP] = tableUB[i]; + rgba[i][ACOMP] = 255; + } } break; case GL_LUMINANCE_ALPHA: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i*2+0]; - rgba[i][GCOMP] = palette->Table[i*2+0]; - rgba[i][BCOMP] = palette->Table[i*2+0]; - rgba[i][ACOMP] = palette->Table[i*2+1]; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i*2+0] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i*2+0] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i*2+0] * 255.0F); + rgba[i][ACOMP] = (GLint) (tableF[i*2+1] * 255.0F); + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i*2+0]; + rgba[i][GCOMP] = tableUB[i*2+0]; + rgba[i][BCOMP] = tableUB[i*2+0]; + rgba[i][ACOMP] = tableUB[i*2+1]; + } } break; case GL_INTENSITY: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i]; - rgba[i][GCOMP] = palette->Table[i]; - rgba[i][BCOMP] = palette->Table[i]; - rgba[i][ACOMP] = 255; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i] * 255.0F); + rgba[i][ACOMP] = (GLint) (tableF[i] * 255.0F); + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i]; + rgba[i][GCOMP] = tableUB[i]; + rgba[i][BCOMP] = tableUB[i]; + rgba[i][ACOMP] = tableUB[i]; + } } break; case GL_RGB: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i*3+0]; - rgba[i][GCOMP] = palette->Table[i*3+1]; - rgba[i][BCOMP] = palette->Table[i*3+2]; - rgba[i][ACOMP] = 255; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i*3+0] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i*3+1] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i*3+2] * 255.0F); + rgba[i][ACOMP] = 255; + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i*3+0]; + rgba[i][GCOMP] = tableUB[i*3+1]; + rgba[i][BCOMP] = tableUB[i*3+2]; + rgba[i][ACOMP] = 255; + } } break; case GL_RGBA: - for (i = 0; i < palette->Size; i++) { - rgba[i][RCOMP] = palette->Table[i*4+0]; - rgba[i][GCOMP] = palette->Table[i*4+1]; - rgba[i][BCOMP] = palette->Table[i*4+2]; - rgba[i][ACOMP] = palette->Table[i*4+3]; + if (table->TableType == GL_FLOAT) { + const GLfloat *tableF = (const GLfloat *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = (GLint) (tableF[i*4+0] * 255.0F); + rgba[i][GCOMP] = (GLint) (tableF[i*4+1] * 255.0F); + rgba[i][BCOMP] = (GLint) (tableF[i*4+2] * 255.0F); + rgba[i][ACOMP] = (GLint) (tableF[i*4+3] * 255.0F); + } + } + else { + const GLubyte *tableUB = (const GLubyte *) table->Table; + for (i = 0; i < table->Size; i++) { + rgba[i][RCOMP] = tableUB[i*4+0]; + rgba[i][GCOMP] = tableUB[i*4+1]; + rgba[i][BCOMP] = tableUB[i*4+2]; + rgba[i][ACOMP] = tableUB[i*4+3]; + } } break; default: - gl_problem(ctx, "bad palette format in glGetColorTable"); + gl_problem(ctx, "bad table format in glGetColorTable"); return; } - gl_pack_rgba_span(ctx, palette->Size, (const GLubyte (*)[]) rgba, - format, type, table, &ctx->Pack, GL_FALSE); + _mesa_pack_rgba_span(ctx, table->Size, (const GLubyte (*)[]) rgba, + format, type, data, &ctx->Pack, GL_FALSE); +} + + + +void +_mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv"); - (void) format; - (void) type; - (void) table; + switch (target) { + case GL_COLOR_TABLE_SGI: + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + ctx->Pixel.ColorTableScale[0] = params[0]; + ctx->Pixel.ColorTableScale[1] = params[1]; + ctx->Pixel.ColorTableScale[2] = params[2]; + ctx->Pixel.ColorTableScale[3] = params[3]; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + ctx->Pixel.ColorTableBias[0] = params[0]; + ctx->Pixel.ColorTableBias[1] = params[1]; + ctx->Pixel.ColorTableBias[2] = params[2]; + ctx->Pixel.ColorTableBias[3] = params[3]; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; + } + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + ctx->Pixel.PCCTscale[0] = params[0]; + ctx->Pixel.PCCTscale[1] = params[1]; + ctx->Pixel.PCCTscale[2] = params[2]; + ctx->Pixel.PCCTscale[3] = params[3]; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + ctx->Pixel.PCCTbias[0] = params[0]; + ctx->Pixel.PCCTbias[1] = params[1]; + ctx->Pixel.PCCTbias[2] = params[2]; + ctx->Pixel.PCCTbias[3] = params[3]; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; + } + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + ctx->Pixel.PCMCTscale[0] = params[0]; + ctx->Pixel.PCMCTscale[1] = params[1]; + ctx->Pixel.PCMCTscale[2] = params[2]; + ctx->Pixel.PCMCTscale[3] = params[3]; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + ctx->Pixel.PCMCTbias[0] = params[0]; + ctx->Pixel.PCMCTbias[1] = params[1]; + ctx->Pixel.PCMCTbias[2] = params[2]; + ctx->Pixel.PCMCTbias[3] = params[3]; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameterfv(pname)"); + return; + } + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glColorTableParameter(target)"); + return; + } } void -_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) +_mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) { - GLint iparams[10]; - _mesa_GetColorTableParameteriv( target, pname, iparams ); - *params = (GLfloat) iparams[0]; + GLfloat fparams[4]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) { + /* four values */ + fparams[0] = (GLfloat) params[0]; + fparams[1] = (GLfloat) params[1]; + fparams[2] = (GLfloat) params[2]; + fparams[3] = (GLfloat) params[3]; + } + else { + /* one values */ + fparams[0] = (GLfloat) params[0]; + } + _mesa_ColorTableParameterfv(target, pname, fparams); } void -_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) +_mesa_GetColorTableParameterfv( GLenum target, GLenum pname, GLfloat *params ) { GET_CURRENT_CONTEXT(ctx); struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_color_table *palette; + struct gl_color_table *table = NULL; - ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameter"); + ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameterfv"); switch (target) { case GL_TEXTURE_1D: - palette = &texUnit->CurrentD[1]->Palette; + table = &texUnit->CurrentD[1]->Palette; break; case GL_TEXTURE_2D: - palette = &texUnit->CurrentD[2]->Palette; + table = &texUnit->CurrentD[2]->Palette; break; case GL_TEXTURE_3D: - palette = &texUnit->CurrentD[3]->Palette; + table = &texUnit->CurrentD[3]->Palette; + break; + case GL_PROXY_TEXTURE_1D: + table = &ctx->Texture.Proxy1D->Palette; + break; + case GL_PROXY_TEXTURE_2D: + table = &ctx->Texture.Proxy2D->Palette; + break; + case GL_PROXY_TEXTURE_3D: + table = &ctx->Texture.Proxy3D->Palette; break; case GL_SHARED_TEXTURE_PALETTE_EXT: - palette = &ctx->Texture.Palette; + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = ctx->Pixel.ColorTableScale[0]; + params[1] = ctx->Pixel.ColorTableScale[1]; + params[2] = ctx->Pixel.ColorTableScale[2]; + params[3] = ctx->Pixel.ColorTableScale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = ctx->Pixel.ColorTableBias[0]; + params[1] = ctx->Pixel.ColorTableBias[1]; + params[2] = ctx->Pixel.ColorTableBias[2]; + params[3] = ctx->Pixel.ColorTableBias[3]; + return; + } + break; + case GL_PROXY_COLOR_TABLE: + table = &ctx->ProxyColorTable; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = ctx->Pixel.PCCTscale[0]; + params[1] = ctx->Pixel.PCCTscale[1]; + params[2] = ctx->Pixel.PCCTscale[2]; + params[3] = ctx->Pixel.PCCTscale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = ctx->Pixel.PCCTbias[0]; + params[1] = ctx->Pixel.PCCTbias[1]; + params[2] = ctx->Pixel.PCCTbias[2]; + params[3] = ctx->Pixel.PCCTbias[3]; + return; + } + break; + case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->ProxyPostConvolutionColorTable; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = ctx->Pixel.PCMCTscale[0]; + params[1] = ctx->Pixel.PCMCTscale[1]; + params[2] = ctx->Pixel.PCMCTscale[2]; + params[3] = ctx->Pixel.PCMCTscale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = ctx->Pixel.PCMCTbias[0]; + params[1] = ctx->Pixel.PCMCTbias[1]; + params[2] = ctx->Pixel.PCMCTbias[2]; + params[3] = ctx->Pixel.PCMCTbias[3]; + return; + } + break; + case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->ProxyPostColorMatrixColorTable; break; default: - gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter(target)"); + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(target)"); return; } + assert(table); + switch (pname) { case GL_COLOR_TABLE_FORMAT: - *params = palette->IntFormat; + *params = table->IntFormat; break; case GL_COLOR_TABLE_WIDTH: - *params = palette->Size; + *params = table->Size; break; case GL_COLOR_TABLE_RED_SIZE: - *params = 8; + *params = table->RedSize; break; case GL_COLOR_TABLE_GREEN_SIZE: - *params = 8; + *params = table->GreenSize; break; case GL_COLOR_TABLE_BLUE_SIZE: - *params = 8; + *params = table->BlueSize; break; case GL_COLOR_TABLE_ALPHA_SIZE: - *params = 8; + *params = table->AlphaSize; break; case GL_COLOR_TABLE_LUMINANCE_SIZE: - *params = 8; + *params = table->LuminanceSize; break; case GL_COLOR_TABLE_INTENSITY_SIZE: - *params = 8; + *params = table->IntensitySize; break; default: - gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameter" ); + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameterfv(pname)" ); return; } } + +void +_mesa_GetColorTableParameteriv( GLenum target, GLenum pname, GLint *params ) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + struct gl_color_table *table = NULL; + + ASSERT_OUTSIDE_BEGIN_END(ctx, "glGetColorTableParameteriv"); + + switch (target) { + case GL_TEXTURE_1D: + table = &texUnit->CurrentD[1]->Palette; + break; + case GL_TEXTURE_2D: + table = &texUnit->CurrentD[2]->Palette; + break; + case GL_TEXTURE_3D: + table = &texUnit->CurrentD[3]->Palette; + break; + case GL_PROXY_TEXTURE_1D: + table = &ctx->Texture.Proxy1D->Palette; + break; + case GL_PROXY_TEXTURE_2D: + table = &ctx->Texture.Proxy2D->Palette; + break; + case GL_PROXY_TEXTURE_3D: + table = &ctx->Texture.Proxy3D->Palette; + break; + case GL_SHARED_TEXTURE_PALETTE_EXT: + table = &ctx->Texture.Palette; + break; + case GL_COLOR_TABLE: + table = &ctx->ColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = (GLint) ctx->Pixel.ColorTableScale[0]; + params[1] = (GLint) ctx->Pixel.ColorTableScale[1]; + params[2] = (GLint) ctx->Pixel.ColorTableScale[2]; + params[3] = (GLint) ctx->Pixel.ColorTableScale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = (GLint) ctx->Pixel.ColorTableBias[0]; + params[1] = (GLint) ctx->Pixel.ColorTableBias[1]; + params[2] = (GLint) ctx->Pixel.ColorTableBias[2]; + params[3] = (GLint) ctx->Pixel.ColorTableBias[3]; + return; + } + break; + case GL_PROXY_COLOR_TABLE: + table = &ctx->ProxyColorTable; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->PostConvolutionColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = (GLint) ctx->Pixel.PCCTscale[0]; + params[1] = (GLint) ctx->Pixel.PCCTscale[1]; + params[2] = (GLint) ctx->Pixel.PCCTscale[2]; + params[3] = (GLint) ctx->Pixel.PCCTscale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = (GLint) ctx->Pixel.PCCTbias[0]; + params[1] = (GLint) ctx->Pixel.PCCTbias[1]; + params[2] = (GLint) ctx->Pixel.PCCTbias[2]; + params[3] = (GLint) ctx->Pixel.PCCTbias[3]; + return; + } + break; + case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE: + table = &ctx->ProxyPostConvolutionColorTable; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->PostColorMatrixColorTable; + if (pname == GL_COLOR_TABLE_SCALE_SGI) { + params[0] = (GLint) ctx->Pixel.PCMCTscale[0]; + params[1] = (GLint) ctx->Pixel.PCMCTscale[1]; + params[2] = (GLint) ctx->Pixel.PCMCTscale[2]; + params[3] = (GLint) ctx->Pixel.PCMCTscale[3]; + return; + } + else if (pname == GL_COLOR_TABLE_BIAS_SGI) { + params[0] = (GLint) ctx->Pixel.PCMCTbias[0]; + params[1] = (GLint) ctx->Pixel.PCMCTbias[1]; + params[2] = (GLint) ctx->Pixel.PCMCTbias[2]; + params[3] = (GLint) ctx->Pixel.PCMCTbias[3]; + return; + } + break; + case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE: + table = &ctx->ProxyPostColorMatrixColorTable; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(target)"); + return; + } + + assert(table); + + switch (pname) { + case GL_COLOR_TABLE_FORMAT: + *params = table->IntFormat; + break; + case GL_COLOR_TABLE_WIDTH: + *params = table->Size; + break; + case GL_COLOR_TABLE_RED_SIZE: + *params = table->RedSize; + break; + case GL_COLOR_TABLE_GREEN_SIZE: + *params = table->GreenSize; + break; + case GL_COLOR_TABLE_BLUE_SIZE: + *params = table->BlueSize; + break; + case GL_COLOR_TABLE_ALPHA_SIZE: + *params = table->AlphaSize; + break; + case GL_COLOR_TABLE_LUMINANCE_SIZE: + *params = table->LuminanceSize; + break; + case GL_COLOR_TABLE_INTENSITY_SIZE: + *params = table->IntensitySize; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetColorTableParameteriv(pname)" ); + return; + } +} diff --git a/xc/extras/Mesa/src/config.h b/xc/extras/Mesa/src/config.h index 595f02830..3ff5e5f78 100644 --- a/xc/extras/Mesa/src/config.h +++ b/xc/extras/Mesa/src/config.h @@ -51,6 +51,9 @@ /* Maximum texture matrix stack depth: */ #define MAX_TEXTURE_STACK_DEPTH 10 +/* Maximum color matrix stack depth: */ +#define MAX_COLOR_STACK_DEPTH 4 + /* Maximum attribute stack depth: */ #define MAX_ATTRIB_STACK_DEPTH 16 @@ -92,8 +95,8 @@ #define MAX_LINE_WIDTH 10.0 #define LINE_WIDTH_GRANULARITY 0.1 -/* Max texture palette size */ -#define MAX_TEXTURE_PALETTE_SIZE 256 +/* Max texture palette / color table size */ +#define MAX_COLOR_TABLE_SIZE 256 /* Number of texture levels */ #define MAX_TEXTURE_LEVELS 12 @@ -111,6 +114,16 @@ /* Subpixel precision for antialiasing, window coordinate snapping */ #define SUB_PIXEL_BITS 4 +/* Size of histogram tables */ +#define HISTOGRAM_TABLE_SIZE 256 + +/* Max convolution filter sizes */ +#define MAX_CONVOLUTION_WIDTH 5 +#define MAX_CONVOLUTION_HEIGHT 5 + +/* GL_ARB_texture_compression */ +#define MAX_COMPRESSED_TEXTURE_FORMATS 25 + /* @@ -125,26 +138,12 @@ /* - * Bits per depth buffer value: 16 or 32 + * Bits per depth buffer value: 16 or 32 (GLushort or GLuint) + * gl_create_visual() can select any depth in [0, 32]. */ -#ifdef MESAD3D - /* Mesa / Direct3D driver only */ - extern float g_DepthScale, g_MaxDepth; -# define DEPTH_BITS 32 -# define DEPTH_SCALE g_DepthScale -# define MAX_DEPTH g_MaxDepth -#else -# define DEPTH_BITS 16 -# if DEPTH_BITS==16 -# define MAX_DEPTH 0xffff -# define DEPTH_SCALE 65535.0F -# elif DEPTH_BITS==32 -# define MAX_DEPTH 0x3fffffff -# define DEPTH_SCALE ((GLfloat) MAX_DEPTH) -# else -# error "illegal number of depth bits" -# endif -#endif +#define DEFAULT_SOFTWARE_DEPTH_BITS 16 +#define DEFAULT_SOFTWARE_DEPTH_TYPE GLushort + /* @@ -190,7 +189,7 @@ * VB_MAX vertices. (This only happens when mixed primitives are * sharing the vb). */ -#define VB_MAX_CLIPPED_VERTS (2 * (6 + MAX_CLIP_PLANES)) +#define VB_MAX_CLIPPED_VERTS ((2 * (6 + MAX_CLIP_PLANES))+1) #define VB_SIZE (VB_MAX + VB_MAX_CLIPPED_VERTS) diff --git a/xc/extras/Mesa/src/context.c b/xc/extras/Mesa/src/context.c index 48e92df60..0138ae6b3 100644 --- a/xc/extras/Mesa/src/context.c +++ b/xc/extras/Mesa/src/context.c @@ -31,6 +31,7 @@ #include "accum.h" #include "alphabuf.h" #include "clip.h" +#include "colortab.h" #include "context.h" #include "cva.h" #include "depth.h" @@ -85,215 +86,110 @@ struct immediate *_mesa_CurrentInput = NULL; #endif - - /**********************************************************************/ -/***** Profiling functions *****/ +/***** GL Visual allocation/destruction *****/ /**********************************************************************/ -#ifdef PROFILE - -#include <sys/times.h> -#include <sys/param.h> - /* - * Return system time in seconds. - * NOTE: this implementation may not be very portable! + * Allocate a new GLvisual object. + * Input: rgbFlag - GL_TRUE=RGB(A) mode, GL_FALSE=Color Index mode + * dbFlag - double buffering? + * stereoFlag - stereo buffer? + * depthBits - requested bits per depth buffer value + * Any value in [0, 32] is acceptable but the actual + * depth type will be GLushort or GLuint as needed. + * stencilBits - requested minimum bits per stencil buffer value + * accumBits - requested minimum bits per accum buffer component + * indexBits - number of bits per pixel if rgbFlag==GL_FALSE + * red/green/blue/alphaBits - number of bits per color component + * in frame buffer for RGB(A) mode. + * We always use 8 in core Mesa though. + * Return: pointer to new GLvisual or NULL if requested parameters can't + * be met. */ -GLdouble gl_time( void ) +GLvisual * +_mesa_create_visual( GLboolean rgbFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint indexBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ) { - static GLdouble prev_time = 0.0; - static GLdouble time; - struct tms tm; - clock_t clk; - - clk = times(&tm); - -#ifdef CLK_TCK - time = (double)clk / (double)CLK_TCK; -#else - time = (double)clk / (double)HZ; -#endif - - if (time>prev_time) { - prev_time = time; - return time; - } - else { - return prev_time; + GLvisual *vis = (GLvisual *) CALLOC( sizeof(GLvisual) ); + if (vis) { + if (!_mesa_initialize_visual(vis, rgbFlag, dbFlag, stereoFlag, + redBits, greenBits, blueBits, alphaBits, + indexBits, depthBits, stencilBits, + accumRedBits, accumGreenBits, + accumBlueBits, accumAlphaBits, + numSamples )) { + FREE(vis); + return NULL; + } } + return vis; } + /* - * Reset the timing/profiling counters + * Initialize the fields of the given GLvisual. + * Input: see _mesa_create_visual() above. + * Return: GL_TRUE = success + * GL_FALSE = failure. */ -static void init_timings( GLcontext *ctx ) +GLboolean +_mesa_initialize_visual( GLvisual *vis, + GLboolean rgbFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint indexBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ) { - ctx->BeginEndCount = 0; - ctx->BeginEndTime = 0.0; - ctx->VertexCount = 0; - ctx->VertexTime = 0.0; - ctx->PointCount = 0; - ctx->PointTime = 0.0; - ctx->LineCount = 0; - ctx->LineTime = 0.0; - ctx->PolygonCount = 0; - ctx->PolygonTime = 0.0; - ctx->ClearCount = 0; - ctx->ClearTime = 0.0; - ctx->SwapCount = 0; - ctx->SwapTime = 0.0; -} + assert(vis); + /* This is to catch bad values from device drivers not updated for + * Mesa 3.3. Some device drivers just passed 1. That's a REALLY + * bad value now (a 1-bit depth buffer!?!). + */ + assert(depthBits == 0 || depthBits > 1); -/* - * Print the accumulated timing/profiling data. - */ -static void print_timings( GLcontext *ctx ) -{ - GLdouble beginendrate; - GLdouble vertexrate; - GLdouble pointrate; - GLdouble linerate; - GLdouble polygonrate; - GLdouble overhead; - GLdouble clearrate; - GLdouble swaprate; - GLdouble avgvertices; - - if (ctx->BeginEndTime>0.0) { - beginendrate = ctx->BeginEndCount / ctx->BeginEndTime; - } - else { - beginendrate = 0.0; - } - if (ctx->VertexTime>0.0) { - vertexrate = ctx->VertexCount / ctx->VertexTime; - } - else { - vertexrate = 0.0; - } - if (ctx->PointTime>0.0) { - pointrate = ctx->PointCount / ctx->PointTime; - } - else { - pointrate = 0.0; - } - if (ctx->LineTime>0.0) { - linerate = ctx->LineCount / ctx->LineTime; - } - else { - linerate = 0.0; - } - if (ctx->PolygonTime>0.0) { - polygonrate = ctx->PolygonCount / ctx->PolygonTime; - } - else { - polygonrate = 0.0; - } - if (ctx->ClearTime>0.0) { - clearrate = ctx->ClearCount / ctx->ClearTime; - } - else { - clearrate = 0.0; - } - if (ctx->SwapTime>0.0) { - swaprate = ctx->SwapCount / ctx->SwapTime; - } - else { - swaprate = 0.0; + if (depthBits < 0 || depthBits > 32) { + return GL_FALSE; } - - if (ctx->BeginEndCount>0) { - avgvertices = (GLdouble) ctx->VertexCount / (GLdouble) ctx->BeginEndCount; + if (stencilBits < 0 || stencilBits > (GLint) (8 * sizeof(GLstencil))) { + return GL_FALSE; } - else { - avgvertices = 0.0; - } - - overhead = ctx->BeginEndTime - ctx->VertexTime - ctx->PointTime - - ctx->LineTime - ctx->PolygonTime; - - - printf(" Count Time (s) Rate (/s) \n"); - printf("--------------------------------------------------------\n"); - printf("glBegin/glEnd %7d %8.3f %10.3f\n", - ctx->BeginEndCount, ctx->BeginEndTime, beginendrate); - printf(" vertexes transformed %7d %8.3f %10.3f\n", - ctx->VertexCount, ctx->VertexTime, vertexrate ); - printf(" points rasterized %7d %8.3f %10.3f\n", - ctx->PointCount, ctx->PointTime, pointrate ); - printf(" lines rasterized %7d %8.3f %10.3f\n", - ctx->LineCount, ctx->LineTime, linerate ); - printf(" polygons rasterized %7d %8.3f %10.3f\n", - ctx->PolygonCount, ctx->PolygonTime, polygonrate ); - printf(" overhead %8.3f\n", overhead ); - printf("glClear %7d %8.3f %10.3f\n", - ctx->ClearCount, ctx->ClearTime, clearrate ); - printf("SwapBuffers %7d %8.3f %10.3f\n", - ctx->SwapCount, ctx->SwapTime, swaprate ); - printf("\n"); - - printf("Average number of vertices per begin/end: %8.3f\n", avgvertices ); -} -#endif - - - - - -/**********************************************************************/ -/***** GL Visual allocation/destruction *****/ -/**********************************************************************/ - - -/* - * Allocate a new GLvisual object. - * Input: rgbFlag - GL_TRUE=RGB(A) mode, GL_FALSE=Color Index mode - * alphaFlag - alloc software alpha buffers? - * dbFlag - double buffering? - * stereoFlag - stereo buffer? - * depthFits - requested minimum bits per depth buffer value - * stencilFits - requested minimum bits per stencil buffer value - * accumFits - requested minimum bits per accum buffer component - * indexFits - number of bits per pixel if rgbFlag==GL_FALSE - * red/green/blue/alphaFits - number of bits per color component - * in frame buffer for RGB(A) mode. - * Return: pointer to new GLvisual or NULL if requested parameters can't - * be met. - */ -GLvisual *gl_create_visual( GLboolean rgbFlag, - GLboolean alphaFlag, - GLboolean dbFlag, - GLboolean stereoFlag, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - GLint indexBits, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits ) -{ - GLvisual *vis; - - if (depthBits > (GLint) (8*sizeof(GLdepth))) { - /* can't meet depth buffer requirements */ - return NULL; + if (accumRedBits < 0 || accumRedBits > (GLint) (8 * sizeof(GLaccum))) { + return GL_FALSE; } - if (stencilBits > (GLint) (8*sizeof(GLstencil))) { - /* can't meet stencil buffer requirements */ - return NULL; + if (accumGreenBits < 0 || accumGreenBits > (GLint) (8 * sizeof(GLaccum))) { + return GL_FALSE; } - if (accumBits > (GLint) (8*sizeof(GLaccum))) { - /* can't meet accum buffer requirements */ - return NULL; + if (accumBlueBits < 0 || accumBlueBits > (GLint) (8 * sizeof(GLaccum))) { + return GL_FALSE; } - - vis = (GLvisual *) CALLOC( sizeof(GLvisual) ); - if (!vis) { - return NULL; + if (accumAlphaBits < 0 || accumAlphaBits > (GLint) (8 * sizeof(GLaccum))) { + return GL_FALSE; } vis->RGBAflag = rgbFlag; @@ -302,23 +198,75 @@ GLvisual *gl_create_visual( GLboolean rgbFlag, vis->RedBits = redBits; vis->GreenBits = greenBits; vis->BlueBits = blueBits; - vis->AlphaBits = alphaFlag ? 8*sizeof(GLubyte) : alphaBits; + vis->AlphaBits = alphaBits; + + vis->IndexBits = indexBits; + vis->DepthBits = depthBits; + vis->AccumRedBits = (accumRedBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->AccumGreenBits = (accumGreenBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->AccumBlueBits = (accumBlueBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->AccumAlphaBits = (accumAlphaBits > 0) ? (8 * sizeof(GLaccum)) : 0; + vis->StencilBits = (stencilBits > 0) ? (8 * sizeof(GLstencil)) : 0; + + if (depthBits == 0) { + /* Special case. Even if we don't have a depth buffer we need + * good values for DepthMax for Z vertex transformation purposes. + */ + vis->DepthMax = 1; + vis->DepthMaxF = 1.0F; + } + else if (depthBits < 32) { + vis->DepthMax = (1 << depthBits) - 1; + vis->DepthMaxF = (GLfloat) vis->DepthMax; + } + else { + /* Special case since shift values greater than or equal to the + * number of bits in the left hand expression's type are + * undefined. + */ + vis->DepthMax = 0xffffffff; + vis->DepthMaxF = (GLfloat) vis->DepthMax; + } - vis->IndexBits = indexBits; - vis->DepthBits = (depthBits>0) ? 8*sizeof(GLdepth) : 0; - vis->AccumBits = (accumBits>0) ? 8*sizeof(GLaccum) : 0; - vis->StencilBits = (stencilBits>0) ? 8*sizeof(GLstencil) : 0; + return GL_TRUE; +} - vis->SoftwareAlpha = alphaFlag; - return vis; +/* This function should no longer be used. Use _mesa_create_visual() instead */ +GLvisual * +gl_create_visual( GLboolean rgbFlag, + GLboolean alphaFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint depthBits, + GLint stencilBits, + GLint accumBits, + GLint indexBits, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits ) +{ + (void) alphaFlag; + return _mesa_create_visual(rgbFlag, dbFlag, stereoFlag, + redBits, greenBits, blueBits, alphaBits, + indexBits, depthBits, stencilBits, + accumBits, accumBits, accumBits, accumBits, 0); } +void +_mesa_destroy_visual( GLvisual *vis ) +{ + FREE(vis); +} -void gl_destroy_visual( GLvisual *vis ) + +/* obsolete */ +void +gl_destroy_visual( GLvisual *vis ) { - FREE( vis ); + _mesa_destroy_visual(vis); } @@ -340,18 +288,38 @@ void gl_destroy_visual( GLvisual *vis ) * Return: pointer to new GLframebuffer struct or NULL if error. */ -GLframebuffer *gl_create_framebuffer( GLvisual *visual, - GLboolean softwareDepth, - GLboolean softwareStencil, - GLboolean softwareAccum, - GLboolean softwareAlpha ) +GLframebuffer * +gl_create_framebuffer( GLvisual *visual, + GLboolean softwareDepth, + GLboolean softwareStencil, + GLboolean softwareAccum, + GLboolean softwareAlpha ) { - GLframebuffer *buffer; - - buffer = CALLOC_STRUCT(gl_frame_buffer); - if (!buffer) { - return NULL; + GLframebuffer *buffer = CALLOC_STRUCT(gl_frame_buffer); + assert(visual); + if (buffer) { + _mesa_initialize_framebuffer(buffer, visual, + softwareDepth, softwareStencil, + softwareAccum, softwareAlpha ); } + return buffer; +} + + +/* + * Initialize a GLframebuffer object. + * Input: See gl_create_framebuffer() above. + */ +void +_mesa_initialize_framebuffer( GLframebuffer *buffer, + GLvisual *visual, + GLboolean softwareDepth, + GLboolean softwareStencil, + GLboolean softwareAccum, + GLboolean softwareAlpha ) +{ + assert(buffer); + assert(visual); /* sanity checks */ if (softwareDepth ) { @@ -362,7 +330,9 @@ GLframebuffer *gl_create_framebuffer( GLvisual *visual, } if (softwareAccum) { assert(visual->RGBAflag); - assert(visual->AccumBits > 0); + assert(visual->AccumRedBits > 0); + assert(visual->AccumGreenBits > 0); + assert(visual->AccumBlueBits > 0); } if (softwareAlpha) { assert(visual->RGBAflag); @@ -374,20 +344,18 @@ GLframebuffer *gl_create_framebuffer( GLvisual *visual, buffer->UseSoftwareStencilBuffer = softwareStencil; buffer->UseSoftwareAccumBuffer = softwareAccum; buffer->UseSoftwareAlphaBuffers = softwareAlpha; - - return buffer; } - /* * Free a framebuffer struct and its buffers. */ -void gl_destroy_framebuffer( GLframebuffer *buffer ) +void +gl_destroy_framebuffer( GLframebuffer *buffer ) { if (buffer) { - if (buffer->Depth) { - FREE( buffer->Depth ); + if (buffer->DepthBuffer) { + FREE( buffer->DepthBuffer ); } if (buffer->Accum) { FREE( buffer->Accum ); @@ -424,7 +392,8 @@ _glthread_DECLARE_STATIC_MUTEX(OneTimeLock); /* * This function just calls all the various one-time-init functions in Mesa. */ -static void one_time_init( void ) +static void +one_time_init( void ) { static GLboolean alreadyCalled = GL_FALSE; _glthread_LOCK_MUTEX(OneTimeLock); @@ -440,7 +409,7 @@ static void one_time_init( void ) gl_init_clip(); gl_init_eval(); _mesa_init_fog(); - gl_init_math(); + _mesa_init_math(); gl_init_lists(); gl_init_shade(); gl_init_texture(); @@ -471,7 +440,8 @@ static void one_time_init( void ) /* * Allocate and initialize a shared context state structure. */ -static struct gl_shared_state *alloc_shared_state( void ) +static struct gl_shared_state * +alloc_shared_state( void ) { GLuint d; struct gl_shared_state *ss; @@ -496,6 +466,14 @@ static struct gl_shared_state *alloc_shared_state( void ) ss->DefaultD[d]->RefCount++; /* don't free if not in use */ } + ss->DefaultCubeMap = gl_alloc_texture_object(ss, 0, 6); + if (!ss->DefaultCubeMap) { + outOfMemory = GL_TRUE; + } + else { + ss->DefaultCubeMap->RefCount++; + } + if (!ss->DisplayList || !ss->TexObjects || outOfMemory) { /* Ran out of memory at some point. Free everything and return NULL */ if (ss->DisplayList) @@ -508,6 +486,8 @@ static struct gl_shared_state *alloc_shared_state( void ) gl_free_texture_object(ss, ss->DefaultD[2]); if (ss->DefaultD[3]) gl_free_texture_object(ss, ss->DefaultD[3]); + if (ss->DefaultCubeMap) + gl_free_texture_object(ss, ss->DefaultCubeMap); FREE(ss); return NULL; } @@ -520,7 +500,8 @@ static struct gl_shared_state *alloc_shared_state( void ) /* * Deallocate a shared state context and all children structures. */ -static void free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) +static void +free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) { /* Free display lists */ while (1) { @@ -553,7 +534,8 @@ static void free_shared_state( GLcontext *ctx, struct gl_shared_state *ss ) * Initialize the nth light. Note that the defaults for light 0 are * different than the other lights. */ -static void init_light( struct gl_light *l, GLuint n ) +static void +init_light( struct gl_light *l, GLuint n ) { make_empty_list( l ); @@ -580,7 +562,8 @@ static void init_light( struct gl_light *l, GLuint n ) -static void init_lightmodel( struct gl_lightmodel *lm ) +static void +init_lightmodel( struct gl_lightmodel *lm ) { ASSIGN_4V( lm->Ambient, 0.2, 0.2, 0.2, 1.0 ); lm->LocalViewer = GL_FALSE; @@ -589,7 +572,8 @@ static void init_lightmodel( struct gl_lightmodel *lm ) } -static void init_material( struct gl_material *m ) +static void +init_material( struct gl_material *m ) { ASSIGN_4V( m->Ambient, 0.2, 0.2, 0.2, 1.0 ); ASSIGN_4V( m->Diffuse, 0.8, 0.8, 0.8, 1.0 ); @@ -603,7 +587,8 @@ static void init_material( struct gl_material *m ) -static void init_texture_unit( GLcontext *ctx, GLuint unit ) +static void +init_texture_unit( GLcontext *ctx, GLuint unit ) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; @@ -627,10 +612,12 @@ static void init_texture_unit( GLcontext *ctx, GLuint unit ) texUnit->CurrentD[1] = ctx->Shared->DefaultD[1]; texUnit->CurrentD[2] = ctx->Shared->DefaultD[2]; texUnit->CurrentD[3] = ctx->Shared->DefaultD[3]; + texUnit->CurrentCubeMap = ctx->Shared->DefaultCubeMap; } -static void init_fallback_arrays( GLcontext *ctx ) +static void +init_fallback_arrays( GLcontext *ctx ) { struct gl_client_array *cl; GLuint i; @@ -680,7 +667,8 @@ static void init_fallback_arrays( GLcontext *ctx ) /* Initialize a 1-D evaluator map */ -static void init_1d_map( struct gl_1d_map *map, int n, const float *initial ) +static void +init_1d_map( struct gl_1d_map *map, int n, const float *initial ) { map->Order = 1; map->u1 = 0.0; @@ -695,7 +683,8 @@ static void init_1d_map( struct gl_1d_map *map, int n, const float *initial ) /* Initialize a 2-D evaluator map */ -static void init_2d_map( struct gl_2d_map *map, int n, const float *initial ) +static void +init_2d_map( struct gl_2d_map *map, int n, const float *initial ) { map->Uorder = 1; map->Vorder = 1; @@ -712,22 +701,11 @@ static void init_2d_map( struct gl_2d_map *map, int n, const float *initial ) } -static void init_color_table( struct gl_color_table *p ) -{ - p->Table[0] = 255; - p->Table[1] = 255; - p->Table[2] = 255; - p->Table[3] = 255; - p->Size = 1; - p->IntFormat = GL_RGBA; - p->Format = GL_RGBA; -} - - /* * Initialize the attribute groups in a GLcontext. */ -static void init_attrib_groups( GLcontext *ctx ) +static void +init_attrib_groups( GLcontext *ctx ) { GLuint i, j; @@ -736,6 +714,7 @@ static void init_attrib_groups( GLcontext *ctx ) /* Constants, may be overriden by device drivers */ ctx->Const.MaxTextureLevels = MAX_TEXTURE_LEVELS; ctx->Const.MaxTextureSize = 1 << (MAX_TEXTURE_LEVELS - 1); + ctx->Const.MaxCubeTextureSize = ctx->Const.MaxTextureSize; ctx->Const.MaxTextureUnits = MAX_TEXTURE_UNITS; ctx->Const.MaxArrayLockSize = MAX_ARRAY_LOCK_SIZE; ctx->Const.SubPixelBits = SUB_PIXEL_BITS; @@ -750,13 +729,17 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Const.MaxLineWidthAA = MAX_LINE_WIDTH; ctx->Const.LineWidthGranularity = LINE_WIDTH_GRANULARITY; ctx->Const.NumAuxBuffers = NUM_AUX_BUFFERS; + ctx->Const.MaxColorTableSize = MAX_COLOR_TABLE_SIZE; + ctx->Const.MaxConvolutionWidth = MAX_CONVOLUTION_WIDTH; + ctx->Const.MaxConvolutionHeight = MAX_CONVOLUTION_HEIGHT; + ctx->Const.NumCompressedTextureFormats = 0; /* Modelview matrix */ gl_matrix_ctr( &ctx->ModelView ); gl_matrix_alloc_inv( &ctx->ModelView ); ctx->ModelViewStackDepth = 0; - for (i = 0 ; i < MAX_MODELVIEW_STACK_DEPTH ; i++) { + for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) { gl_matrix_ctr( &ctx->ModelViewStack[i] ); gl_matrix_alloc_inv( &ctx->ModelViewStack[i] ); } @@ -773,7 +756,7 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->NearFarStack[0][0] = 1.0; /* These values seem weird by make */ ctx->NearFarStack[0][1] = 0.0; /* sense mathematically. */ - for (i = 0 ; i < MAX_PROJECTION_STACK_DEPTH ; i++) { + for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) { gl_matrix_ctr( &ctx->ProjectionStack[i] ); gl_matrix_alloc_inv( &ctx->ProjectionStack[i] ); } @@ -782,11 +765,18 @@ static void init_attrib_groups( GLcontext *ctx ) for (i=0; i<MAX_TEXTURE_UNITS; i++) { gl_matrix_ctr( &ctx->TextureMatrix[i] ); ctx->TextureStackDepth[i] = 0; - for (j = 0 ; j < MAX_TEXTURE_STACK_DEPTH ; j++) { + for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) { ctx->TextureStack[i][j].inv = 0; } } + /* Color matrix */ + gl_matrix_ctr(&ctx->ColorMatrix); + ctx->ColorStackDepth = 0; + for (j = 0; j < MAX_COLOR_STACK_DEPTH - 1; j++) { + gl_matrix_ctr(&ctx->ColorStack[j]); + } + /* Accumulate buffer group */ ASSIGN_4V( ctx->Accum.ClearColor, 0.0, 0.0, 0.0, 0.0 ); @@ -845,6 +835,7 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Depth.Clear = 1.0; ctx->Depth.Func = GL_LESS; ctx->Depth.Mask = GL_TRUE; + ctx->Depth.OcclusionTest = GL_FALSE; /* Evaluators group */ ctx->Eval.Map1Color4 = GL_FALSE; @@ -920,11 +911,38 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Hint.LineSmooth = GL_DONT_CARE; ctx->Hint.PolygonSmooth = GL_DONT_CARE; ctx->Hint.Fog = GL_DONT_CARE; - ctx->Hint.AllowDrawWin = GL_TRUE; - ctx->Hint.AllowDrawSpn = GL_TRUE; + ctx->Hint.AllowDrawFrg = GL_TRUE; ctx->Hint.AllowDrawMem = GL_TRUE; ctx->Hint.StrictLighting = GL_TRUE; + ctx->Hint.ClipVolumeClipping = GL_DONT_CARE; + ctx->Hint.TextureCompression = GL_DONT_CARE; + + /* Histogram group */ + ctx->Histogram.Width = 0; + ctx->Histogram.Format = GL_RGBA; + ctx->Histogram.Sink = GL_FALSE; + ctx->Histogram.RedSize = 0xffffffff; + ctx->Histogram.GreenSize = 0xffffffff; + ctx->Histogram.BlueSize = 0xffffffff; + ctx->Histogram.AlphaSize = 0xffffffff; + ctx->Histogram.LuminanceSize = 0xffffffff; + for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { + ctx->Histogram.Count[i][0] = 0; + ctx->Histogram.Count[i][1] = 0; + ctx->Histogram.Count[i][2] = 0; + ctx->Histogram.Count[i][3] = 0; + } + + /* Min/Max group */ + ctx->MinMax.Format = GL_RGBA; + ctx->MinMax.Sink = GL_FALSE; + ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000; + ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000; + ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000; + ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000; + + /* Pipeline */ gl_pipeline_init( ctx ); @@ -1022,6 +1040,29 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Pixel.MapGtoG[0] = 0.0; ctx->Pixel.MapBtoB[0] = 0.0; ctx->Pixel.MapAtoA[0] = 0.0; + ctx->Pixel.HistogramEnabled = GL_FALSE; + ctx->Pixel.MinMaxEnabled = GL_FALSE; + ctx->Pixel.PixelTextureEnabled = GL_FALSE; + ctx->Pixel.FragmentRgbSource = GL_PIXEL_GROUP_COLOR_SGIS; + ctx->Pixel.FragmentAlphaSource = GL_PIXEL_GROUP_COLOR_SGIS; + ASSIGN_4V(ctx->Pixel.PostColorMatrixScale, 1.0, 1.0, 1.0, 1.0); + ASSIGN_4V(ctx->Pixel.PostColorMatrixBias, 0.0, 0.0, 0.0, 0.0); + ASSIGN_4V(ctx->Pixel.ColorTableScale, 1.0, 1.0, 1.0, 1.0); + ASSIGN_4V(ctx->Pixel.ColorTableBias, 0.0, 0.0, 0.0, 0.0); + ctx->Pixel.ColorTableEnabled = GL_FALSE; + ctx->Pixel.PostConvolutionColorTableEnabled = GL_FALSE; + ctx->Pixel.PostColorMatrixColorTableEnabled = GL_FALSE; + ctx->Pixel.Convolution1DEnabled = GL_FALSE; + ctx->Pixel.Convolution2DEnabled = GL_FALSE; + ctx->Pixel.Separable2DEnabled = GL_FALSE; + for (i = 0; i < 3; i++) { + ASSIGN_4V(ctx->Pixel.ConvolutionBorderColor[i], 0.0, 0.0, 0.0, 0.0); + ctx->Pixel.ConvolutionBorderMode[i] = GL_REDUCE; + ASSIGN_4V(ctx->Pixel.ConvolutionFilterScale[i], 1.0, 1.0, 1.0, 1.0); + ASSIGN_4V(ctx->Pixel.ConvolutionFilterBias[i], 0.0, 0.0, 0.0, 0.0); + } + ASSIGN_4V(ctx->Pixel.PostConvolutionScale, 1.0, 1.0, 1.0, 1.0); + ASSIGN_4V(ctx->Pixel.PostConvolutionBias, 0.0, 0.0, 0.0, 0.0); /* Point group */ ctx->Point.SmoothFlag = GL_FALSE; @@ -1077,7 +1118,7 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->Texture.Enabled = 0; for (i=0; i<MAX_TEXTURE_UNITS; i++) init_texture_unit( ctx, i ); - init_color_table(&ctx->Texture.Palette); + _mesa_init_colortable(&ctx->Texture.Palette); /* Transformation group */ ctx->Transform.MatrixMode = GL_MODELVIEW; @@ -1100,8 +1141,8 @@ static void init_attrib_groups( GLcontext *ctx ) #define Sz 10 #define Tz 14 - ctx->Viewport.WindowMap.m[Sz] = 0.5 * DEPTH_SCALE; - ctx->Viewport.WindowMap.m[Tz] = 0.5 * DEPTH_SCALE; + ctx->Viewport.WindowMap.m[Sz] = 0.5 * ctx->Visual->DepthMaxF; + ctx->Viewport.WindowMap.m[Tz] = 0.5 * ctx->Visual->DepthMaxF; #undef Sz #undef Tz @@ -1185,6 +1226,23 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->AttribStackDepth = 0; ctx->ClientAttribStackDepth = 0; + /* Display list */ + ctx->CallDepth = 0; + ctx->ExecuteFlag = GL_TRUE; + ctx->CompileFlag = GL_FALSE; + ctx->CurrentListPtr = NULL; + ctx->CurrentBlock = NULL; + ctx->CurrentListNum = 0; + ctx->CurrentPos = 0; + + /* Color tables */ + _mesa_init_colortable(&ctx->ColorTable); + _mesa_init_colortable(&ctx->ProxyColorTable); + _mesa_init_colortable(&ctx->PostConvolutionColorTable); + _mesa_init_colortable(&ctx->ProxyPostConvolutionColorTable); + _mesa_init_colortable(&ctx->PostColorMatrixColorTable); + _mesa_init_colortable(&ctx->ProxyPostColorMatrixColorTable); + /* Miscellaneous */ ctx->NewState = NEW_ALL; ctx->RenderMode = GL_RENDER; @@ -1196,18 +1254,11 @@ static void init_attrib_groups( GLcontext *ctx ) ctx->NeedEyeNormals = GL_FALSE; ctx->vb_proj_matrix = &ctx->ModelProjectMatrix; - /* Display list */ - ctx->CallDepth = 0; - ctx->ExecuteFlag = GL_TRUE; - ctx->CompileFlag = GL_FALSE; - ctx->CurrentListPtr = NULL; - ctx->CurrentBlock = NULL; - ctx->CurrentListNum = 0; - ctx->CurrentPos = 0; - ctx->ErrorValue = (GLenum) GL_NO_ERROR; ctx->CatchSignals = GL_TRUE; + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; /* For debug/development only */ ctx->NoRaster = getenv("MESA_NO_RASTER") ? GL_TRUE : GL_FALSE; @@ -1231,7 +1282,8 @@ static void init_attrib_groups( GLcontext *ctx ) * the allocations clean up and return GL_FALSE. * Return: GL_TRUE=success, GL_FALSE=failure */ -static GLboolean alloc_proxy_textures( GLcontext *ctx ) +static GLboolean +alloc_proxy_textures( GLcontext *ctx ) { GLboolean out_of_memory; GLint i; @@ -1256,9 +1308,9 @@ static GLboolean alloc_proxy_textures( GLcontext *ctx ) out_of_memory = GL_FALSE; for (i=0;i<MAX_TEXTURE_LEVELS;i++) { - ctx->Texture.Proxy1D->Image[i] = gl_alloc_texture_image(); - ctx->Texture.Proxy2D->Image[i] = gl_alloc_texture_image(); - ctx->Texture.Proxy3D->Image[i] = gl_alloc_texture_image(); + ctx->Texture.Proxy1D->Image[i] = _mesa_alloc_texture_image(); + ctx->Texture.Proxy2D->Image[i] = _mesa_alloc_texture_image(); + ctx->Texture.Proxy3D->Image[i] = _mesa_alloc_texture_image(); if (!ctx->Texture.Proxy1D->Image[i] || !ctx->Texture.Proxy2D->Image[i] || !ctx->Texture.Proxy3D->Image[i]) { @@ -1268,13 +1320,13 @@ static GLboolean alloc_proxy_textures( GLcontext *ctx ) if (out_of_memory) { for (i=0;i<MAX_TEXTURE_LEVELS;i++) { if (ctx->Texture.Proxy1D->Image[i]) { - gl_free_texture_image(ctx->Texture.Proxy1D->Image[i]); + _mesa_free_texture_image(ctx->Texture.Proxy1D->Image[i]); } if (ctx->Texture.Proxy2D->Image[i]) { - gl_free_texture_image(ctx->Texture.Proxy2D->Image[i]); + _mesa_free_texture_image(ctx->Texture.Proxy2D->Image[i]); } if (ctx->Texture.Proxy3D->Image[i]) { - gl_free_texture_image(ctx->Texture.Proxy3D->Image[i]); + _mesa_free_texture_image(ctx->Texture.Proxy3D->Image[i]); } } gl_free_texture_object(NULL, ctx->Texture.Proxy1D); @@ -1292,12 +1344,15 @@ static GLboolean alloc_proxy_textures( GLcontext *ctx ) /* * Initialize a GLcontext struct. */ -GLboolean gl_initialize_context_data( GLcontext *ctx, - GLvisual *visual, - GLcontext *share_list, - void *driver_ctx, - GLboolean direct ) +GLboolean +_mesa_initialize_context( GLcontext *ctx, + GLvisual *visual, + GLcontext *share_list, + void *driver_ctx, + GLboolean direct ) { + GLuint dispatchSize; + (void) direct; /* not used */ /* misc one-time initializations */ @@ -1360,10 +1415,6 @@ GLboolean gl_initialize_context_data( GLcontext *ctx, ctx->Pixel.DriverReadBuffer = GL_FRONT_LEFT; } -#ifdef PROFILE - init_timings( ctx ); -#endif - if (!alloc_proxy_textures(ctx)) { free_shared_state(ctx, ctx->Shared); FREE(ctx->VB); @@ -1372,9 +1423,27 @@ GLboolean gl_initialize_context_data( GLcontext *ctx, return GL_FALSE; } + /* register the most recent extension functions with libGL */ + _glapi_add_entrypoint("glTbufferMask3DFX", 553); + _glapi_add_entrypoint("glCompressedTexImage3DARB", 554); + _glapi_add_entrypoint("glCompressedTexImage2DARB", 555); + _glapi_add_entrypoint("glCompressedTexImage1DARB", 556); + _glapi_add_entrypoint("glCompressedTexSubImage3DARB", 557); + _glapi_add_entrypoint("glCompressedTexSubImage2DARB", 558); + _glapi_add_entrypoint("glCompressedTexSubImage1DARB", 559); + _glapi_add_entrypoint("glGetCompressedTexImageARB", 560); + + /* Find the larger of Mesa's dispatch table and libGL's dispatch table. + * In practice, this'll be the same for stand-alone Mesa. But for DRI + * Mesa we do this to accomodate different versions of libGL and various + * DRI drivers. + */ + dispatchSize = MAX2(_glapi_get_dispatch_table_size(), + sizeof(struct _glapi_table) / sizeof(void *)); + /* setup API dispatch tables */ - ctx->Exec = CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *)); - ctx->Save = CALLOC(_glapi_get_dispatch_table_size() * sizeof(void *)); + ctx->Exec = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*)); + ctx->Save = (struct _glapi_table *) CALLOC(dispatchSize * sizeof(void*)); if (!ctx->Exec || !ctx->Save) { free_shared_state(ctx, ctx->Shared); FREE(ctx->VB); @@ -1383,8 +1452,8 @@ GLboolean gl_initialize_context_data( GLcontext *ctx, FREE(ctx->Exec); FREE(ctx); } - _mesa_init_exec_table( ctx->Exec ); - _mesa_init_dlist_table( ctx->Save ); + _mesa_init_exec_table(ctx->Exec, dispatchSize); + _mesa_init_dlist_table(ctx->Save, dispatchSize); ctx->CurrentDispatch = ctx->Exec; return GL_TRUE; @@ -1399,18 +1468,18 @@ GLboolean gl_initialize_context_data( GLcontext *ctx, * driver_ctx - pointer to device driver's context state struct * Return: pointer to a new gl_context struct or NULL if error. */ -GLcontext *gl_create_context( GLvisual *visual, - GLcontext *share_list, - void *driver_ctx, - GLboolean direct ) +GLcontext * +gl_create_context( GLvisual *visual, + GLcontext *share_list, + void *driver_ctx, + GLboolean direct ) { GLcontext *ctx = (GLcontext *) CALLOC( sizeof(GLcontext) ); if (!ctx) { return NULL; } - if (gl_initialize_context_data(ctx, visual, share_list, - driver_ctx, direct)) { + if (_mesa_initialize_context(ctx, visual, share_list, driver_ctx, direct)) { return ctx; } else { @@ -1425,34 +1494,35 @@ GLcontext *gl_create_context( GLvisual *visual, * Free the data associated with the given context. * But don't free() the GLcontext struct itself! */ -void gl_free_context_data( GLcontext *ctx ) +void +gl_free_context_data( GLcontext *ctx ) { - GLuint i; struct gl_shine_tab *s, *tmps; + GLuint i, j; /* if we're destroying the current context, unbind it first */ if (ctx == gl_get_current_context()) { gl_make_current(NULL, NULL); } -#ifdef PROFILE - if (getenv("MESA_PROFILE")) { - print_timings( ctx ); - } -#endif - gl_matrix_dtr( &ctx->ModelView ); - for (i = 0 ; i < MAX_MODELVIEW_STACK_DEPTH ; i++) { + for (i = 0; i < MAX_MODELVIEW_STACK_DEPTH - 1; i++) { gl_matrix_dtr( &ctx->ModelViewStack[i] ); } gl_matrix_dtr( &ctx->ProjectionMatrix ); - for (i = 0 ; i < MAX_PROJECTION_STACK_DEPTH ; i++) { + for (i = 0; i < MAX_PROJECTION_STACK_DEPTH - 1; i++) { gl_matrix_dtr( &ctx->ProjectionStack[i] ); } + for (i = 0; i < MAX_TEXTURE_UNITS; i++) { + gl_matrix_dtr( &ctx->TextureMatrix[i] ); + for (j = 0; j < MAX_TEXTURE_STACK_DEPTH - 1; j++) { + gl_matrix_dtr( &ctx->TextureStack[i][j] ); + } + } FREE( ctx->PB ); - if(ctx->input != ctx->VB->IM) + if (ctx->input != ctx->VB->IM) gl_immediate_free( ctx->input ); gl_vb_free( ctx->VB ); @@ -1515,6 +1585,11 @@ void gl_free_context_data( GLcontext *ctx ) if (ctx->EvalMap.Map2Texture4.Points) FREE( ctx->EvalMap.Map2Texture4.Points ); + _mesa_free_colortable_data( &ctx->ColorTable ); + _mesa_free_colortable_data( &ctx->PostConvolutionColorTable ); + _mesa_free_colortable_data( &ctx->PostColorMatrixColorTable ); + _mesa_free_colortable_data( &ctx->Texture.Palette ); + /* Free cache of immediate buffers. */ while (ctx->nr_im_queued-- > 0) { struct immediate * next = ctx->freed_im_queue->next; @@ -1532,7 +1607,8 @@ void gl_free_context_data( GLcontext *ctx ) /* * Destroy a GLcontext structure. */ -void gl_destroy_context( GLcontext *ctx ) +void +gl_destroy_context( GLcontext *ctx ) { if (ctx) { gl_free_context_data(ctx); @@ -1546,7 +1622,8 @@ void gl_destroy_context( GLcontext *ctx ) * Called by the driver after both the context and driver are fully * initialized. Currently just reads the config file. */ -void gl_context_initialize( GLcontext *ctx ) +void +gl_context_initialize( GLcontext *ctx ) { gl_read_config_file( ctx ); } @@ -1559,7 +1636,8 @@ void gl_context_initialize( GLcontext *ctx ) * dst - destination context * mask - bitwise OR of GL_*_BIT flags */ -void gl_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask ) +void +gl_copy_context( const GLcontext *src, GLcontext *dst, GLuint mask ) { if (mask & GL_ACCUM_BUFFER_BIT) { MEMCPY( &dst->Accum, &src->Accum, sizeof(struct gl_accum_attrib) ); @@ -1767,7 +1845,7 @@ _mesa_get_dispatch(GLcontext *ctx) void gl_problem( const GLcontext *ctx, const char *s ) { fprintf( stderr, "Mesa implementation error: %s\n", s ); - fprintf( stderr, "Report to mesa-bugs@mesa3d.org\n" ); + fprintf( stderr, "Report to Mesa bug database at www.mesa3d.org\n" ); (void) ctx; } diff --git a/xc/extras/Mesa/src/context.h b/xc/extras/Mesa/src/context.h index 535ac238e..51c4aaba3 100644 --- a/xc/extras/Mesa/src/context.h +++ b/xc/extras/Mesa/src/context.h @@ -56,20 +56,62 @@ * the colorbuffer, depth buffer, stencil buffer and accum buffer which will * be used by the GL context and framebuffer. */ -extern GLvisual *gl_create_visual( GLboolean rgbFlag, - GLboolean alphaFlag, - GLboolean dbFlag, - GLboolean stereoFlag, - GLint depthBits, - GLint stencilBits, - GLint accumBits, - GLint indexBits, - GLint redBits, - GLint greenBits, - GLint blueBits, - GLint alphaBits ); - -extern void gl_destroy_visual( GLvisual *vis ); +extern GLvisual * +_mesa_create_visual( GLboolean rgbFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint indexBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ); + +extern GLboolean +_mesa_initialize_visual( GLvisual *v, + GLboolean rgbFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits, + GLint indexBits, + GLint depthBits, + GLint stencilBits, + GLint accumRedBits, + GLint accumGreenBits, + GLint accumBlueBits, + GLint accumAlphaBits, + GLint numSamples ); + +/* this function is obsolete */ +extern GLvisual * +gl_create_visual( GLboolean rgbFlag, + GLboolean alphaFlag, + GLboolean dbFlag, + GLboolean stereoFlag, + GLint depthBits, + GLint stencilBits, + GLint accumBits, + GLint indexBits, + GLint redBits, + GLint greenBits, + GLint blueBits, + GLint alphaBits ); + + +extern void +_mesa_destroy_visual( GLvisual *vis ); + +/*obsolete */ extern void gl_destroy_visual( GLvisual *vis ); + /* @@ -77,13 +119,23 @@ extern void gl_destroy_visual( GLvisual *vis ); * It bundles up the depth buffer, stencil buffer and accum buffers into a * single entity. */ -extern GLframebuffer *gl_create_framebuffer( GLvisual *visual, - GLboolean softwareDepth, - GLboolean softwareStencil, - GLboolean softwareAccum, - GLboolean softwareAlpha ); +extern GLframebuffer * +gl_create_framebuffer( GLvisual *visual, + GLboolean softwareDepth, + GLboolean softwareStencil, + GLboolean softwareAccum, + GLboolean softwareAlpha ); + +extern void +_mesa_initialize_framebuffer( GLframebuffer *fb, + GLvisual *visual, + GLboolean softwareDepth, + GLboolean softwareStencil, + GLboolean softwareAccum, + GLboolean softwareAlpha ); -extern void gl_destroy_framebuffer( GLframebuffer *buffer ); +extern void +gl_destroy_framebuffer( GLframebuffer *buffer ); @@ -91,36 +143,46 @@ extern void gl_destroy_framebuffer( GLframebuffer *buffer ); * Create/destroy a GLcontext. A GLcontext is like a GLX context. It * contains the rendering state. */ -extern GLcontext *gl_create_context( GLvisual *visual, - GLcontext *share_list, - void *driver_ctx, - GLboolean direct); +extern GLcontext * +gl_create_context( GLvisual *visual, + GLcontext *share_list, + void *driver_ctx, + GLboolean direct); + +extern GLboolean +_mesa_initialize_context( GLcontext *ctx, + GLvisual *visual, + GLcontext *share_list, + void *driver_ctx, + GLboolean direct ); -extern GLboolean gl_initialize_context_data( GLcontext *ctx, - GLvisual *visual, - GLcontext *share_list, - void *driver_ctx, - GLboolean direct ); +extern void +gl_free_context_data( GLcontext *ctx ); -extern void gl_free_context_data( GLcontext *ctx ); +extern void +gl_destroy_context( GLcontext *ctx ); -extern void gl_destroy_context( GLcontext *ctx ); +extern void +gl_context_initialize( GLcontext *ctx ); -extern void gl_context_initialize( GLcontext *ctx ); +extern void +gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); -extern void gl_copy_context(const GLcontext *src, GLcontext *dst, GLuint mask); +extern void +gl_make_current( GLcontext *ctx, GLframebuffer *buffer ); -extern void gl_make_current( GLcontext *ctx, GLframebuffer *buffer ); +extern void +gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer, + GLframebuffer *readBuffer ); -extern void gl_make_current2( GLcontext *ctx, GLframebuffer *drawBuffer, - GLframebuffer *readBuffer ); +extern GLcontext * +gl_get_current_context(void); -extern GLcontext *gl_get_current_context(void); /* @@ -141,7 +203,7 @@ do { \ extern struct immediate *_mesa_CurrentInput; -#define GET_CURRENT_CONTEXT(C) GLcontext *C = _glapi_Context +#define GET_CURRENT_CONTEXT(C) GLcontext *C = (GLcontext *) _glapi_Context #define GET_IMMEDIATE struct immediate *IM = _mesa_CurrentInput @@ -168,35 +230,26 @@ _mesa_get_dispatch(GLcontext *ctx); * Miscellaneous */ -extern void gl_problem( const GLcontext *ctx, const char *s ); - -extern void gl_warning( const GLcontext *ctx, const char *s ); - -extern void gl_error( GLcontext *ctx, GLenum error, const char *s ); - -extern void gl_compile_error( GLcontext *ctx, GLenum error, const char *s ); - +extern void +gl_problem( const GLcontext *ctx, const char *s ); +extern void +gl_warning( const GLcontext *ctx, const char *s ); extern void -_mesa_Finish( void ); +gl_error( GLcontext *ctx, GLenum error, const char *s ); extern void -_mesa_Flush( void ); +gl_compile_error( GLcontext *ctx, GLenum error, const char *s ); extern void -_mesa_init_no_op_table(struct _glapi_table *exec); +_mesa_Finish( void ); extern void -_mesa_init_exec_table(struct _glapi_table *exec); - - +_mesa_Flush( void ); -#ifdef PROFILE -extern GLdouble gl_time( void ); -#endif #endif diff --git a/xc/extras/Mesa/src/copypix.c b/xc/extras/Mesa/src/copypix.c index a77086ccf..e76c170f6 100644 --- a/xc/extras/Mesa/src/copypix.c +++ b/xc/extras/Mesa/src/copypix.c @@ -32,13 +32,16 @@ #include "copypix.h" #include "depth.h" #include "feedback.h" +#include "imaging.h" #include "macros.h" #include "mem.h" #include "mmath.h" #include "pixel.h" +#include "pixeltex.h" #include "span.h" #include "state.h" #include "stencil.h" +#include "texture.h" #include "types.h" #include "zoom.h" #endif @@ -83,6 +86,7 @@ static void copy_rgba_pixels( GLcontext *ctx, GLubyte *saveReadAlpha; const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; + GLboolean applyTransferOps; /* Determine if copy should be done bottom-to-top or top-to-bottom */ if (srcy < desty) { @@ -103,7 +107,7 @@ static void copy_rgba_pixels( GLcontext *ctx, if (ctx->Depth.Test || ctx->Fog.Enabled) { /* fill in array of z values */ - GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMax); for (i=0;i<width;i++) { zspan[i] = z; } @@ -156,6 +160,15 @@ static void copy_rgba_pixels( GLcontext *ctx, p = NULL; } + applyTransferOps = ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled || + ctx->Pixel.HistogramEnabled; + for (j = 0; j < height; j++, sy += stepy, dy += stepy) { if (overlapping) { MEMCPY(rgba, p, width * sizeof(GLubyte) * 4); @@ -188,12 +201,70 @@ static void copy_rgba_pixels( GLcontext *ctx, ctx->ReadBuffer->Alpha = saveReadAlpha; } - if (ctx->Pixel.ScaleOrBiasRGBA) { - gl_scale_and_bias_rgba( ctx, width, rgba ); + if (applyTransferOps) { + const GLfloat scale = (1.0F / 255.0F); + GLfloat rgbaFloat[MAX_WIDTH][4]; + GLuint k; + /* convert ubyte to float */ + for (k = 0; k < width; k++) { + rgbaFloat[k][RCOMP] = (GLfloat) rgba[k][RCOMP] * scale; + rgbaFloat[k][GCOMP] = (GLfloat) rgba[k][GCOMP] * scale; + rgbaFloat[k][BCOMP] = (GLfloat) rgba[k][BCOMP] * scale; + rgbaFloat[k][ACOMP] = (GLfloat) rgba[k][ACOMP] * scale; + } + /* scale & bias */ + if (ctx->Pixel.ScaleOrBiasRGBA) { + _mesa_scale_and_bias_rgba(ctx, width, rgbaFloat); + } + /* color map lookup */ + if (ctx->Pixel.MapColorFlag) { + _mesa_map_rgba(ctx, width, rgbaFloat); + } + /* GL_COLOR_TABLE lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, width, rgbaFloat); + } + /* color matrix */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, width, rgbaFloat); + } + /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ + if (ctx->Pixel.PostColorMatrixColorTableEnabled) { + _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, width, rgbaFloat); + } + /* update histogram count */ + if (ctx->Pixel.HistogramEnabled) { + _mesa_update_histogram(ctx, width, (CONST GLfloat (*)[4]) rgbaFloat); + } + /* update min/max */ + if (ctx->Pixel.MinMaxEnabled) { + _mesa_update_minmax(ctx, width, (CONST GLfloat (*)[4]) rgbaFloat); + } + /* clamp to [0,1] and convert float back to ubyte */ + for (k = 0; k < width; k++) { + GLint r = (GLint) (rgbaFloat[k][RCOMP] * 255.0F); + GLint g = (GLint) (rgbaFloat[k][GCOMP] * 255.0F); + GLint b = (GLint) (rgbaFloat[k][BCOMP] * 255.0F); + GLint a = (GLint) (rgbaFloat[k][ACOMP] * 255.0F); + rgba[k][RCOMP] = (GLubyte) CLAMP(r, 0, 255); + rgba[k][GCOMP] = (GLubyte) CLAMP(g, 0, 255); + rgba[k][BCOMP] = (GLubyte) CLAMP(b, 0, 255); + rgba[k][ACOMP] = (GLubyte) CLAMP(a, 0, 255); + } } - if (ctx->Pixel.MapColorFlag) { - gl_map_rgba( ctx, width, rgba ); + + if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) { + GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH]; + GLuint unit; + /* XXX not sure how multitexture is supposed to work here */ + for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) { + _mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba, + s, t, r, q); + gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba); + } } + if (quick_draw && dy >= 0 && dy < ctx->DrawBuffer->Height) { (*ctx->Driver.WriteRGBASpan)( ctx, width, destx, dy, (const GLubyte (*)[4])rgba, NULL ); @@ -244,7 +315,7 @@ static void copy_ci_pixels( GLcontext *ctx, if (ctx->Depth.Test || ctx->Fog.Enabled) { /* fill in array of z values */ - GLint z = (GLint) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMax); for (i=0;i<width;i++) { zspan[i] = z; } @@ -298,10 +369,10 @@ static void copy_ci_pixels( GLcontext *ctx, } if (shift_or_offset) { - gl_shift_and_offset_ci( ctx, width, indexes ); + _mesa_shift_and_offset_ci( ctx, width, indexes ); } if (ctx->Pixel.MapColorFlag) { - gl_map_ci( ctx, width, indexes ); + _mesa_map_ci( ctx, width, indexes ); } if (zoom) { @@ -335,7 +406,7 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, const GLboolean zoom = ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F; GLint overlapping; - if (!ctx->ReadBuffer->Depth || !ctx->DrawBuffer->Depth) { + if (!ctx->ReadBuffer->DepthBuffer || !ctx->DrawBuffer->DepthBuffer) { gl_error( ctx, GL_INVALID_OPERATION, "glCopyPixels" ); return; } @@ -401,7 +472,7 @@ static void copy_depth_pixels( GLcontext *ctx, GLint srcx, GLint srcy, for (i = 0; i < width; i++) { GLfloat d = depth[i] * ctx->Pixel.DepthScale + ctx->Pixel.DepthBias; - zspan[i] = (GLint) (CLAMP( d, 0.0F, 1.0F ) * DEPTH_SCALE); + zspan[i] = (GLdepth) (CLAMP(d, 0.0F, 1.0F) * ctx->Visual->DepthMax); } if (ctx->Visual->RGBAflag) { @@ -473,7 +544,7 @@ static void copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy, } p = psten; for (j = 0; j < height; j++, ssy += stepy) { - gl_read_stencil_span( ctx, width, srcx, ssy, p ); + _mesa_read_stencil_span( ctx, width, srcx, ssy, p ); p += width; } p = psten; @@ -491,21 +562,21 @@ static void copy_stencil_pixels( GLcontext *ctx, GLint srcx, GLint srcy, p += width; } else { - gl_read_stencil_span( ctx, width, srcx, sy, stencil ); + _mesa_read_stencil_span( ctx, width, srcx, sy, stencil ); } if (shift_or_offset) { - gl_shift_and_offset_stencil( ctx, width, stencil ); + _mesa_shift_and_offset_stencil( ctx, width, stencil ); } if (ctx->Pixel.MapStencilFlag) { - gl_map_stencil( ctx, width, stencil ); + _mesa_map_stencil( ctx, width, stencil ); } if (zoom) { gl_write_zoomed_stencil_span( ctx, width, destx, dy, stencil, desty ); } else { - gl_write_stencil_span( ctx, width, destx, dy, stencil ); + _mesa_write_stencil_span( ctx, width, destx, dy, stencil ); } } @@ -542,6 +613,14 @@ _mesa_CopyPixels( GLint srcx, GLint srcy, GLsizei width, GLsizei height, destx = (GLint) (ctx->Current.RasterPos[0] + 0.5F); desty = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + ctx->OcclusionResult = GL_TRUE; + + if (ctx->Driver.CopyPixels && + (*ctx->Driver.CopyPixels)( ctx, srcx, srcy, width, height, + destx, desty, type )) { + return; + } + if (type == GL_COLOR && ctx->Visual->RGBAflag) { copy_rgba_pixels( ctx, srcx, srcy, width, height, destx, desty ); } diff --git a/xc/extras/Mesa/src/dd.h b/xc/extras/Mesa/src/dd.h index 25a82a546..ad389df4a 100644 --- a/xc/extras/Mesa/src/dd.h +++ b/xc/extras/Mesa/src/dd.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -390,6 +390,8 @@ struct dd_function_table { /*** *** For supporting hardware Z buffers: *** Either ALL or NONE of these functions must be implemented! + *** NOTE that Each depth value is a 32-bit GLuint. If the depth + *** buffer is less than 32 bits deep then the extra upperbits are zero. ***/ void (*WriteDepthSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, @@ -431,13 +433,11 @@ struct dd_function_table { * Else, only write stencil[i] if mask[i] is non-zero. */ - void (*ReadStencilSpan)( GLcontext *ctx, GLuint n, GLint x, GLint y, GLstencil stencil[] ); /* Read a horizontal span of stencil values from the stencil buffer. */ - void (*WriteStencilPixels)( GLcontext *ctx, GLuint n, const GLint x[], const GLint y[], const GLstencil stencil[], @@ -454,18 +454,10 @@ struct dd_function_table { */ - /*** - *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions: + *** glDraw/Read/CopyPixels and glBitmap functions: ***/ - points_func PointsFunc; - line_func LineFunc; - triangle_func TriangleFunc; - quad_func QuadFunc; - rect_func RectFunc; - - GLboolean (*DrawPixels)( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, @@ -477,6 +469,25 @@ struct dd_function_table { * must do the job. */ + GLboolean (*ReadPixels)( GLcontext *ctx, + GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, + const struct gl_pixelstore_attrib *unpack, + GLvoid *dest ); + /* Called by glReadPixels. + * Return GL_TRUE if operation completed, else return GL_FALSE. + * This function must respect all glPixelTransfer settings. + */ + + GLboolean (*CopyPixels)( GLcontext *ctx, + GLint srcx, GLint srcy, + GLsizei width, GLsizei height, + GLint dstx, GLint dsty, GLenum type ); + /* Do a glCopyPixels. Return GL_TRUE if operation completed, else + * return GL_FALSE. This function must respect all rasterization + * state, glPixelTransfer, glPixelZoom, etc. + */ + GLboolean (*Bitmap)( GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height, const struct gl_pixelstore_attrib *unpack, @@ -484,78 +495,17 @@ struct dd_function_table { /* This is called by glBitmap. Works the same as DrawPixels, above. */ - void (*RenderStart)( GLcontext *ctx ); - void (*RenderFinish)( GLcontext *ctx ); - /* KW: These replace Begin and End, and have more relaxed semantics. - * They are called prior-to and after one or more vb flush, and are - * thus decoupled from the gl_begin/gl_end pairs, which are possibly - * more frequent. If a begin/end pair covers >1 vertex buffer, these - * are called at most once for the pair. (a bit broken at present) - */ - - void (*RasterSetup)( struct vertex_buffer *VB, GLuint start, GLuint end ); - /* This function, if not NULL, is called whenever new window coordinates - * are put in the vertex buffer. The vertices in question are those n - * such that start <= n < end. - * The device driver can convert the window coords to its own specialized - * format. The 3Dfx driver uses this. - * - * Note: Deprecated in favour of RegisterPipelineStages, below. - */ - - - render_func *RenderVBClippedTab; - render_func *RenderVBCulledTab; - render_func *RenderVBRawTab; - /* These function tables allow the device driver to rasterize an - * entire begin/end group of primitives at once. See the - * gl_render_vb() function in vbrender.c for more details. - */ - - - void (*ReducedPrimitiveChange)( GLcontext *ctx, GLenum primitive ); - /* If registered, this will be called when rendering transitions between - * points, lines and triangles. It is not called on transitions between - * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between - * triangles and quads or triangles and polygons. - */ - - GLuint TriangleCaps; - /* Holds a list of the reasons why we might normally want to call - * render_triangle, but which are in fact implemented by the - * driver. The FX driver sets this to DD_TRI_CULL, and will soon - * implement DD_TRI_OFFSET. - */ - - - GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno ); - /* Driver may request additional render passes by returning GL_TRUE - * when this function is called. This function will be called - * after the first pass, and passes will be made until the function - * returns GL_FALSE. If no function is registered, only one pass - * is made. - * - * This function will be first invoked with passno == 1. - */ /*** *** Texture mapping functions: ***/ - void (*TexEnv)( GLcontext *ctx, GLenum pname, const GLfloat *param ); - /* - * Called whenever glTexEnv*() is called. - * Pname will be one of GL_TEXTURE_ENV_MODE or GL_TEXTURE_ENV_COLOR. - * If pname is GL_TEXTURE_ENV_MODE then param will be one - * of GL_MODULATE, GL_BLEND, GL_DECAL, or GL_REPLACE. - */ - void (*TexImage)( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj, GLint level, GLint internalFormat, const struct gl_texture_image *image ); - /* - * Called whenever a texture object's image is changed. + /* XXX this function is obsolete */ + /* Called whenever a texture object's image is changed. * texObject is the number of the texture object being changed. * level indicates the mipmap level. * internalFormat is the format in which the texture is to be stored. @@ -569,70 +519,310 @@ struct dd_function_table { GLsizei width, GLsizei height, GLint internalFormat, const struct gl_texture_image *image ); - /* - * Called from glTexSubImage() to define a sub-region of a texture. + /* XXX this function is obsolete */ + /* Called from glTexSubImage() to define a sub-region of a texture. + */ + + + GLboolean (*TexImage1D)( GLcontext *ctx, GLenum target, GLint level, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLboolean *retainInternalCopy ); + GLboolean (*TexImage2D)( GLcontext *ctx, GLenum target, GLint level, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLboolean *retainInternalCopy ); + GLboolean (*TexImage3D)( GLcontext *ctx, GLenum target, GLint level, + GLenum format, GLenum type, const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLboolean *retainInternalCopy ); + /* Called by glTexImage1/2/3D. + * Will not be called if any glPixelTransfer operations are enabled. + * Arguments: + * <target>, <level>, <format>, <type> and <pixels> are user specified. + * <packing> indicates the image packing of pixels. + * <texObj> is the target texture object. + * <texImage> is the target texture image. It will have the texture + * width, height, depth, border and internalFormat information. + * <retainInternalCopy> is returned by this function and indicates whether + * core Mesa should keep an internal copy of the texture image. + * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa + * should do the job. If GL_FALSE is returned, this function will be + * called a second time after the texture image has been unpacked into + * GLubytes. It may be easier for the driver to handle then. + */ + + GLboolean (*TexSubImage1D)( GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + GLboolean (*TexSubImage2D)( GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + GLboolean (*TexSubImage3D)( GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLint depth, + GLenum format, GLenum type, + const GLvoid *pixels, + const struct gl_pixelstore_attrib *packing, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /* Called by glTexSubImage1/2/3D. + * Will not be called if any glPixelTransfer operations are enabled. + * Arguments: + * <target>, <level>, <xoffset>, <yoffset>, <zoffset>, <width>, <height>, + * <depth>, <format>, <type> and <pixels> are user specified. + * <packing> indicates the image packing of pixels. + * <texObj> is the target texture object. + * <texImage> is the target texture image. It will have the texture + * width, height, border and internalFormat information. + * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa + * should do the job. If GL_FALSE is returned, then TexImage1/2/3D will + * be called with the complete texture image. + */ + + GLboolean (*CopyTexImage1D)( GLcontext *ctx, GLenum target, GLint level, + GLenum internalFormat, GLint x, GLint y, + GLsizei width, GLint border ); + GLboolean (*CopyTexImage2D)( GLcontext *ctx, GLenum target, GLint level, + GLenum internalFormat, GLint x, GLint y, + GLsizei width, GLsizei height, GLint border ); + /* Called by glCopyTexImage1D and glCopyTexImage2D. + * Will not be called if any glPixelTransfer operations are enabled. + * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa + * should do the job. + */ + + GLboolean (*CopyTexSubImage1D)( GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, + GLint x, GLint y, GLsizei width ); + GLboolean (*CopyTexSubImage2D)( GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + GLboolean (*CopyTexSubImage3D)( GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ); + /* Called by glCopyTexSubImage1/2/3D. + * Will not be called if any glPixelTransfer operations are enabled. + * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa + * should do the job. + */ + + GLvoid *(*GetTexImage)( GLcontext *ctx, GLenum target, GLint level, + const struct gl_texture_object *texObj, + GLenum *formatOut, GLenum *typeOut, + GLboolean *freeImageOut ); + /* Called by glGetTexImage or by core Mesa when a texture image + * is needed for software fallback rendering. + * Return the address of the texture image or NULL if failure. + * The image must be tightly packed (i.e. row stride = image width) + * Return the image's format and type in formatOut and typeOut. + * The format and type must be values which are accepted by glTexImage. + * Set the freeImageOut flag if the returned image should be deallocated + * with FREE() when finished. + * The size of the image can be deduced from the target and level. + * Core Mesa will perform any image format/type conversions that are needed. + */ + + GLboolean (*CompressedTexImage1D)( GLcontext *ctx, GLenum target, + GLint level, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLboolean *retainInternalCopy); + GLboolean (*CompressedTexImage2D)( GLcontext *ctx, GLenum target, + GLint level, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLboolean *retainInternalCopy); + GLboolean (*CompressedTexImage3D)( GLcontext *ctx, GLenum target, + GLint level, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLboolean *retainInternalCopy); + /* Called by glCompressedTexImage1/2/3D. + * Arguments: + * <target>, <level>, <internalFormat>, <data> are user specified. + * <texObj> is the target texture object. + * <texImage> is the target texture image. It will have the texture + * width, height, depth, border and internalFormat information. + * <retainInternalCopy> is returned by this function and indicates whether + * core Mesa should keep an internal copy of the texture image. + * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa + * should do the job. + */ + + GLboolean (*CompressedTexSubImage1D)( GLcontext *ctx, GLenum target, + GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + GLboolean (*CompressedTexSubImage2D)( GLcontext *ctx, GLenum target, + GLint level, GLint xoffset, + GLint yoffset, GLsizei width, + GLint height, GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + GLboolean (*CompressedTexSubImage3D)( GLcontext *ctx, GLenum target, + GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, + GLsizei width, GLint height, + GLint depth, GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /* Called by glCompressedTexSubImage1/2/3D. + * Arguments: + * <target>, <level>, <x/z/zoffset>, <width>, <height>, <depth>, + * <imageSize>, and <data> are user specified. + * <texObj> is the target texture object. + * <texImage> is the target texture image. It will have the texture + * width, height, depth, border and internalFormat information. + * Return GL_TRUE if operation completed, return GL_FALSE if core Mesa + * should do the job. + */ + + void (*GetCompressedTexImage)( GLcontext *ctx, GLenum target, + GLint lod, void *image, + const struct gl_texture_object *texObj, + struct gl_texture_image *texImage ); + /* Called by glGetCompressedTexImageARB. + * <target>, <lod>, <image> are specified by user. + * <texObj> is the source texture object. + * <texImage> is the source texture image. + */ + + void (*TexEnv)( GLcontext *ctx, GLenum target, GLenum pname, + const GLfloat *param ); + /* Called by glTexEnv*(). */ void (*TexParameter)( GLcontext *ctx, GLenum target, - struct gl_texture_object *tObj, + struct gl_texture_object *texObj, GLenum pname, const GLfloat *params ); - /* - * Called whenever glTexParameter*() is called. - * target is GL_TEXTURE_1D or GL_TEXTURE_2D - * texObject is the texture object to modify - * pname is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, - * GL_TEXTURE_WRAP_S, GL_TEXTURE_WRAP_T, or GL_TEXTURE_BORDER_COLOR. - * params is dependant on pname. See man glTexParameter. + /* Called by glTexParameter*(). + * <target> is user specified + * <texObj> the texture object to modify + * <pname> is one of GL_TEXTURE_MIN_FILTER, GL_TEXTURE_MAG_FILTER, + * GL_TEXTURE_WRAP_[STR], or GL_TEXTURE_BORDER_COLOR. + * <params> is user specified. */ void (*BindTexture)( GLcontext *ctx, GLenum target, struct gl_texture_object *tObj ); - /* - * Called whenever glBindTexture() is called. This specifies which - * texture is to be the current one. No dirty flags will be set. + /* Called by glBindTexture(). */ void (*DeleteTexture)( GLcontext *ctx, struct gl_texture_object *tObj ); - /* - * Called when a texture object is about to be deallocated. Driver + /* Called when a texture object is about to be deallocated. Driver * should free anything attached to the DriverData pointers. */ - void (*UpdateTexturePalette)( GLcontext *ctx, - struct gl_texture_object *tObj ); - /* - * Called when the texture's color lookup table is changed. - * If tObj is NULL then the shared texture palette ctx->Texture.Palette - * was changed. + GLboolean (*IsTextureResident)( GLcontext *ctx, + struct gl_texture_object *t ); + /* Called by glAreTextureResident(). */ - void (*UseGlobalTexturePalette)( GLcontext *ctx, GLboolean state ); - /* - * Called via glEnable/Disable(GL_SHARED_TEXTURE_PALETTE_EXT) + void (*PrioritizeTexture)( GLcontext *ctx, struct gl_texture_object *t, + GLclampf priority ); + /* Called by glPrioritizeTextures(). */ void (*ActiveTexture)( GLcontext *ctx, GLuint texUnitNumber ); - /* - * Called by glActiveTextureARB to set current texture unit. + /* Called by glActiveTextureARB to set current texture unit. */ + void (*UpdateTexturePalette)( GLcontext *ctx, + struct gl_texture_object *tObj ); + /* Called when the texture's color lookup table is changed. + * If tObj is NULL then the shared texture palette ctx->Texture.Palette + * is to be updated. + */ - GLboolean (*IsTextureResident)( GLcontext *ctx, - struct gl_texture_object *t ); - /* - * Allows the driver to implement the AreTexturesResident tests without - * knowing about Mesa's internal hash tables for textures. + + + /*** + *** Accelerated point, line, polygon, glDrawPixels and glBitmap functions: + ***/ + + points_func PointsFunc; + line_func LineFunc; + triangle_func TriangleFunc; + quad_func QuadFunc; + rect_func RectFunc; + + + /*** + *** Transformation/Rendering functions + ***/ + + void (*RenderStart)( GLcontext *ctx ); + void (*RenderFinish)( GLcontext *ctx ); + /* KW: These replace Begin and End, and have more relaxed semantics. + * They are called prior-to and after one or more vb flush, and are + * thus decoupled from the gl_begin/gl_end pairs, which are possibly + * more frequent. If a begin/end pair covers >1 vertex buffer, these + * are called at most once for the pair. (a bit broken at present) + */ + + void (*RasterSetup)( struct vertex_buffer *VB, GLuint start, GLuint end ); + /* This function, if not NULL, is called whenever new window coordinates + * are put in the vertex buffer. The vertices in question are those n + * such that start <= n < end. + * The device driver can convert the window coords to its own specialized + * format. The 3Dfx driver uses this. + * + * Note: Deprecated in favour of RegisterPipelineStages, below. */ - void (*PrioritizeTexture)( GLcontext *ctx, - struct gl_texture_object *t, - GLclampf priority ); - /* - * Notify driver of priority change for a texture. + render_func *RenderVBClippedTab; + render_func *RenderVBCulledTab; + render_func *RenderVBRawTab; + /* These function tables allow the device driver to rasterize an + * entire begin/end group of primitives at once. See the + * gl_render_vb() function in vbrender.c for more details. */ + void (*ReducedPrimitiveChange)( GLcontext *ctx, GLenum primitive ); + /* If registered, this will be called when rendering transitions between + * points, lines and triangles. It is not called on transitions between + * primtives such as GL_TRIANGLES and GL_TRIANGLE_STRIPS, or between + * triangles and quads or triangles and polygons. + */ + GLuint TriangleCaps; + /* Holds a list of the reasons why we might normally want to call + * render_triangle, but which are in fact implemented by the + * driver. The FX driver sets this to DD_TRI_CULL, and will soon + * implement DD_TRI_OFFSET. + */ + GLboolean (*MultipassFunc)( struct vertex_buffer *VB, GLuint passno ); + /* Driver may request additional render passes by returning GL_TRUE + * when this function is called. This function will be called + * after the first pass, and passes will be made until the function + * returns GL_FALSE. If no function is registered, only one pass + * is made. + * + * This function will be first invoked with passno == 1. + */ /*** *** NEW in Mesa 3.x @@ -704,7 +894,11 @@ struct dd_function_table { void (*Lightfv)(GLcontext *ctx, GLenum light, GLenum pname, const GLfloat *params, GLint nparams ); void (*LightModelfv)(GLcontext *ctx, GLenum pname, const GLfloat *params); + void (*LineStipple)(GLcontext *ctx, GLint factor, GLushort pattern ); + void (*LineWidth)(GLcontext *ctx, GLfloat width); + void (*LogicOpcode)(GLcontext *ctx, GLenum opcode); void (*PolygonMode)(GLcontext *ctx, GLenum face, GLenum mode); + void (*PolygonStipple)(GLcontext *ctx, const GLubyte *mask ); void (*Scissor)(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h); void (*ShadeModel)(GLcontext *ctx, GLenum mode); void (*ClearStencil)(GLcontext *ctx, GLint s); diff --git a/xc/extras/Mesa/src/ddsample.c b/xc/extras/Mesa/src/ddsample.c index 364b091eb..31e4811b1 100644 --- a/xc/extras/Mesa/src/ddsample.c +++ b/xc/extras/Mesa/src/ddsample.c @@ -51,6 +51,13 @@ * the core Mesa library. */ +/* + * XXX XXX + * THIS FILE IS VERY OUT OF DATE! LOOK AT OSmesa/osmesa.c FOR A BETTER + * EXAMPLE DRIVER! + */ + + #ifdef PC_HEADER #include "all.h" @@ -240,10 +247,20 @@ static void dither( GLcontext *ctx, GLboolean enable ) /* - * Set the current drawing/reading buffer, return GL_TRUE or GL_FALSE - * for success/failure. + * Set the current reading buffer. + */ +static void set_read_buffer( GLcontext *ctx, GLframebuffer *bufer, + GLenum mode ) +{ + struct foo_mesa_context *foo = (struct foo_mesa_context *) ctx->DriverCtx; + setup_DD_pointers( ctx ); +} + + +/* + * Set the destination/draw buffer. */ -static GLboolean set_buffer( GLcontext *ctx, GLenum mode ) +static GLboolean set_draw_buffer( GLcontext *ctx, GLenum mode ) { struct foo_mesa_context *foo = (struct foo_mesa_context *) ctx->DriverCtx; setup_DD_pointers( ctx ); @@ -311,8 +328,8 @@ static void fast_points_function( GLcontext *ctx, GLuint first, GLuint last ) for (i=first;i<=last;i++) { if (VB->ClipMask[i]==0) { int x, y; - x = (GLint) VB->Win[i][0]; - y = FLIP( (GLint) VB->Win[i][1] ); + x = (GLint) VB->Win.data[i][0]; + y = FLIP( (GLint) VB->Win.data[i][1] ); WriteRGBAPixel( x, y, VB->ColorPtr->data[i] ); } } @@ -332,10 +349,10 @@ static void fast_line_function( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv pixel = VB->ColorPtr->data[pv]; - x0 = (int) VB->Win[v0][0]; - y0 = FLIP( (int) VB->Win[v0][1] ); - x1 = (int) VB->Win[v1][0]; - y1 = FLIP( (int) VB->Win[v1][1] ); + x0 = (int) VB->Win.data[v0][0]; + y0 = FLIP( (int) VB->Win.data[v0][1] ); + x1 = (int) VB->Win.data[v1][0]; + y1 = FLIP( (int) VB->Win.data[v1][1] ); /* Draw line from (x0,y0) to (x1,y1) with current pixel color/index */ } @@ -615,7 +632,8 @@ static void setup_DD_pointers( GLcontext *ctx ) ctx->Driver.Index = set_index; ctx->Driver.Color = set_color; - ctx->Driver.SetBuffer = set_buffer; + ctx->Driver.SetDrawBuffer = set_draw_buffer; + ctx->Driver.SetReadBuffer = set_read_buffer; ctx->Driver.GetBufferSize = get_buffer_size; ctx->Driver.PointsFunc = fast_points_function; @@ -730,7 +748,11 @@ FooMesaBuffer FooMesaCreateBuffer( FooMesaVisual visual, return NULL; } - b->gl_buffer = gl_create_framebuffer( visual->gl_visual ); + b->gl_buffer = gl_create_framebuffer( visual->gl_visual, + visual->gl_visual->DepthBits > 0, + visual->gl_visual->StencilBits > 0, + visual->gl_visual->AccumBits > 0, + visual->gl_visual->AlphaBits > 0 ); b->the_window = your_window_id; /* other stuff */ @@ -769,7 +791,7 @@ FooMesaContext FooMesaCreateContext( FooMesaVisual visual, /* and then, finally let the context examine your initializations */ - gl_context_initialize( c->gl_ctx ); + _mesa_initialize_context( c->gl_ctx ); return c; diff --git a/xc/extras/Mesa/src/dlist.c b/xc/extras/Mesa/src/dlist.c index d491db47c..f9fc902f2 100644 --- a/xc/extras/Mesa/src/dlist.c +++ b/xc/extras/Mesa/src/dlist.c @@ -1,3 +1,4 @@ +/* $Id: dlist.c,v 1.10.12.1 2000/06/13 15:33:05 dfr Exp $ */ /* * Mesa 3-D graphics library @@ -58,6 +59,7 @@ #include "mem.h" #include "pipeline.h" #include "pixel.h" +#include "pixeltex.h" #include "points.h" #include "polygon.h" #include "readpix.h" @@ -140,7 +142,17 @@ typedef enum { OPCODE_COLOR_MASK, OPCODE_COLOR_MATERIAL, OPCODE_COLOR_TABLE, + OPCODE_COLOR_TABLE_PARAMETER_FV, + OPCODE_COLOR_TABLE_PARAMETER_IV, OPCODE_COLOR_SUB_TABLE, + OPCODE_CONVOLUTION_FILTER_1D, + OPCODE_CONVOLUTION_FILTER_2D, + OPCODE_CONVOLUTION_PARAMETER_I, + OPCODE_CONVOLUTION_PARAMETER_IV, + OPCODE_CONVOLUTION_PARAMETER_F, + OPCODE_CONVOLUTION_PARAMETER_FV, + OPCODE_COPY_COLOR_SUB_TABLE, + OPCODE_COPY_COLOR_TABLE, OPCODE_COPY_PIXELS, OPCODE_COPY_TEX_IMAGE1D, OPCODE_COPY_TEX_IMAGE2D, @@ -166,6 +178,7 @@ typedef enum { OPCODE_FRUSTUM, OPCODE_HINT, OPCODE_HINT_PGI, + OPCODE_HISTOGRAM, OPCODE_INDEX_MASK, OPCODE_INIT_NAMES, OPCODE_LIGHT, @@ -182,6 +195,7 @@ typedef enum { OPCODE_MAPGRID1, OPCODE_MAPGRID2, OPCODE_MATRIX_MODE, + OPCODE_MIN_MAX, OPCODE_MULT_MATRIX, OPCODE_ORTHO, OPCODE_PASSTHROUGH, @@ -203,6 +217,8 @@ typedef enum { OPCODE_RASTER_POS, OPCODE_RECTF, OPCODE_READ_BUFFER, + OPCODE_RESET_HISTOGRAM, + OPCODE_RESET_MIN_MAX, OPCODE_SCALE, OPCODE_SCISSOR, OPCODE_SELECT_TEXTURE_SGIS, @@ -226,6 +242,16 @@ typedef enum { /* GL_ARB_multitexture */ OPCODE_ACTIVE_TEXTURE, OPCODE_CLIENT_ACTIVE_TEXTURE, + /* GL_SGIX/SGIS_pixel_texture */ + OPCODE_PIXEL_TEXGEN_SGIX, + OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, + /* GL_ARB_texture_compression */ + OPCODE_COMPRESSED_TEX_IMAGE_1D, + OPCODE_COMPRESSED_TEX_IMAGE_2D, + OPCODE_COMPRESSED_TEX_IMAGE_3D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, + OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, /* The following three are meta instructions */ OPCODE_ERROR, /* raise compiled-in error */ OPCODE_VERTEX_CASSETTE, /* render prebuilt vertex buffer */ @@ -365,6 +391,14 @@ void gl_destroy_list( GLcontext *ctx, GLuint list ) FREE( n[6].data ); n += InstSize[n[0].opcode]; break; + case OPCODE_CONVOLUTION_FILTER_1D: + FREE( n[6].data ); + n += InstSize[n[0].opcode]; + break; + case OPCODE_CONVOLUTION_FILTER_2D: + FREE( n[7].data ); + n += InstSize[n[0].opcode]; + break; case OPCODE_POLYGON_STIPPLE: FREE( n[1].data ); n += InstSize[n[0].opcode]; @@ -393,6 +427,30 @@ void gl_destroy_list( GLcontext *ctx, GLuint list ) FREE(n[11].data); n += InstSize[n[0].opcode]; break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: + FREE(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: + FREE(n[8].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: + FREE(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: + FREE(n[7].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: + FREE(n[9].data); + n += InstSize[n[0].opcode]; + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: + FREE(n[11].data); + n += InstSize[n[0].opcode]; + break; case OPCODE_CONTINUE: n = (Node *) n[1].next; FREE( block ); @@ -500,8 +558,18 @@ void gl_init_lists( void ) InstSize[OPCODE_COLOR_MASK] = 5; InstSize[OPCODE_COLOR_MATERIAL] = 3; InstSize[OPCODE_COLOR_TABLE] = 7; + InstSize[OPCODE_COLOR_TABLE_PARAMETER_FV] = 7; + InstSize[OPCODE_COLOR_TABLE_PARAMETER_IV] = 7; InstSize[OPCODE_COLOR_SUB_TABLE] = 7; + InstSize[OPCODE_CONVOLUTION_FILTER_1D] = 7; + InstSize[OPCODE_CONVOLUTION_FILTER_2D] = 8; + InstSize[OPCODE_CONVOLUTION_PARAMETER_I] = 4; + InstSize[OPCODE_CONVOLUTION_PARAMETER_IV] = 7; + InstSize[OPCODE_CONVOLUTION_PARAMETER_F] = 4; + InstSize[OPCODE_CONVOLUTION_PARAMETER_FV] = 7; InstSize[OPCODE_COPY_PIXELS] = 6; + InstSize[OPCODE_COPY_COLOR_SUB_TABLE] = 6; + InstSize[OPCODE_COPY_COLOR_TABLE] = 6; InstSize[OPCODE_COPY_TEX_IMAGE1D] = 8; InstSize[OPCODE_COPY_TEX_IMAGE2D] = 9; InstSize[OPCODE_COPY_TEX_SUB_IMAGE1D] = 7; @@ -526,6 +594,7 @@ void gl_init_lists( void ) InstSize[OPCODE_FRUSTUM] = 7; InstSize[OPCODE_HINT] = 3; InstSize[OPCODE_HINT_PGI] = 3; + InstSize[OPCODE_HISTOGRAM] = 5; InstSize[OPCODE_INDEX_MASK] = 2; InstSize[OPCODE_INIT_NAMES] = 1; InstSize[OPCODE_LIGHT] = 7; @@ -542,6 +611,7 @@ void gl_init_lists( void ) InstSize[OPCODE_MAPGRID1] = 4; InstSize[OPCODE_MAPGRID2] = 7; InstSize[OPCODE_MATRIX_MODE] = 2; + InstSize[OPCODE_MIN_MAX] = 4; InstSize[OPCODE_MULT_MATRIX] = 17; InstSize[OPCODE_ORTHO] = 7; InstSize[OPCODE_PASSTHROUGH] = 2; @@ -563,6 +633,8 @@ void gl_init_lists( void ) InstSize[OPCODE_RASTER_POS] = 5; InstSize[OPCODE_RECTF] = 5; InstSize[OPCODE_READ_BUFFER] = 2; + InstSize[OPCODE_RESET_HISTOGRAM] = 2; + InstSize[OPCODE_RESET_MIN_MAX] = 2; InstSize[OPCODE_SCALE] = 4; InstSize[OPCODE_SCISSOR] = 5; InstSize[OPCODE_STENCIL_FUNC] = 4; @@ -585,6 +657,16 @@ void gl_init_lists( void ) InstSize[OPCODE_ERROR] = 3; InstSize[OPCODE_VERTEX_CASSETTE] = 9; InstSize[OPCODE_END_OF_LIST] = 1; + /* GL_SGIX/SGIS_pixel_texture */ + InstSize[OPCODE_PIXEL_TEXGEN_SGIX] = 2; + InstSize[OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS] = 3; + /* GL_ARB_texture_compression */ + InstSize[OPCODE_COMPRESSED_TEX_IMAGE_1D] = 8; + InstSize[OPCODE_COMPRESSED_TEX_IMAGE_2D] = 9; + InstSize[OPCODE_COMPRESSED_TEX_IMAGE_3D] = 10; + InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D] = 8; + InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D] = 10; + InstSize[OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D] = 12; /* GL_ARB_multitexture */ InstSize[OPCODE_ACTIVE_TEXTURE] = 2; InstSize[OPCODE_CLIENT_ACTIVE_TEXTURE] = 2; @@ -976,6 +1058,66 @@ static void save_ColorTable( GLenum target, GLenum internalFormat, } + +static void +save_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv"); + FLUSH_VB(ctx, "dlist"); + + n = alloc_instruction( ctx, OPCODE_COLOR_TABLE_PARAMETER_FV, 6 ); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + } + + if (ctx->ExecuteFlag) { + (*ctx->Exec->ColorTableParameterfv)( target, pname, params ); + } +} + + +static void +save_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + ASSERT_OUTSIDE_BEGIN_END(ctx, "glColorTableParameterfv"); + FLUSH_VB(ctx, "dlist"); + + n = alloc_instruction( ctx, OPCODE_COLOR_TABLE_PARAMETER_IV, 6 ); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_COLOR_TABLE_SGI || + pname == GL_POST_CONVOLUTION_COLOR_TABLE_SGI || + pname == GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + } + + if (ctx->ExecuteFlag) { + (*ctx->Exec->ColorTableParameteriv)( target, pname, params ); + } +} + + + static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *table) @@ -1003,6 +1145,199 @@ static void save_ColorSubTable( GLenum target, GLsizei start, GLsizei count, } +static void +save_CopyColorSubTable(GLenum target, GLsizei start, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 6 ); + if (n) { + n[1].e = target; + n[2].i = start; + n[3].i = x; + n[4].i = y; + n[5].i = width; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->CopyColorSubTable)(target, start, x, y, width); + } +} + + +static void +save_CopyColorTable(GLenum target, GLenum internalformat, + GLint x, GLint y, GLsizei width) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_COPY_COLOR_TABLE, 6 ); + if (n) { + n[1].e = target; + n[2].e = internalformat; + n[3].i = x; + n[4].i = y; + n[5].i = width; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->CopyColorTable)(target, internalformat, x, y, width); + } +} + + +static void +save_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, + GLenum format, GLenum type, const GLvoid *filter) +{ + GET_CURRENT_CONTEXT(ctx); + GLvoid *image = _mesa_unpack_image(width, 1, 1, format, type, filter, + &ctx->Unpack); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_CONVOLUTION_FILTER_1D, 6 ); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].e = format; + n[5].e = type; + n[6].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ConvolutionFilter1D)( target, internalFormat, width, + format, type, filter ); + } +} + + +static void +save_ConvolutionFilter2D(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height, GLenum format, + GLenum type, const GLvoid *filter) +{ + GET_CURRENT_CONTEXT(ctx); + GLvoid *image = _mesa_unpack_image(width, height, 1, format, type, filter, + &ctx->Unpack); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_CONVOLUTION_FILTER_2D, 7 ); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].i = width; + n[4].i = height; + n[5].e = format; + n[6].e = type; + n[7].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ConvolutionFilter2D)( target, internalFormat, width, height, + format, type, filter ); + } +} + + +static void +save_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_I, 3 ); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = param; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ConvolutionParameteri)( target, pname, param ); + } +} + + +static void +save_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 ); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].i = params[0]; + if (pname == GL_CONVOLUTION_BORDER_COLOR || + pname == GL_CONVOLUTION_FILTER_SCALE || + pname == GL_CONVOLUTION_FILTER_BIAS) { + n[4].i = params[1]; + n[5].i = params[2]; + n[6].i = params[3]; + } + else { + n[4].i = n[5].i = n[6].i = 0; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ConvolutionParameteriv)( target, pname, params ); + } +} + + +static void +save_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_F, 3 ); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = param; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ConvolutionParameterf)( target, pname, param ); + } +} + + +static void +save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 ); + if (n) { + n[1].e = target; + n[2].e = pname; + n[3].f = params[0]; + if (pname == GL_CONVOLUTION_BORDER_COLOR || + pname == GL_CONVOLUTION_FILTER_SCALE || + pname == GL_CONVOLUTION_FILTER_BIAS) { + n[4].f = params[1]; + n[5].f = params[2]; + n[6].f = params[3]; + } + else { + n[4].f = n[5].f = n[6].f = 0.0F; + } + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ConvolutionParameterfv)( target, pname, params ); + } +} + static void save_CopyPixels( GLint x, GLint y, GLsizei width, GLsizei height, GLenum type ) @@ -1455,6 +1790,26 @@ static void save_HintPGI( GLenum target, GLint mode ) } +static void +save_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_HISTOGRAM, 4 ); + if (n) { + n[1].e = target; + n[2].i = width; + n[3].e = internalFormat; + n[4].b = sink; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->Histogram)( target, width, internalFormat, sink ); + } +} + + static void save_IndexMask( GLuint mask ) { GET_CURRENT_CONTEXT(ctx); @@ -1928,6 +2283,25 @@ static void save_MatrixMode( GLenum mode ) } +static void +save_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_MIN_MAX, 3 ); + if (n) { + n[1].e = target; + n[2].e = internalFormat; + n[3].b = sink; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->Minmax)( target, internalFormat, sink ); + } +} + + static void save_MultMatrixf( const GLfloat *m ) { GET_CURRENT_CONTEXT(ctx); @@ -2176,7 +2550,8 @@ static void save_PolygonOffset( GLfloat factor, GLfloat units ) static void save_PolygonOffsetEXT( GLfloat factor, GLfloat bias ) { - save_PolygonOffset(factor, DEPTH_SCALE * bias); + GET_CURRENT_CONTEXT(ctx); + save_PolygonOffset(factor, ctx->Visual->DepthMaxF * bias); } @@ -2491,6 +2866,38 @@ static void save_Rectsv(const GLshort *v1, const GLshort *v2) } +static void +save_ResetHistogram(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_RESET_HISTOGRAM, 1 ); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ResetHistogram)( target ); + } +} + + +static void +save_ResetMinmax(GLenum target) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_RESET_MIN_MAX, 1 ); + if (n) { + n[1].e = target; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->ResetMinmax)( target ); + } +} + + static void save_Rotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) { GLfloat m[16]; @@ -2842,7 +3249,7 @@ static void save_TexImage2D( GLenum target, static void save_TexImage3D( GLenum target, - GLint level, GLint components, + GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, @@ -2851,7 +3258,7 @@ static void save_TexImage3D( GLenum target, GET_CURRENT_CONTEXT(ctx); if (target == GL_PROXY_TEXTURE_3D) { /* don't compile, execute immediately */ - (*ctx->Exec->TexImage3D)( target, level, components, width, + (*ctx->Exec->TexImage3D)( target, level, internalFormat, width, height, depth, border, format, type, pixels ); } else { @@ -2863,7 +3270,7 @@ static void save_TexImage3D( GLenum target, if (n) { n[1].e = target; n[2].i = level; - n[3].i = components; + n[3].i = internalFormat; n[4].i = (GLint) width; n[5].i = (GLint) height; n[6].i = (GLint) depth; @@ -2876,7 +3283,7 @@ static void save_TexImage3D( GLenum target, FREE(image); } if (ctx->ExecuteFlag) { - (*ctx->Exec->TexImage3D)( target, level, components, width, + (*ctx->Exec->TexImage3D)( target, level, internalFormat, width, height, depth, border, format, type, pixels ); } } @@ -3190,6 +3597,8 @@ static void save_ClientActiveTextureARB( GLenum target ) +/* GL_ARB_transpose_matrix */ + static void save_LoadTransposeMatrixdARB( const GLdouble m[16] ) { GLdouble tm[16]; @@ -3222,6 +3631,313 @@ static void save_MultTransposeMatrixfARB( const GLfloat m[16] ) } +static void save_PixelTexGenSGIX(GLenum mode) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_PIXEL_TEXGEN_SGIX, 1 ); + if (n) { + n[1].e = mode; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->PixelTexGenSGIX)( mode ); + } +} + + +/* GL_ARB_texture_compression */ +static void +save_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_1D) { + /* don't compile, execute immediately */ + (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat, + width, border, imageSize, data); + } + else { + Node *n; + GLvoid *image; + FLUSH_VB(ctx, "dlist"); + /* make copy of image */ + image = MALLOC(imageSize); + if (!image) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); + return; + } + MEMCPY(image, data, imageSize); + n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 8 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = border; + n[6].i = imageSize; + n[7].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->CompressedTexImage1DARB)(target, level, internalFormat, + width, border, imageSize, data); + } + } +} + + +static void +save_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_2D) { + /* don't compile, execute immediately */ + (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat, + width, height, border, imageSize, data); + } + else { + Node *n; + GLvoid *image; + FLUSH_VB(ctx, "dlist"); + /* make copy of image */ + image = MALLOC(imageSize); + if (!image) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); + return; + } + MEMCPY(image, data, imageSize); + n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 9 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = border; + n[7].i = imageSize; + n[8].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->CompressedTexImage2DARB)(target, level, internalFormat, + width, height, border, imageSize, data); + } + } +} + + +static void +save_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + if (target == GL_PROXY_TEXTURE_3D) { + /* don't compile, execute immediately */ + (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat, + width, height, depth, border, imageSize, data); + } + else { + Node *n; + GLvoid *image; + FLUSH_VB(ctx, "dlist"); + /* make copy of image */ + image = MALLOC(imageSize); + if (!image) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); + return; + } + MEMCPY(image, data, imageSize); + n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 10 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].e = internalFormat; + n[4].i = (GLint) width; + n[5].i = (GLint) height; + n[6].i = (GLint) depth; + n[7].i = border; + n[8].i = imageSize; + n[9].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->CompressedTexImage3DARB)(target, level, internalFormat, + width, height, depth, border, imageSize, data); + } + } +} + + +static void +save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + FLUSH_VB(ctx, "dlist"); + + /* make copy of image */ + image = MALLOC(imageSize); + if (!image) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage1DARB"); + return; + } + MEMCPY(image, data, imageSize); + n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 8 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = (GLint) width; + n[5].e = format; + n[6].i = imageSize; + n[7].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->CompressedTexSubImage1DARB)(target, level, xoffset, + width, format, imageSize, data); + } +} + + +static void +save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid *data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + FLUSH_VB(ctx, "dlist"); + + /* make copy of image */ + image = MALLOC(imageSize); + if (!image) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage2DARB"); + return; + } + MEMCPY(image, data, imageSize); + n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 10 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = (GLint) width; + n[6].i = (GLint) height; + n[7].e = format; + n[8].i = imageSize; + n[9].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->CompressedTexSubImage2DARB)(target, level, xoffset, yoffset, + width, height, format, imageSize, data); + } +} + + +static void +save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + Node *n; + GLvoid *image; + + GET_CURRENT_CONTEXT(ctx); + FLUSH_VB(ctx, "dlist"); + + /* make copy of image */ + image = MALLOC(imageSize); + if (!image) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage3DARB"); + return; + } + MEMCPY(image, data, imageSize); + n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 12 ); + if (n) { + n[1].e = target; + n[2].i = level; + n[3].i = xoffset; + n[4].i = yoffset; + n[5].i = zoffset; + n[6].i = (GLint) width; + n[7].i = (GLint) height; + n[8].i = (GLint) depth; + n[9].e = format; + n[10].i = imageSize; + n[11].data = image; + } + else if (image) { + FREE(image); + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->CompressedTexSubImage3DARB)(target, level, xoffset, yoffset, + zoffset, width, height, depth, format, imageSize, data); + } +} + + +/* GL_SGIS_pixel_texture */ + +static void save_PixelTexGenParameteriSGIS(GLenum target, GLint value) +{ + GET_CURRENT_CONTEXT(ctx); + Node *n; + FLUSH_VB(ctx, "dlist"); + n = alloc_instruction( ctx, OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS, 2 ); + if (n) { + n[1].e = target; + n[2].i = value; + } + if (ctx->ExecuteFlag) { + (*ctx->Exec->PixelTexGenParameteriSGIS)( target, value ); + } +} + + +static void save_PixelTexGenParameterfSGIS(GLenum target, GLfloat value) +{ + save_PixelTexGenParameteriSGIS(target, (GLint) value); +} + + +static void save_PixelTexGenParameterivSGIS(GLenum target, const GLint *value) +{ + save_PixelTexGenParameteriSGIS(target, *value); +} + + +static void save_PixelTexGenParameterfvSGIS(GLenum target, const GLfloat *value) +{ + save_PixelTexGenParameteriSGIS(target, (GLint) *value); +} void gl_compile_cassette( GLcontext *ctx ) { @@ -3364,10 +4080,12 @@ static void execute_list( GLcontext *ctx, GLuint list ) (MESA_VERBOSE & VERBOSE_IMMEDIATE)) gl_print_cassette( (struct immediate *) n[1].data ); - if (0) - fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x\n", + if (MESA_VERBOSE & VERBOSE_DISPLAY_LIST) { + fprintf(stderr, "Run cassette %d, rows %d..%d, beginstate %x ", IM->id, IM->Start, IM->Count, IM->BeginState); + gl_print_vert_flags("orflag", IM->OrFlag); + } gl_fixup_cassette( ctx, (struct immediate *) n[1].data ); gl_execute_cassette( ctx, (struct immediate *) n[1].data ); @@ -3387,7 +4105,7 @@ static void execute_list( GLcontext *ctx, GLuint list ) struct gl_pixelstore_attrib save = ctx->Unpack; ctx->Unpack = _mesa_native_packing; (*ctx->Exec->Bitmap)( (GLsizei) n[1].i, (GLsizei) n[2].i, - n[3].f, n[4].f, n[5].f, n[6].f, n[7].data ); + n[3].f, n[4].f, n[5].f, n[6].f, (const GLubyte *) n[7].data ); ctx->Unpack = save; /* restore */ } break; @@ -3458,6 +4176,26 @@ static void execute_list( GLcontext *ctx, GLuint list ) ctx->Unpack = save; /* restore */ } break; + case OPCODE_COLOR_TABLE_PARAMETER_FV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + (*ctx->Exec->ColorTableParameterfv)( n[1].e, n[2].e, params ); + } + break; + case OPCODE_COLOR_TABLE_PARAMETER_IV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + (*ctx->Exec->ColorTableParameteriv)( n[1].e, n[2].e, params ); + } + break; case OPCODE_COLOR_SUB_TABLE: { struct gl_pixelstore_attrib save = ctx->Unpack; @@ -3467,6 +4205,58 @@ static void execute_list( GLcontext *ctx, GLuint list ) ctx->Unpack = save; /* restore */ } break; + case OPCODE_CONVOLUTION_FILTER_1D: + { + struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec->ConvolutionFilter1D)( n[1].e, n[2].i, n[3].i, + n[4].e, n[5].e, n[6].data ); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_FILTER_2D: + { + struct gl_pixelstore_attrib save = ctx->Unpack; + ctx->Unpack = _mesa_native_packing; + (*ctx->Exec->ConvolutionFilter2D)( n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, n[6].e, n[7].data ); + ctx->Unpack = save; /* restore */ + } + break; + case OPCODE_CONVOLUTION_PARAMETER_I: + (*ctx->Exec->ConvolutionParameteri)( n[1].e, n[2].e, n[3].i ); + break; + case OPCODE_CONVOLUTION_PARAMETER_IV: + { + GLint params[4]; + params[0] = n[3].i; + params[1] = n[4].i; + params[2] = n[5].i; + params[3] = n[6].i; + (*ctx->Exec->ConvolutionParameteriv)( n[1].e, n[2].e, params ); + } + break; + case OPCODE_CONVOLUTION_PARAMETER_F: + (*ctx->Exec->ConvolutionParameterf)( n[1].e, n[2].e, n[3].f ); + break; + case OPCODE_CONVOLUTION_PARAMETER_FV: + { + GLfloat params[4]; + params[0] = n[3].f; + params[1] = n[4].f; + params[2] = n[5].f; + params[3] = n[6].f; + (*ctx->Exec->ConvolutionParameterfv)( n[1].e, n[2].e, params ); + } + break; + case OPCODE_COPY_COLOR_SUB_TABLE: + (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i, + n[3].i, n[4].i, n[5].i ); + break; + case OPCODE_COPY_COLOR_TABLE: + (*ctx->Exec->CopyColorSubTable)( n[1].e, n[2].i, + n[3].i, n[4].i, n[5].i ); + break; case OPCODE_COPY_PIXELS: (*ctx->Exec->CopyPixels)( n[1].i, n[2].i, (GLsizei) n[3].i, (GLsizei) n[4].i, n[5].e ); @@ -3549,6 +4339,9 @@ static void execute_list( GLcontext *ctx, GLuint list ) case OPCODE_HINT_PGI: (*ctx->Exec->HintPGI)( n[1].e, n[2].i ); break; + case OPCODE_HISTOGRAM: + (*ctx->Exec->Histogram)( n[1].e, n[2].i, n[3].e, n[4].b ); + break; case OPCODE_INDEX_MASK: (*ctx->Exec->IndexMask)( n[1].ui ); break; @@ -3642,6 +4435,9 @@ static void execute_list( GLcontext *ctx, GLuint list ) case OPCODE_MATRIX_MODE: (*ctx->Exec->MatrixMode)( n[1].e ); break; + case OPCODE_MIN_MAX: + (*ctx->Exec->Minmax)(n[1].e, n[2].e, n[3].b); + break; case OPCODE_MULT_MATRIX: if (sizeof(Node)==sizeof(GLfloat)) { (*ctx->Exec->MultMatrixf)( &n[1].f ); @@ -3721,6 +4517,12 @@ static void execute_list( GLcontext *ctx, GLuint list ) case OPCODE_RECTF: (*ctx->Exec->Rectf)( n[1].f, n[2].f, n[3].f, n[4].f ); break; + case OPCODE_RESET_HISTOGRAM: + (*ctx->Exec->ResetHistogram)( n[1].e ); + break; + case OPCODE_RESET_MIN_MAX: + (*ctx->Exec->ResetMinmax)( n[1].e ); + break; case OPCODE_SCALE: (*ctx->Exec->Scalef)( n[1].f, n[2].f, n[3].f ); break; @@ -3867,6 +4669,37 @@ static void execute_list( GLcontext *ctx, GLuint list ) case OPCODE_CLIENT_ACTIVE_TEXTURE: /* GL_ARB_multitexture */ (*ctx->Exec->ClientActiveTextureARB)( n[1].e ); break; + case OPCODE_PIXEL_TEXGEN_SGIX: /* GL_SGIX_pixel_texture */ + (*ctx->Exec->PixelTexGenSGIX)( n[1].e ); + break; + case OPCODE_PIXEL_TEXGEN_PARAMETER_SGIS: /* GL_SGIS_pixel_texture */ + (*ctx->Exec->PixelTexGenParameteriSGIS)( n[1].e, n[2].i ); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_1D: /* GL_ARB_texture_compression */ + (*ctx->Exec->CompressedTexImage1DARB)(n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, n[7].data); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_2D: /* GL_ARB_texture_compression */ + (*ctx->Exec->CompressedTexImage2DARB)(n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, n[7].i, n[8].data); + break; + case OPCODE_COMPRESSED_TEX_IMAGE_3D: /* GL_ARB_texture_compression */ + (*ctx->Exec->CompressedTexImage3DARB)(n[1].e, n[2].i, n[3].e, + n[4].i, n[5].i, n[6].i, n[7].i, n[8].i, n[9].data); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D: /* GL_ARB_texture_compress */ + (*ctx->Exec->CompressedTexSubImage1DARB)(n[1].e, n[2].i, n[3].i, + n[4].i, n[5].e, n[6].i, n[7].data); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D: /* GL_ARB_texture_compress */ + (*ctx->Exec->CompressedTexSubImage2DARB)(n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].e, n[8].i, n[9].data); + break; + case OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D: /* GL_ARB_texture_compress */ + (*ctx->Exec->CompressedTexSubImage3DARB)(n[1].e, n[2].i, n[3].i, + n[4].i, n[5].i, n[6].i, n[7].i, n[8].i, + n[9].e, n[10].i, n[11].data); + break; case OPCODE_CONTINUE: n = (Node *) n[1].next; break; @@ -3953,6 +4786,11 @@ _mesa_GenLists(GLsizei range ) return 0; } + /* + * Make this an atomic operation + */ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + base = _mesa_HashFindFreeKeyBlock(ctx->Shared->DisplayList, range); if (base) { /* reserve the list IDs by with empty/dummy lists */ @@ -3961,6 +4799,9 @@ _mesa_GenLists(GLsizei range ) _mesa_HashInsert(ctx->Shared->DisplayList, base+i, make_empty_list()); } } + + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + return base; } @@ -4149,13 +4990,13 @@ _mesa_ListBase( GLuint base ) /* - * Assign all the pointers in 'table' to point to Mesa's display list + * Assign all the pointers in <table> to point to Mesa's display list * building functions. */ void -_mesa_init_dlist_table( struct _glapi_table *table ) +_mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize ) { - _mesa_init_no_op_table(table); + _mesa_init_no_op_table(table, tableSize); /* GL 1.0 */ table->Accum = save_Accum; @@ -4507,18 +5348,18 @@ _mesa_init_dlist_table( struct _glapi_table *table ) /* Not all are supported */ table->BlendColor = save_BlendColor; table->BlendEquation = save_BlendEquation; - table->ColorSubTable = _mesa_ColorSubTable; - table->ColorTable = _mesa_ColorTable; - table->ColorTableParameterfv = _mesa_ColorTableParameterfv; - table->ColorTableParameteriv = _mesa_ColorTableParameteriv; - table->ConvolutionFilter1D = _mesa_ConvolutionFilter1D; - table->ConvolutionFilter2D = _mesa_ConvolutionFilter2D; - table->ConvolutionParameterf = _mesa_ConvolutionParameterf; - table->ConvolutionParameterfv = _mesa_ConvolutionParameterfv; - table->ConvolutionParameteri = _mesa_ConvolutionParameteri; - table->ConvolutionParameteriv = _mesa_ConvolutionParameteriv; - table->CopyColorSubTable = _mesa_CopyColorSubTable; - table->CopyColorTable = _mesa_CopyColorTable; + table->ColorSubTable = save_ColorSubTable; + table->ColorTable = save_ColorTable; + table->ColorTableParameterfv = save_ColorTableParameterfv; + table->ColorTableParameteriv = save_ColorTableParameteriv; + table->ConvolutionFilter1D = save_ConvolutionFilter1D; + table->ConvolutionFilter2D = save_ConvolutionFilter2D; + table->ConvolutionParameterf = save_ConvolutionParameterf; + table->ConvolutionParameterfv = save_ConvolutionParameterfv; + table->ConvolutionParameteri = save_ConvolutionParameteri; + table->ConvolutionParameteriv = save_ConvolutionParameteriv; + table->CopyColorSubTable = save_CopyColorSubTable; + table->CopyColorTable = save_CopyColorTable; table->CopyConvolutionFilter1D = _mesa_CopyConvolutionFilter1D; table->CopyConvolutionFilter2D = _mesa_CopyConvolutionFilter2D; table->GetColorTable = _mesa_GetColorTable; @@ -4534,10 +5375,10 @@ _mesa_init_dlist_table( struct _glapi_table *table ) table->GetMinmaxParameterfv = _mesa_GetMinmaxParameterfv; table->GetMinmaxParameteriv = _mesa_GetMinmaxParameteriv; table->GetSeparableFilter = _mesa_GetSeparableFilter; - table->Histogram = _mesa_Histogram; - table->Minmax = _mesa_Minmax; - table->ResetHistogram = _mesa_ResetHistogram; - table->ResetMinmax = _mesa_ResetMinmax; + table->Histogram = save_Histogram; + table->Minmax = save_Minmax; + table->ResetHistogram = save_ResetHistogram; + table->ResetMinmax = save_ResetMinmax; table->SeparableFilter2D = _mesa_SeparableFilter2D; /* GL_EXT_texture3d */ @@ -4556,6 +5397,17 @@ _mesa_init_dlist_table( struct _glapi_table *table ) table->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; table->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; + /* 15. GL_SGIX_pixel_texture */ + table->PixelTexGenSGIX = save_PixelTexGenSGIX; + + /* 15. GL_SGIS_pixel_texture */ + table->PixelTexGenParameteriSGIS = save_PixelTexGenParameteriSGIS; + table->PixelTexGenParameterfSGIS = save_PixelTexGenParameterfSGIS; + table->PixelTexGenParameterivSGIS = save_PixelTexGenParameterivSGIS; + table->PixelTexGenParameterfvSGIS = save_PixelTexGenParameterfvSGIS; + table->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS; + table->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS; + /* GL_EXT_compiled_vertex_array */ table->LockArraysEXT = _mesa_LockArraysEXT; table->UnlockArraysEXT = _mesa_UnlockArraysEXT; @@ -4654,6 +5506,14 @@ _mesa_init_dlist_table( struct _glapi_table *table ) table->MultTransposeMatrixdARB = save_MultTransposeMatrixdARB; table->MultTransposeMatrixfARB = save_MultTransposeMatrixfARB; + /* ARB 12. GL_ARB_texture_compression */ + table->CompressedTexImage3DARB = save_CompressedTexImage3DARB; + table->CompressedTexImage2DARB = save_CompressedTexImage2DARB; + table->CompressedTexImage1DARB = save_CompressedTexImage1DARB; + table->CompressedTexSubImage3DARB = save_CompressedTexSubImage3DARB; + table->CompressedTexSubImage2DARB = save_CompressedTexSubImage2DARB; + table->CompressedTexSubImage1DARB = save_CompressedTexSubImage1DARB; + table->GetCompressedTexImageARB = _mesa_GetCompressedTexImageARB; } @@ -4705,6 +5565,16 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list ) fprintf(f,"CallList %d + offset %u = %u\n", (int) n[1].ui, ctx->List.ListBase, ctx->List.ListBase + n[1].ui ); break; + case OPCODE_COLOR_TABLE_PARAMETER_FV: + fprintf(f,"ColorTableParameterfv %s %s %f %f %f %f\n", + enum_string(n[1].e), enum_string(n[2].e), + n[3].f, n[4].f, n[5].f, n[6].f); + break; + case OPCODE_COLOR_TABLE_PARAMETER_IV: + fprintf(f,"ColorTableParameteriv %s %s %d %d %d %d\n", + enum_string(n[1].e), enum_string(n[2].e), + n[3].i, n[4].i, n[5].i, n[6].i); + break; case OPCODE_DISABLE: fprintf(f,"Disable %s\n", enum_string(n[1].e)); break; @@ -4788,6 +5658,7 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list ) ((struct immediate *) n[1].data)->id, n[2].ui, n[3].ui); + gl_print_cassette( (struct immediate *) n[1].data ); break; case OPCODE_CONTINUE: fprintf(f,"DISPLAY-LIST-CONTINUE\n"); diff --git a/xc/extras/Mesa/src/dlist.h b/xc/extras/Mesa/src/dlist.h index a5233e50c..b2aaa64c7 100644 --- a/xc/extras/Mesa/src/dlist.h +++ b/xc/extras/Mesa/src/dlist.h @@ -1,9 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -24,15 +24,13 @@ */ - - - #ifndef DLIST_H #define DLIST_H #include "types.h" + struct display_list { union node *nodes; GLuint OrFlag; @@ -66,8 +64,7 @@ extern void _mesa_ListBase( GLuint base ); extern void _mesa_NewList( GLuint list, GLenum mode ); -extern void _mesa_init_dlist_table( struct _glapi_table *table ); - +extern void _mesa_init_dlist_table( struct _glapi_table *table, GLuint tableSize ); extern void gl_compile_cassette( GLcontext *ctx ); diff --git a/xc/extras/Mesa/src/drawpix.c b/xc/extras/Mesa/src/drawpix.c index f89d80a70..7fb93abcc 100644 --- a/xc/extras/Mesa/src/drawpix.c +++ b/xc/extras/Mesa/src/drawpix.c @@ -33,11 +33,14 @@ #include "feedback.h" #include "image.h" #include "macros.h" +#include "mem.h" #include "mmath.h" #include "pixel.h" +#include "pixeltex.h" #include "span.h" #include "state.h" #include "stencil.h" +#include "texture.h" #include "types.h" #include "zoom.h" #endif @@ -112,24 +115,17 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, return GL_TRUE; } - if (ctx->NewState) { - gl_update_state(ctx); - } - - /* see if device driver can do the drawpix */ - if (ctx->Driver.DrawPixels - && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type, - unpack, pixels)) { - return GL_TRUE; - } - if ((ctx->RasterMask&(~(SCISSOR_BIT|WINCLIP_BIT)))==0 - && ctx->Pixel.RedBias==0.0 && ctx->Pixel.RedScale==1.0 - && ctx->Pixel.GreenBias==0.0 && ctx->Pixel.GreenScale==1.0 - && ctx->Pixel.BlueBias==0.0 && ctx->Pixel.BlueScale==1.0 - && ctx->Pixel.AlphaBias==0.0 && ctx->Pixel.AlphaScale==1.0 + && !ctx->Pixel.ScaleOrBiasRGBA + && !ctx->Pixel.ScaleOrBiasRGBApcm + && ctx->ColorMatrix.type == MATRIX_IDENTITY + && !ctx->Pixel.ColorTableEnabled + && !ctx->Pixel.PostColorMatrixColorTableEnabled + && !ctx->Pixel.MinMaxEnabled + && !ctx->Pixel.HistogramEnabled && ctx->Pixel.IndexShift==0 && ctx->Pixel.IndexOffset==0 && ctx->Pixel.MapColorFlag==0 + && ctx->Texture.ReallyEnabled == 0 && unpack->Alignment==1 && !unpack->SwapBytes && !unpack->LsbFirst) { @@ -180,7 +176,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, } else { /* setup array of fragment Z value to pass to zoom function */ - GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF); GLint i; assert(drawWidth < MAX_WIDTH); for (i=0; i<drawWidth; i++) @@ -347,7 +343,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, GLint row; for (row=0; row<drawHeight; row++) { assert(drawWidth < MAX_WIDTH); - gl_map_ci8_to_rgba(ctx, drawWidth, src, rgba); + _mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba); (*ctx->Driver.WriteRGBASpan)(ctx, drawWidth, destX, destY, (const GLubyte (*)[4])rgba, NULL); @@ -361,7 +357,7 @@ simple_DrawPixels( GLcontext *ctx, GLint x, GLint y, GLint row; for (row=0; row<drawHeight; row++) { assert(drawWidth < MAX_WIDTH); - gl_map_ci8_to_rgba(ctx, drawWidth, src, rgba); + _mesa_map_ci8_to_rgba(ctx, drawWidth, src, rgba); gl_write_zoomed_rgba_span(ctx, drawWidth, destX, destY, zSpan, (void *) rgba, zoomY0); src += rowLength; @@ -418,7 +414,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, /* Fragment depth values */ if (ctx->Depth.Test || ctx->Fog.Enabled) { - GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLdepth zval = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF); GLint i; for (i = 0; i < drawWidth; i++) { zspan[i] = zval; @@ -430,7 +426,7 @@ draw_index_pixels( GLcontext *ctx, GLint x, GLint y, */ for (row = 0; row < height; row++, y++) { GLuint indexes[MAX_WIDTH]; - const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack, + const GLvoid *source = _mesa_image_address(&ctx->Unpack, pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0); _mesa_unpack_index_span(ctx, drawWidth, GL_UNSIGNED_INT, indexes, type, source, &ctx->Unpack, GL_TRUE); @@ -455,6 +451,7 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, GLenum type, const GLvoid *pixels ) { const GLboolean zoom = ctx->Pixel.ZoomX!=1.0 || ctx->Pixel.ZoomY!=1.0; + const GLboolean shift_or_offset = ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset; const GLint desty = y; GLint row, drawWidth; @@ -476,17 +473,23 @@ draw_stencil_pixels( GLcontext *ctx, GLint x, GLint y, GLstencil values[MAX_WIDTH]; GLenum destType = (sizeof(GLstencil) == sizeof(GLubyte)) ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT; - const GLvoid *source = gl_pixel_addr_in_image(&ctx->Unpack, + const GLvoid *source = _mesa_image_address(&ctx->Unpack, pixels, width, height, GL_COLOR_INDEX, type, 0, row, 0); _mesa_unpack_index_span(ctx, drawWidth, destType, values, - type, source, &ctx->Unpack, GL_TRUE); + type, source, &ctx->Unpack, GL_FALSE); + if (shift_or_offset) { + _mesa_shift_and_offset_stencil( ctx, drawWidth, values ); + } + if (ctx->Pixel.MapStencilFlag) { + _mesa_map_stencil( ctx, drawWidth, values ); + } if (zoom) { gl_write_zoomed_stencil_span( ctx, (GLuint) drawWidth, x, y, values, desty ); } else { - gl_write_stencil_span( ctx, (GLuint) drawWidth, x, y, values ); + _mesa_write_stencil_span( ctx, (GLuint) drawWidth, x, y, values ); } } } @@ -545,30 +548,23 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, /* Special case: directly write 16-bit depth values */ GLint row; for (row = 0; row < height; row++, y++) { - const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack, + GLdepth zspan[MAX_WIDTH]; + const GLushort *zptr = _mesa_image_address(&ctx->Unpack, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); - gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP ); + GLint i; + for (i = 0; i < width; i++) + zspan[i] = zptr[i]; + gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP ); } } - else if (type==GL_UNSIGNED_INT && sizeof(GLdepth)==sizeof(GLuint) + else if (type==GL_UNSIGNED_INT && ctx->Visual->DepthBits == 32 && !bias_or_scale && !zoom && ctx->Visual->RGBAflag) { /* Special case: directly write 32-bit depth values */ - GLint i, row; - /* Compute shift value to scale 32-bit uints down to depth values. */ - GLuint shift = 0; - GLuint max = MAX_DEPTH; - while ((max & 0x80000000) == 0) { - max = max << 1; - shift++; - } + GLint row; for (row = 0; row < height; row++, y++) { - GLdepth zspan[MAX_WIDTH]; - const GLdepth *zptr = gl_pixel_addr_in_image(&ctx->Unpack, + const GLuint *zptr = _mesa_image_address(&ctx->Unpack, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); - for (i=0;i<width;i++) { - zspan[i] = zptr[i] >> shift; - } - gl_write_rgba_span( ctx, width, x, y, zspan, rgba, GL_BITMAP ); + gl_write_rgba_span( ctx, width, x, y, zptr, rgba, GL_BITMAP ); } } else { @@ -576,7 +572,7 @@ draw_depth_pixels( GLcontext *ctx, GLint x, GLint y, GLint row; for (row = 0; row < height; row++, y++) { GLdepth zspan[MAX_WIDTH]; - const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, + const GLvoid *src = _mesa_image_address(&ctx->Unpack, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, row, 0); _mesa_unpack_depth_span( ctx, drawWidth, zspan, type, src, &ctx->Unpack, GL_TRUE ); @@ -625,7 +621,7 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, /* Fragment depth values */ if (ctx->Depth.Test || ctx->Fog.Enabled) { /* fill in array of z values */ - GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * DEPTH_SCALE); + GLdepth z = (GLdepth) (ctx->Current.RasterPos[2] * ctx->Visual->DepthMaxF); GLint i; for (i=0;i<width;i++) { zspan[i] = z; @@ -652,10 +648,23 @@ draw_rgba_pixels( GLcontext *ctx, GLint x, GLint y, if (width > MAX_WIDTH) width = MAX_WIDTH; for (row = 0; row < height; row++, y++) { - const GLvoid *source = gl_pixel_addr_in_image(unpack, + const GLvoid *source = _mesa_image_address(unpack, pixels, width, height, format, type, 0, row, 0); _mesa_unpack_ubyte_color_span(ctx, width, GL_RGBA, (void*) rgba, format, type, source, unpack, GL_TRUE); + if (ctx->Pixel.MinMaxEnabled && ctx->MinMax.Sink) + continue; + + if (ctx->Texture.ReallyEnabled && ctx->Pixel.PixelTextureEnabled) { + GLfloat s[MAX_WIDTH], t[MAX_WIDTH], r[MAX_WIDTH], q[MAX_WIDTH]; + GLuint unit; + /* XXX not sure how multitexture is supposed to work here */ + for (unit = 0; unit < MAX_TEXTURE_UNITS; unit++) { + _mesa_pixeltexgen(ctx, width, (const GLubyte (*)[4]) rgba, + s, t, r, q); + gl_texture_pixels(ctx, unit, width, s, t, r, NULL, rgba); + } + } if (quickDraw) { (*ctx->Driver.WriteRGBASpan)( ctx, width, x, y, @@ -690,9 +699,22 @@ _mesa_DrawPixels( GLsizei width, GLsizei height, return; } + if (ctx->NewState) { + gl_update_state(ctx); + } + x = (GLint) (ctx->Current.RasterPos[0] + 0.5F); y = (GLint) (ctx->Current.RasterPos[1] + 0.5F); + ctx->OcclusionResult = GL_TRUE; + + /* see if device driver can do the drawpix */ + if (ctx->Driver.DrawPixels + && (*ctx->Driver.DrawPixels)(ctx, x, y, width, height, format, type, + &ctx->Unpack, pixels)) { + return; + } + switch (format) { case GL_STENCIL_INDEX: draw_stencil_pixels( ctx, x, y, width, height, type, pixels ); diff --git a/xc/extras/Mesa/src/enable.c b/xc/extras/Mesa/src/enable.c index aff6cbb50..97554430e 100644 --- a/xc/extras/Mesa/src/enable.c +++ b/xc/extras/Mesa/src/enable.c @@ -153,6 +153,9 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) ctx->NewState |= NEW_FOG|NEW_RASTER_OPS; } break; + case GL_HISTOGRAM: + ctx->Pixel.HistogramEnabled = state; + break; case GL_LIGHT0: case GL_LIGHT1: case GL_LIGHT2: @@ -191,6 +194,7 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) case GL_LINE_SMOOTH: if (ctx->Line.SmoothFlag!=state) { ctx->Line.SmoothFlag = state; + ctx->TriangleCaps ^= DD_LINE_SMOOTH; ctx->NewState |= NEW_RASTER_OPS; } break; @@ -267,6 +271,9 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) case GL_MAP2_VERTEX_4: ctx->Eval.Map2Vertex4 = state; break; + case GL_MINMAX: + ctx->Pixel.MinMaxEnabled = state; + break; case GL_NORMALIZE: if (ctx->Transform.Normalize != state) { ctx->Transform.Normalize = state; @@ -327,8 +334,6 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) break; case GL_SHARED_TEXTURE_PALETTE_EXT: ctx->Texture.SharedPalette = state; - if (ctx->Driver.UseGlobalTexturePalette) - (*ctx->Driver.UseGlobalTexturePalette)( ctx, state ); break; case GL_STENCIL_TEST: if (state && ctx->Visual->StencilBits==0) { @@ -452,6 +457,81 @@ void _mesa_set_enable( GLcontext *ctx, GLenum cap, GLboolean state ) ctx->Array.EdgeFlag.Enabled = state; break; + /* GL_HP_occlusion_test */ + case GL_OCCLUSION_TEST_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + ctx->Depth.OcclusionTest = state; + if (state) + ctx->OcclusionResult = ctx->OcclusionResultSaved; + else + ctx->OcclusionResultSaved = ctx->OcclusionResult; + ctx->NewState |= NEW_RASTER_OPS; + } + else { + gl_error( ctx, GL_INVALID_ENUM, state ? "glEnable": "glDisable" ); + return; + } + break; + + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + ctx->Pixel.PixelTextureEnabled = state; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + ctx->Pixel.PixelTextureEnabled = state; + break; + + /* GL_SGI_color_table */ + case GL_COLOR_TABLE_SGI: + ctx->Pixel.ColorTableEnabled = state; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + ctx->Pixel.PostConvolutionColorTableEnabled = state; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + ctx->Pixel.PostColorMatrixColorTableEnabled = state; + break; + + /* GL_EXT_convolution */ + case GL_CONVOLUTION_1D: + ctx->Pixel.Convolution1DEnabled = state; + break; + case GL_CONVOLUTION_2D: + ctx->Pixel.Convolution2DEnabled = state; + break; + case GL_SEPARABLE_2D: + ctx->Pixel.Separable2DEnabled = state; + break; + + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) { + if (ctx->Visual->RGBAflag) { + const GLuint curr = ctx->Texture.CurrentUnit; + const GLuint flag = TEXTURE0_CUBE << (curr * 4); + struct gl_texture_unit *texUnit = &ctx->Texture.Unit[curr]; + ctx->NewState |= NEW_TEXTURE_ENABLE; + if (state) { + texUnit->Enabled |= TEXTURE0_CUBE; + ctx->Enabled |= flag; + } + else { + texUnit->Enabled &= ~TEXTURE0_CUBE; + ctx->Enabled &= ~flag; + } + } + } + else { + if (state) + gl_error(ctx, GL_INVALID_ENUM, "glEnable"); + else + gl_error(ctx, GL_INVALID_ENUM, "glDisable"); + return; + } + break; + default: if (state) { gl_error( ctx, GL_INVALID_ENUM, "glEnable" ); @@ -516,6 +596,8 @@ _mesa_IsEnabled( GLenum cap ) return ctx->Color.DitherFlag; case GL_FOG: return ctx->Fog.Enabled; + case GL_HISTOGRAM: + return ctx->Pixel.HistogramEnabled; case GL_LIGHTING: return ctx->Light.Enabled; case GL_LIGHT0: @@ -571,6 +653,8 @@ _mesa_IsEnabled( GLenum cap ) return ctx->Eval.Map2Vertex3; case GL_MAP2_VERTEX_4: return ctx->Eval.Map2Vertex4; + case GL_MINMAX: + return ctx->Pixel.MinMaxEnabled; case GL_NORMALIZE: return ctx->Transform.Normalize; case GL_POINT_SMOOTH: @@ -645,6 +729,52 @@ _mesa_IsEnabled( GLenum cap ) return ctx->Array.TexCoord[ctx->Array.ActiveTexture].Enabled; case GL_EDGE_FLAG_ARRAY: return ctx->Array.EdgeFlag.Enabled; + + /* GL_HP_occlusion_test */ + case GL_OCCLUSION_TEST_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + return ctx->Depth.OcclusionTest; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); + return GL_FALSE; + } + + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + return ctx->Pixel.PixelTextureEnabled; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + return ctx->Pixel.PixelTextureEnabled; + + /* GL_SGI_color_table */ + case GL_COLOR_TABLE_SGI: + return ctx->Pixel.ColorTableEnabled; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + return ctx->Pixel.PostConvolutionColorTableEnabled; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + return ctx->Pixel.PostColorMatrixColorTableEnabled; + + /* GL_EXT_convolution */ + case GL_CONVOLUTION_1D: + return ctx->Pixel.Convolution1DEnabled; + case GL_CONVOLUTION_2D: + return ctx->Pixel.Convolution2DEnabled; + case GL_SEPARABLE_2D: + return ctx->Pixel.Separable2DEnabled; + + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) { + const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + return (texUnit->Enabled & TEXTURE0_CUBE) ? GL_TRUE : GL_FALSE; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glIsEnabled"); + return GL_FALSE; + } + default: gl_error( ctx, GL_INVALID_ENUM, "glIsEnabled" ); return GL_FALSE; diff --git a/xc/extras/Mesa/src/extensions.c b/xc/extras/Mesa/src/extensions.c index 82ad25208..18ff0c0cf 100644 --- a/xc/extras/Mesa/src/extensions.c +++ b/xc/extras/Mesa/src/extensions.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -40,7 +40,7 @@ struct extension { struct extension *next, *prev; - int enabled; + GLint enabled; char name[MAX_EXT_NAMELEN+1]; void (*notify)( GLcontext *, GLboolean ); }; @@ -48,36 +48,68 @@ struct extension { static struct { int enabled; const char *name; } default_extensions[] = { + { DEFAULT_OFF, "GL_ARB_imaging" }, /* in progress */ + { DEFAULT_ON, "GL_ARB_multitexture" }, + { DEFAULT_OFF, "GL_ARB_texture_compression" }, /* in progress */ + { DEFAULT_OFF, "GL_ARB_texture_cube_map" }, /* in progress */ + { ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" }, + { ALWAYS_ENABLED, "GL_EXT_abgr" }, { DEFAULT_ON, "GL_EXT_blend_color" }, - { DEFAULT_OFF, "ARB_imaging" }, - { DEFAULT_ON, "GL_EXT_blend_minmax" }, + { DEFAULT_ON, "GL_EXT_blend_func_separate" }, { DEFAULT_ON, "GL_EXT_blend_logic_op" }, + { DEFAULT_ON, "GL_EXT_blend_minmax" }, { DEFAULT_ON, "GL_EXT_blend_subtract" }, + { DEFAULT_ON, "GL_EXT_clip_volume_hint" }, + { DEFAULT_OFF, "GL_EXT_convolution" }, /* in progress */ + { DEFAULT_ON, "GL_EXT_compiled_vertex_array" }, + { DEFAULT_ON, "GL_EXT_histogram" }, { DEFAULT_ON, "GL_EXT_paletted_texture" }, { DEFAULT_ON, "GL_EXT_point_parameters" }, { ALWAYS_ENABLED, "GL_EXT_polygon_offset" }, - { ALWAYS_ENABLED, "GL_EXT_vertex_array" }, - { ALWAYS_ENABLED, "GL_EXT_texture_object" }, - { DEFAULT_ON, "GL_EXT_texture3D" }, - { ALWAYS_ENABLED, "GL_MESA_window_pos" }, - { ALWAYS_ENABLED, "GL_MESA_resize_buffers" }, - { ALWAYS_ENABLED, "GL_EXT_shared_texture_palette" }, { ALWAYS_ENABLED, "GL_EXT_rescale_normal" }, - { ALWAYS_ENABLED, "GL_EXT_abgr" }, - { ALWAYS_ENABLED, "GL_SGIS_texture_edge_clamp" }, + { DEFAULT_ON, "GL_EXT_shared_texture_palette" }, { ALWAYS_ENABLED, "GL_EXT_stencil_wrap" }, + { DEFAULT_ON, "GL_EXT_texture3D" }, + { DEFAULT_OFF, "GL_EXT_texture_compression_s3tc" }, + { DEFAULT_OFF, "GL_EXT_texture_env" }, + { DEFAULT_ON, "GL_EXT_texture_env_add" }, + { ALWAYS_ENABLED, "GL_EXT_texture_object" }, + { DEFAULT_ON, "GL_EXT_texture_lod_bias" }, + { ALWAYS_ENABLED, "GL_EXT_vertex_array" }, + { DEFAULT_OFF, "GL_EXT_vertex_array_set" }, + { DEFAULT_OFF, "GL_HP_occlusion_test" }, { DEFAULT_ON, "GL_INGR_blend_func_separate" }, - { DEFAULT_ON, "GL_ARB_multitexture" }, + { ALWAYS_ENABLED, "GL_MESA_window_pos" }, + { ALWAYS_ENABLED, "GL_MESA_resize_buffers" }, { ALWAYS_ENABLED, "GL_NV_texgen_reflection" }, { DEFAULT_ON, "GL_PGI_misc_hints" }, - { DEFAULT_ON, "GL_EXT_compiled_vertex_array" }, - { DEFAULT_OFF, "GL_EXT_vertex_array_set" }, - { DEFAULT_ON, "GL_EXT_clip_volume_hint" }, - { DEFAULT_ON, "GL_EXT_texture_env_add" }, - { ALWAYS_ENABLED, "GL_ARB_tranpose_matrix" }, + { DEFAULT_ON, "GL_SGI_color_matrix" }, + { DEFAULT_ON, "GL_SGI_color_table" }, + { DEFAULT_ON, "GL_SGIS_pixel_texture" }, + { DEFAULT_ON, "GL_SGIS_texture_edge_clamp" }, + { DEFAULT_ON, "GL_SGIX_pixel_texture" }, + { DEFAULT_OFF, "GL_3DFX_texture_compression_FXT1" } }; +/* + * Update the boolean convenience flags in the Extensions struct. + */ +static void +update_extension_flags( GLcontext *ctx ) +{ + /* Update flags */ + ctx->Extensions.HaveTextureEnvAdd = gl_extension_is_enabled(ctx, "GL_EXT_texture_env_add"); + ctx->Extensions.HaveTextureLodBias = gl_extension_is_enabled(ctx, "GL_EXT_texture_lod_bias"); + ctx->Extensions.HaveHpOcclusionTest = gl_extension_is_enabled(ctx, "GL_HP_occlusion_test"); + ctx->Extensions.HaveTextureCubeMap = gl_extension_is_enabled(ctx, "GL_ARB_texture_cube_map"); + ctx->Extensions.HaveTextureCompression = gl_extension_is_enabled(ctx, "GL_ARB_texture_compression"); + ctx->Extensions.HaveTextureCompressionS3TC = gl_extension_is_enabled(ctx, "GL_EXT_texture_compression_s3tc"); + ctx->Extensions.HaveTextureCompressionFXT1 = gl_extension_is_enabled(ctx, "GL_3DFX_texture_compression_FXT1"); +} + + + int gl_extensions_add( GLcontext *ctx, int state, const char *name, @@ -99,21 +131,26 @@ int gl_extensions_add( GLcontext *ctx, } -static int set_extension( GLcontext *ctx, const char *name, GLuint state ) +/* + * Either enable or disable the named extension. + */ +static int set_extension( GLcontext *ctx, const char *name, GLint state ) { struct extension *i; foreach( i, ctx->Extensions.ext_list ) if (strncmp(i->name, name, MAX_EXT_NAMELEN) == 0) break; - if (i == ctx->Extensions.ext_list) return 1; + if (i == ctx->Extensions.ext_list) + return 1; - if (i->enabled && !(i->enabled & ALWAYS_ENABLED)) - { + if (!(i->enabled & ALWAYS_ENABLED)) { if (i->notify) i->notify( ctx, state ); i->enabled = state; } + update_extension_flags(ctx); + return 0; } @@ -187,6 +224,7 @@ void gl_extensions_ctr( GLcontext *ctx ) default_extensions[i].name, 0 ); } + update_extension_flags(ctx); } diff --git a/xc/extras/Mesa/src/feedback.c b/xc/extras/Mesa/src/feedback.c index 12565b105..5d14e892e 100644 --- a/xc/extras/Mesa/src/feedback.c +++ b/xc/extras/Mesa/src/feedback.c @@ -167,7 +167,7 @@ static void feedback_vertex( GLcontext *ctx, GLuint v, GLuint pv ) win[0] = VB->Win.data[v][0]; win[1] = VB->Win.data[v][1]; - win[2] = VB->Win.data[v][2] / DEPTH_SCALE; + win[2] = VB->Win.data[v][2] / ctx->Visual->DepthMaxF; win[3] = 1.0 / VB->Win.data[v][3]; if (ctx->Light.ShadeModel == GL_SMOOTH) @@ -298,12 +298,13 @@ void gl_update_hitflag( GLcontext *ctx, GLfloat z ) void gl_select_triangle( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint pv ) { - struct vertex_buffer *VB = ctx->VB; + const struct vertex_buffer *VB = ctx->VB; if (gl_cull_triangle( ctx, v0, v1, v2, 0 )) { - gl_update_hitflag( ctx, VB->Win.data[v0][2] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v1][2] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v2][2] / DEPTH_SCALE ); + const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF; + gl_update_hitflag( ctx, VB->Win.data[v0][2] * zs ); + gl_update_hitflag( ctx, VB->Win.data[v1][2] * zs ); + gl_update_hitflag( ctx, VB->Win.data[v2][2] * zs ); } } @@ -311,21 +312,22 @@ void gl_select_triangle( GLcontext *ctx, void gl_select_line( GLcontext *ctx, GLuint v0, GLuint v1, GLuint pv ) { - struct vertex_buffer *VB = ctx->VB; - - gl_update_hitflag( ctx, VB->Win.data[v0][2] / DEPTH_SCALE ); - gl_update_hitflag( ctx, VB->Win.data[v1][2] / DEPTH_SCALE ); + const struct vertex_buffer *VB = ctx->VB; + const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF; + gl_update_hitflag( ctx, VB->Win.data[v0][2] * zs ); + gl_update_hitflag( ctx, VB->Win.data[v1][2] * zs ); } void gl_select_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; + const GLfloat zs = 1.0F / ctx->Visual->DepthMaxF; GLuint i; for (i=first;i<=last;i++) { if (VB->ClipMask[i]==0) { - gl_update_hitflag( ctx, VB->Win.data[i][2] / DEPTH_SCALE); + gl_update_hitflag( ctx, VB->Win.data[i][2] * zs ); } } } diff --git a/xc/extras/Mesa/src/fog.c b/xc/extras/Mesa/src/fog.c index 1aff751c4..d21711805 100644 --- a/xc/extras/Mesa/src/fog.c +++ b/xc/extras/Mesa/src/fog.c @@ -33,6 +33,7 @@ #include "macros.h" #include "mmath.h" #include "types.h" +#include "xform.h" #endif @@ -84,6 +85,8 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params ) GET_CURRENT_CONTEXT(ctx); GLenum m; + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glFog"); + switch (pname) { case GL_FOG_MODE: m = (GLenum) (GLint) *params; @@ -105,23 +108,9 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params ) } break; case GL_FOG_START: -#if 0 - /* Prior to OpenGL 1.1, this was an error */ - if (*params<0.0F) { - gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_START)" ); - return; - } -#endif ctx->Fog.Start = *params; break; case GL_FOG_END: -#if 0 - /* Prior to OpenGL 1.1, this was an error */ - if (*params<0.0F) { - gl_error( ctx, GL_INVALID_VALUE, "glFog(GL_FOG_END)" ); - return; - } -#endif ctx->Fog.End = *params; break; case GL_FOG_INDEX: @@ -149,9 +138,13 @@ _mesa_Fogfv( GLenum pname, const GLfloat *params ) typedef void (*fog_func)( struct vertex_buffer *VB, GLuint side, GLubyte flag ); +typedef void (*fog_coord_func)( struct vertex_buffer *VB, + const GLvector4f *from, + GLubyte flag ); static fog_func fog_ci_tab[2]; static fog_func fog_rgba_tab[2]; +static fog_coord_func make_fog_coord_tab[2]; /* * Compute the fogged color for an array of vertices. @@ -209,6 +202,71 @@ _mesa_fog_vertices( struct vertex_buffer *VB ) } } + +static void check_fog_coords( GLcontext *ctx, struct gl_pipeline_stage *d ) +{ + d->type = 0; + + if (ctx->FogMode==FOG_FRAGMENT) + { + d->type = PIPE_IMMEDIATE|PIPE_PRECALC; + d->inputs = VERT_OBJ_ANY; + d->outputs = VERT_FOG_COORD; + } +} + + +static void gl_make_fog_coords( struct vertex_buffer *VB ) +{ + GLcontext *ctx = VB->ctx; + + /* If full eye coords weren't required, just calculate the eye Z + * values. + */ + if (!ctx->NeedEyeCoords) { + GLfloat *m = ctx->ModelView.m; + GLfloat plane[4]; + + plane[0] = m[2]; + plane[1] = m[6]; + plane[2] = m[10]; + plane[3] = m[14]; + + gl_dotprod_tab[0][VB->ObjPtr->size](&VB->Eye, + 2, /* fill z coordinates */ + VB->ObjPtr, + plane, + 0 ); + + make_fog_coord_tab[0]( VB, &VB->Eye, 0 ); + } + else + { + make_fog_coord_tab[0]( VB, VB->EyePtr, 0 ); + } +} + + +/* Drivers that want fog coordinates in VB->Spec[0] alpha, can substitute this + * stage for the default PIPE_OP_FOG pipeline stage. + */ +struct gl_pipeline_stage gl_fog_coord_stage = { + "build fog coordinates", + PIPE_OP_FOG, + PIPE_PRECALC|PIPE_IMMEDIATE, + 0, + NEW_FOG, + NEW_LIGHTING|NEW_RASTER_OPS|NEW_FOG|NEW_MODELVIEW, + 0, 0, + 0, 0, 0, + check_fog_coords, + gl_make_fog_coords +}; + + + + + /* * Apply fog to an array of RGBA pixels. * Input: n - number of pixels diff --git a/xc/extras/Mesa/src/get.c b/xc/extras/Mesa/src/get.c index 6c5f3ef9f..21b5b639a 100644 --- a/xc/extras/Mesa/src/get.c +++ b/xc/extras/Mesa/src/get.c @@ -57,6 +57,28 @@ #endif +static GLenum +pixel_texgen_mode(const GLcontext *ctx) +{ + if (ctx->Pixel.FragmentRgbSource == GL_CURRENT_RASTER_POSITION) { + if (ctx->Pixel.FragmentAlphaSource == GL_CURRENT_RASTER_POSITION) { + return GL_RGBA; + } + else { + return GL_RGB; + } + } + else { + if (ctx->Pixel.FragmentAlphaSource == GL_CURRENT_RASTER_POSITION) { + return GL_ALPHA; + } + else { + return GL_NONE; + } + } +} + + void _mesa_GetBooleanv( GLenum pname, GLboolean *params ) @@ -74,10 +96,16 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) switch (pname) { case GL_ACCUM_RED_BITS: + *params = INT_TO_BOOL(ctx->Visual->AccumRedBits); + break; case GL_ACCUM_GREEN_BITS: + *params = INT_TO_BOOL(ctx->Visual->AccumGreenBits); + break; case GL_ACCUM_BLUE_BITS: + *params = INT_TO_BOOL(ctx->Visual->AccumBlueBits); + break; case GL_ACCUM_ALPHA_BITS: - *params = INT_TO_BOOL(ctx->Visual->AccumBits); + *params = INT_TO_BOOL(ctx->Visual->AccumAlphaBits); break; case GL_ACCUM_CLEAR_VALUE: params[0] = FLOAT_TO_BOOL(ctx->Accum.ClearColor[0]); @@ -318,6 +346,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) case GL_GREEN_SCALE: *params = FLOAT_TO_BOOL(ctx->Pixel.GreenScale); break; + case GL_HISTOGRAM: + *params = ctx->Pixel.HistogramEnabled; + break; case GL_INDEX_BITS: *params = INT_TO_BOOL( ctx->Visual->IndexBits ); break; @@ -539,6 +570,9 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) params[0] = INT_TO_BOOL(MAX_WIDTH); params[1] = INT_TO_BOOL(MAX_HEIGHT); break; + case GL_MINMAX: + *params = ctx->Pixel.MinMaxEnabled; + break; case GL_MODELVIEW_MATRIX: for (i=0;i<16;i++) { params[i] = FLOAT_TO_BOOL(ctx->ModelView.m[i]); @@ -611,7 +645,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = INT_TO_BOOL(ctx->Pixel.MapStoSsize); break; case GL_POINT_SIZE: - *params = FLOAT_TO_BOOL(ctx->Point.Size ); + *params = FLOAT_TO_BOOL(ctx->Point.UserSize); break; case GL_POINT_SIZE_GRANULARITY: *params = FLOAT_TO_BOOL(ctx->Const.PointSizeGranularity ); @@ -747,13 +781,13 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = INT_TO_BOOL(ctx->Const.SubPixelBits); break; case GL_TEXTURE_1D: - *params = _mesa_IsEnabled(GL_TEXTURE_1D ); + *params = _mesa_IsEnabled(GL_TEXTURE_1D); break; case GL_TEXTURE_2D: - *params = _mesa_IsEnabled(GL_TEXTURE_2D ); + *params = _mesa_IsEnabled(GL_TEXTURE_2D); break; case GL_TEXTURE_3D: - *params = _mesa_IsEnabled(GL_TEXTURE_3D ); + *params = _mesa_IsEnabled(GL_TEXTURE_3D); break; case GL_TEXTURE_BINDING_1D: *params = INT_TO_BOOL(textureUnit->CurrentD[1]->Name); @@ -763,7 +797,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_TEXTURE_BINDING_3D: *params = INT_TO_BOOL(textureUnit->CurrentD[3]->Name); - break; + break; case GL_TEXTURE_ENV_COLOR: { params[0] = FLOAT_TO_BOOL(textureUnit->EnvColor[0]); @@ -908,6 +942,7 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = INT_TO_BOOL(ctx->Array.EdgeFlag.Stride); break; + /* GL_ARB_multitexture */ case GL_MAX_TEXTURE_UNITS_ARB: *params = ctx->Const.MaxTextureUnits; break; @@ -918,6 +953,51 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) *params = INT_TO_BOOL(GL_TEXTURE0_ARB + ctx->Array.ActiveTexture); break; + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB); + else + gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv"); + return; + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = INT_TO_BOOL(textureUnit->CurrentCubeMap->Name); + else + gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv"); + return; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = INT_TO_BOOL(ctx->Const.MaxCubeTextureSize); + else + gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv"); + break; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSION_HINT_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = INT_TO_BOOL(ctx->Hint.TextureCompression); + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv"); + break; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = INT_TO_BOOL(ctx->Const.NumCompressedTextureFormats); + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv"); + break; + case GL_COMPRESSED_TEXTURE_FORMATS_ARB: + if (ctx->Extensions.HaveTextureCompression) { + GLuint i; + for (i = 0; i < ctx->Const.NumCompressedTextureFormats; i++) + params[i] = INT_TO_BOOL(ctx->Const.CompressedTextureFormats[i]); + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetBooleanv"); + break; + /* GL_PGI_misc_hints */ case GL_STRICT_DEPTHFUNC_HINT_PGI: *params = ENUM_TO_BOOL(GL_NICEST); @@ -934,12 +1014,12 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) break; case GL_ALWAYS_FAST_HINT_PGI: *params = (GLboolean) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_FALSE && + ctx->Hint.AllowDrawFrg == GL_FALSE && ctx->Hint.AllowDrawMem == GL_FALSE); break; case GL_ALWAYS_SOFT_HINT_PGI: *params = (GLboolean) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_TRUE && + ctx->Hint.AllowDrawFrg == GL_TRUE && ctx->Hint.AllowDrawMem == GL_TRUE); break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -948,8 +1028,8 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) case GL_ALLOW_DRAW_WIN_HINT_PGI: *params = (GLboolean) ctx->Hint.AllowDrawWin; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - *params = (GLboolean) ctx->Hint.AllowDrawSpn; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + *params = (GLboolean) ctx->Hint.AllowDrawFrg; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: *params = (GLboolean) ctx->Hint.AllowDrawMem; @@ -978,7 +1058,14 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) /* GL_ARB_transpose_matrix */ case GL_TRANSPOSE_COLOR_MATRIX_ARB: - /* don't have a color matrix */ + { + GLfloat tm[16]; + GLuint i; + gl_matrix_transposef(tm, ctx->ColorMatrix.m); + for (i=0;i<16;i++) { + params[i] = FLOAT_TO_BOOL(tm[i]); + } + } break; case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB: { @@ -1011,8 +1098,124 @@ _mesa_GetBooleanv( GLenum pname, GLboolean *params ) } break; + /* GL_HP_occlusion_test */ + case GL_OCCLUSION_TEST_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + *params = ctx->Depth.OcclusionTest; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" ); + } + return; + case GL_OCCLUSION_TEST_RESULT_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + if (ctx->Depth.OcclusionTest) + *params = ctx->OcclusionResult; + else + *params = ctx->OcclusionResultSaved; + /* reset flag now */ + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" ); + } + return; + + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + *params = ctx->Pixel.PixelTextureEnabled; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + *params = ctx->Pixel.PixelTextureEnabled; + break; + case GL_PIXEL_TEX_GEN_MODE_SGIX: + *params = (GLboolean) pixel_texgen_mode(ctx); + break; + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = FLOAT_TO_BOOL(ctx->ColorMatrix.m[i]); + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = INT_TO_BOOL(ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = FLOAT_TO_BOOL(MAX_COLOR_STACK_DEPTH); + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixScale[0]); + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixScale[1]); + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixScale[2]); + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixScale[3]); + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixBias[0]); + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixBias[1]); + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixBias[2]); + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostColorMatrixBias[3]); + break; + + /* GL_EXT_convolution (also in 1.2 imaging) */ + case GL_MAX_CONVOLUTION_WIDTH: + *params = INT_TO_BOOL(ctx->Const.MaxConvolutionWidth); + break; + case GL_MAX_CONVOLUTION_HEIGHT: + *params = INT_TO_BOOL(ctx->Const.MaxConvolutionHeight); + break; + case GL_POST_CONVOLUTION_RED_SCALE_EXT: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostConvolutionScale[0]); + break; + case GL_POST_CONVOLUTION_GREEN_SCALE_EXT: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostConvolutionScale[1]); + break; + case GL_POST_CONVOLUTION_BLUE_SCALE_EXT: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostConvolutionScale[2]); + break; + case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostConvolutionScale[3]); + break; + case GL_POST_CONVOLUTION_RED_BIAS_EXT: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostConvolutionBias[0]); + break; + case GL_POST_CONVOLUTION_GREEN_BIAS_EXT: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostConvolutionBias[1]); + break; + case GL_POST_CONVOLUTION_BLUE_BIAS_EXT: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostConvolutionBias[2]); + break; + case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT: + *params = FLOAT_TO_BOOL(ctx->Pixel.PostConvolutionBias[2]); + break; + + /* GL_SGI_color_table (also in 1.2 imaging */ + case GL_COLOR_TABLE_SGI: + *params = ctx->Pixel.ColorTableEnabled; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + *params = ctx->Pixel.PostConvolutionColorTableEnabled; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + *params = ctx->Pixel.PostColorMatrixColorTableEnabled; + break; + default: - printf("invalid enum: %x\n", pname); gl_error( ctx, GL_INVALID_ENUM, "glGetBooleanv" ); } } @@ -1036,10 +1239,16 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) switch (pname) { case GL_ACCUM_RED_BITS: + *params = (GLdouble) ctx->Visual->AccumRedBits; + break; case GL_ACCUM_GREEN_BITS: + *params = (GLdouble) ctx->Visual->AccumGreenBits; + break; case GL_ACCUM_BLUE_BITS: + *params = (GLdouble) ctx->Visual->AccumBlueBits; + break; case GL_ACCUM_ALPHA_BITS: - *params = (GLdouble) ctx->Visual->AccumBits; + *params = (GLdouble) ctx->Visual->AccumAlphaBits; break; case GL_ACCUM_CLEAR_VALUE: params[0] = (GLdouble) ctx->Accum.ClearColor[0]; @@ -1280,6 +1489,9 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) case GL_GREEN_SCALE: *params = (GLdouble) ctx->Pixel.GreenScale; break; + case GL_HISTOGRAM: + *params = (GLdouble) ctx->Pixel.HistogramEnabled; + break; case GL_INDEX_BITS: *params = (GLdouble) ctx->Visual->IndexBits; break; @@ -1501,6 +1713,9 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) params[0] = (GLdouble) MAX_WIDTH; params[1] = (GLdouble) MAX_HEIGHT; break; + case GL_MINMAX: + *params = (GLdouble) ctx->Pixel.MinMaxEnabled; + break; case GL_MODELVIEW_MATRIX: for (i=0;i<16;i++) { params[i] = (GLdouble) ctx->ModelView.m[i]; @@ -1573,7 +1788,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = (GLdouble) ctx->Pixel.MapStoSsize; break; case GL_POINT_SIZE: - *params = (GLdouble) ctx->Point.Size; + *params = (GLdouble) ctx->Point.UserSize; break; case GL_POINT_SIZE_GRANULARITY: *params = (GLdouble) ctx->Const.PointSizeGranularity; @@ -1870,6 +2085,7 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = 0.0; break; + /* GL_ARB_multitexture */ case GL_MAX_TEXTURE_UNITS_ARB: *params = (GLdouble) ctx->Const.MaxTextureUnits; break; @@ -1880,6 +2096,50 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) *params = (GLdouble) (GL_TEXTURE0_ARB + ctx->Array.ActiveTexture); break; + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = (GLdouble) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB); + else + gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev"); + return; + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = (GLdouble) textureUnit->CurrentCubeMap->Name; + else + gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev"); + return; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = (GLdouble) ctx->Const.MaxCubeTextureSize; + else + gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev"); + return; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSION_HINT_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = (GLdouble) ctx->Hint.TextureCompression; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev"); + break; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = (GLdouble) ctx->Const.NumCompressedTextureFormats; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev"); + break; + case GL_COMPRESSED_TEXTURE_FORMATS_ARB: + if (ctx->Extensions.HaveTextureCompression) { + GLuint i; + for (i = 0; i < ctx->Const.NumCompressedTextureFormats; i++) + params[i] = (GLdouble) ctx->Const.CompressedTextureFormats[i]; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetDoublev"); + break; /* GL_PGI_misc_hints */ case GL_STRICT_DEPTHFUNC_HINT_PGI: @@ -1897,12 +2157,12 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) break; case GL_ALWAYS_FAST_HINT_PGI: *params = (GLdouble) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_FALSE && + ctx->Hint.AllowDrawFrg == GL_FALSE && ctx->Hint.AllowDrawMem == GL_FALSE); break; case GL_ALWAYS_SOFT_HINT_PGI: *params = (GLdouble) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_TRUE && + ctx->Hint.AllowDrawFrg == GL_TRUE && ctx->Hint.AllowDrawMem == GL_TRUE); break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -1911,8 +2171,8 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) case GL_ALLOW_DRAW_WIN_HINT_PGI: *params = (GLdouble) ctx->Hint.AllowDrawWin; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - *params = (GLdouble) ctx->Hint.AllowDrawSpn; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + *params = (GLdouble) ctx->Hint.AllowDrawFrg; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: *params = (GLdouble) ctx->Hint.AllowDrawMem; @@ -1941,7 +2201,14 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) /* GL_ARB_transpose_matrix */ case GL_TRANSPOSE_COLOR_MATRIX_ARB: - /* don't have a color matrix */ + { + GLfloat tm[16]; + GLuint i; + gl_matrix_transposef(tm, ctx->ColorMatrix.m); + for (i=0;i<16;i++) { + params[i] = (GLdouble) tm[i]; + } + } break; case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB: { @@ -1974,8 +2241,124 @@ _mesa_GetDoublev( GLenum pname, GLdouble *params ) } break; + /* GL_HP_occlusion_test */ + case GL_OCCLUSION_TEST_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + *params = (GLdouble) ctx->Depth.OcclusionTest; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" ); + } + return; + case GL_OCCLUSION_TEST_RESULT_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + if (ctx->Depth.OcclusionTest) + *params = (GLdouble) ctx->OcclusionResult; + else + *params = (GLdouble) ctx->OcclusionResultSaved; + /* reset flag now */ + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" ); + } + return; + + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + *params = (GLdouble) ctx->Pixel.PixelTextureEnabled; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + *params = (GLdouble) ctx->Pixel.PixelTextureEnabled; + break; + case GL_PIXEL_TEX_GEN_MODE_SGIX: + *params = (GLdouble) pixel_texgen_mode(ctx); + break; + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = (GLdouble) ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLdouble) (ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLdouble) MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixScale[0]; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixScale[1]; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixScale[2]; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixScale[3]; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixBias[0]; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixBias[1]; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixBias[2]; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixBias[3]; + break; + + /* GL_EXT_convolution (also in 1.2 imaging) */ + case GL_MAX_CONVOLUTION_WIDTH: + *params = (GLdouble) ctx->Const.MaxConvolutionWidth; + break; + case GL_MAX_CONVOLUTION_HEIGHT: + *params = (GLdouble) ctx->Const.MaxConvolutionHeight; + break; + case GL_POST_CONVOLUTION_RED_SCALE_EXT: + *params = (GLdouble) ctx->Pixel.PostConvolutionScale[0]; + break; + case GL_POST_CONVOLUTION_GREEN_SCALE_EXT: + *params = (GLdouble) ctx->Pixel.PostConvolutionScale[1]; + break; + case GL_POST_CONVOLUTION_BLUE_SCALE_EXT: + *params = (GLdouble) ctx->Pixel.PostConvolutionScale[2]; + break; + case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT: + *params = (GLdouble) ctx->Pixel.PostConvolutionScale[3]; + break; + case GL_POST_CONVOLUTION_RED_BIAS_EXT: + *params = (GLdouble) ctx->Pixel.PostConvolutionBias[0]; + break; + case GL_POST_CONVOLUTION_GREEN_BIAS_EXT: + *params = (GLdouble) ctx->Pixel.PostConvolutionBias[1]; + break; + case GL_POST_CONVOLUTION_BLUE_BIAS_EXT: + *params = (GLdouble) ctx->Pixel.PostConvolutionBias[2]; + break; + case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT: + *params = (GLdouble) ctx->Pixel.PostConvolutionBias[2]; + break; + + /* GL_SGI_color_table (also in 1.2 imaging */ + case GL_COLOR_TABLE_SGI: + *params = (GLdouble) ctx->Pixel.ColorTableEnabled; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + *params = (GLdouble) ctx->Pixel.PostConvolutionColorTableEnabled; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + *params = (GLdouble) ctx->Pixel.PostColorMatrixColorTableEnabled; + break; + default: - printf("invalid enum: %x\n", pname); gl_error( ctx, GL_INVALID_ENUM, "glGetDoublev" ); } } @@ -1999,10 +2382,16 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) switch (pname) { case GL_ACCUM_RED_BITS: + *params = (GLfloat) ctx->Visual->AccumRedBits; + break; case GL_ACCUM_GREEN_BITS: + *params = (GLfloat) ctx->Visual->AccumGreenBits; + break; case GL_ACCUM_BLUE_BITS: + *params = (GLfloat) ctx->Visual->AccumBlueBits; + break; case GL_ACCUM_ALPHA_BITS: - *params = (GLfloat) ctx->Visual->AccumBits; + *params = (GLfloat) ctx->Visual->AccumAlphaBits; break; case GL_ACCUM_CLEAR_VALUE: params[0] = ctx->Accum.ClearColor[0]; @@ -2240,6 +2629,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) case GL_GREEN_SCALE: *params = (GLfloat) ctx->Pixel.GreenScale; break; + case GL_HISTOGRAM: + *params = (GLfloat) ctx->Pixel.HistogramEnabled; + break; case GL_INDEX_BITS: *params = (GLfloat) ctx->Visual->IndexBits; break; @@ -2461,6 +2853,9 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) params[0] = (GLfloat) MAX_WIDTH; params[1] = (GLfloat) MAX_HEIGHT; break; + case GL_MINMAX: + *params = (GLfloat) ctx->Pixel.MinMaxEnabled; + break; case GL_MODELVIEW_MATRIX: for (i=0;i<16;i++) { params[i] = ctx->ModelView.m[i]; @@ -2533,7 +2928,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = (GLfloat) ctx->Pixel.MapStoSsize; break; case GL_POINT_SIZE: - *params = (GLfloat) ctx->Point.Size; + *params = (GLfloat) ctx->Point.UserSize; break; case GL_POINT_SIZE_GRANULARITY: *params = (GLfloat) ctx->Const.PointSizeGranularity; @@ -2832,6 +3227,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = 0.0; break; + /* GL_ARB_multitexture */ case GL_MAX_TEXTURE_UNITS_ARB: *params = (GLfloat) ctx->Const.MaxTextureUnits; break; @@ -2842,6 +3238,51 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) *params = (GLfloat) (GL_TEXTURE0_ARB + ctx->Array.ActiveTexture); break; + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = (GLfloat) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB); + else + gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv"); + return; + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = (GLfloat) textureUnit->CurrentCubeMap->Name; + else + gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv"); + return; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = (GLfloat) ctx->Const.MaxCubeTextureSize; + else + gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv"); + return; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSION_HINT_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = (GLfloat) ctx->Hint.TextureCompression; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv"); + break; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = (GLfloat) ctx->Const.NumCompressedTextureFormats; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv"); + break; + case GL_COMPRESSED_TEXTURE_FORMATS_ARB: + if (ctx->Extensions.HaveTextureCompression) { + GLuint i; + for (i = 0; i < ctx->Const.NumCompressedTextureFormats; i++) + params[i] = (GLfloat) ctx->Const.CompressedTextureFormats[i]; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetFloatv"); + break; + /* GL_PGI_misc_hints */ case GL_STRICT_DEPTHFUNC_HINT_PGI: *params = ENUM_TO_FLOAT(GL_NICEST); @@ -2858,12 +3299,12 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) break; case GL_ALWAYS_FAST_HINT_PGI: *params = (GLfloat) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_FALSE && + ctx->Hint.AllowDrawFrg == GL_FALSE && ctx->Hint.AllowDrawMem == GL_FALSE); break; case GL_ALWAYS_SOFT_HINT_PGI: *params = (GLfloat) (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_TRUE && + ctx->Hint.AllowDrawFrg == GL_TRUE && ctx->Hint.AllowDrawMem == GL_TRUE); break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -2872,8 +3313,8 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) case GL_ALLOW_DRAW_WIN_HINT_PGI: *params = (GLfloat) ctx->Hint.AllowDrawWin; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - *params = (GLfloat) ctx->Hint.AllowDrawSpn; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + *params = (GLfloat) ctx->Hint.AllowDrawFrg; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: *params = (GLfloat) ctx->Hint.AllowDrawMem; @@ -2902,7 +3343,7 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) /* GL_ARB_transpose_matrix */ case GL_TRANSPOSE_COLOR_MATRIX_ARB: - /* don't have a color matrix */ + gl_matrix_transposef(params, ctx->ColorMatrix.m); break; case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB: gl_matrix_transposef(params, ctx->ModelView.m); @@ -2914,8 +3355,124 @@ _mesa_GetFloatv( GLenum pname, GLfloat *params ) gl_matrix_transposef(params, ctx->TextureMatrix[texTransformUnit].m); break; + /* GL_HP_occlusion_test */ + case GL_OCCLUSION_TEST_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + *params = (GLfloat) ctx->Depth.OcclusionTest; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" ); + } + return; + case GL_OCCLUSION_TEST_RESULT_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + if (ctx->Depth.OcclusionTest) + *params = (GLfloat) ctx->OcclusionResult; + else + *params = (GLfloat) ctx->OcclusionResultSaved; + /* reset flag now */ + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" ); + } + return; + + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + *params = (GLfloat) ctx->Pixel.PixelTextureEnabled; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + *params = (GLfloat) ctx->Pixel.PixelTextureEnabled; + break; + case GL_PIXEL_TEX_GEN_MODE_SGIX: + *params = (GLfloat) pixel_texgen_mode(ctx); + break; + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLfloat) (ctx->ColorStackDepth + 1); + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = (GLfloat) MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixScale[0]; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixScale[1]; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixScale[2]; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = ctx->Pixel.PostColorMatrixScale[3]; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixBias[0]; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixBias[1]; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixBias[2]; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = ctx->Pixel.PostColorMatrixBias[3]; + break; + + /* GL_EXT_convolution (also in 1.2 imaging) */ + case GL_MAX_CONVOLUTION_WIDTH: + *params = (GLfloat) ctx->Const.MaxConvolutionWidth; + break; + case GL_MAX_CONVOLUTION_HEIGHT: + *params = (GLfloat) ctx->Const.MaxConvolutionHeight; + break; + case GL_POST_CONVOLUTION_RED_SCALE_EXT: + *params = ctx->Pixel.PostConvolutionScale[0]; + break; + case GL_POST_CONVOLUTION_GREEN_SCALE_EXT: + *params = ctx->Pixel.PostConvolutionScale[1]; + break; + case GL_POST_CONVOLUTION_BLUE_SCALE_EXT: + *params = ctx->Pixel.PostConvolutionScale[2]; + break; + case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT: + *params = ctx->Pixel.PostConvolutionScale[3]; + break; + case GL_POST_CONVOLUTION_RED_BIAS_EXT: + *params = ctx->Pixel.PostConvolutionBias[0]; + break; + case GL_POST_CONVOLUTION_GREEN_BIAS_EXT: + *params = ctx->Pixel.PostConvolutionBias[1]; + break; + case GL_POST_CONVOLUTION_BLUE_BIAS_EXT: + *params = ctx->Pixel.PostConvolutionBias[2]; + break; + case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT: + *params = ctx->Pixel.PostConvolutionBias[2]; + break; + + /* GL_SGI_color_table (also in 1.2 imaging */ + case GL_COLOR_TABLE_SGI: + *params = (GLfloat) ctx->Pixel.ColorTableEnabled; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + *params = (GLfloat) ctx->Pixel.PostConvolutionColorTableEnabled; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + *params = (GLfloat) ctx->Pixel.PostColorMatrixColorTableEnabled; + break; + default: - printf("invalid enum: %x\n", pname); gl_error( ctx, GL_INVALID_ENUM, "glGetFloatv" ); } } @@ -2939,10 +3496,16 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) switch (pname) { case GL_ACCUM_RED_BITS: + *params = (GLint) ctx->Visual->AccumRedBits; + break; case GL_ACCUM_GREEN_BITS: + *params = (GLint) ctx->Visual->AccumGreenBits; + break; case GL_ACCUM_BLUE_BITS: + *params = (GLint) ctx->Visual->AccumBlueBits; + break; case GL_ACCUM_ALPHA_BITS: - *params = (GLint) ctx->Visual->AccumBits; + *params = (GLint) ctx->Visual->AccumAlphaBits; break; case GL_ACCUM_CLEAR_VALUE: params[0] = FLOAT_TO_INT( ctx->Accum.ClearColor[0] ); @@ -3184,6 +3747,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) case GL_GREEN_SCALE: *params = (GLint) ctx->Pixel.GreenScale; break; + case GL_HISTOGRAM: + *params = (GLint) ctx->Pixel.HistogramEnabled; + break; case GL_INDEX_BITS: *params = (GLint) ctx->Visual->IndexBits; break; @@ -3405,6 +3971,9 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) params[0] = (GLint) MAX_WIDTH; params[1] = (GLint) MAX_HEIGHT; break; + case GL_MINMAX: + *params = (GLint) ctx->Pixel.MinMaxEnabled; + break; case GL_MODELVIEW_MATRIX: for (i=0;i<16;i++) { params[i] = (GLint) ctx->ModelView.m[i]; @@ -3477,7 +4046,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = ctx->Pixel.MapStoSsize; break; case GL_POINT_SIZE: - *params = (GLint) ctx->Point.Size; + *params = (GLint) ctx->Point.UserSize; break; case GL_POINT_SIZE_GRANULARITY: *params = (GLint) ctx->Const.PointSizeGranularity; @@ -3774,6 +4343,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = 0; break; + /* GL_ARB_multitexture */ case GL_MAX_TEXTURE_UNITS_ARB: *params = ctx->Const.MaxTextureUnits; break; @@ -3784,6 +4354,51 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = GL_TEXTURE0_ARB + ctx->Array.ActiveTexture; break; + /* GL_ARB_texture_cube_map */ + case GL_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = (GLint) _mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB); + else + gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv"); + return; + case GL_TEXTURE_BINDING_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = textureUnit->CurrentCubeMap->Name; + else + gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv"); + return; + case GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + *params = ctx->Const.MaxCubeTextureSize; + else + gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv"); + return; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSION_HINT_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = (GLint) ctx->Hint.TextureCompression; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv"); + break; + case GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = (GLint) ctx->Const.NumCompressedTextureFormats; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv"); + break; + case GL_COMPRESSED_TEXTURE_FORMATS_ARB: + if (ctx->Extensions.HaveTextureCompression) { + GLuint i; + for (i = 0; i < ctx->Const.NumCompressedTextureFormats; i++) + params[i] = (GLint) ctx->Const.CompressedTextureFormats[i]; + } + else + gl_error(ctx, GL_INVALID_ENUM, "glGetIntegerv"); + break; + /* GL_PGI_misc_hints */ case GL_STRICT_DEPTHFUNC_HINT_PGI: *params = (GL_NICEST); @@ -3793,19 +4408,19 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) break; case GL_STRICT_SCISSOR_HINT_PGI: case GL_FULL_STIPPLE_HINT_PGI: - *params = (GL_TRUE); + *params = GL_TRUE; break; case GL_CONSERVE_MEMORY_HINT_PGI: - *params = (GL_FALSE); + *params = GL_FALSE; break; case GL_ALWAYS_FAST_HINT_PGI: *params = (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_FALSE && + ctx->Hint.AllowDrawFrg == GL_FALSE && ctx->Hint.AllowDrawMem == GL_FALSE); break; case GL_ALWAYS_SOFT_HINT_PGI: *params = (ctx->Hint.AllowDrawWin == GL_TRUE && - ctx->Hint.AllowDrawSpn == GL_TRUE && + ctx->Hint.AllowDrawFrg == GL_TRUE && ctx->Hint.AllowDrawMem == GL_TRUE); break; case GL_ALLOW_DRAW_OBJ_HINT_PGI: @@ -3814,8 +4429,8 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) case GL_ALLOW_DRAW_WIN_HINT_PGI: *params = ctx->Hint.AllowDrawWin; break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - *params = ctx->Hint.AllowDrawSpn; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + *params = ctx->Hint.AllowDrawFrg; break; case GL_ALLOW_DRAW_MEM_HINT_PGI: *params = ctx->Hint.AllowDrawMem; @@ -3828,7 +4443,7 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) *params = GL_DONT_CARE; break; case GL_BACK_NORMALS_HINT_PGI: - *params = (GL_TRUE); + *params = GL_TRUE; break; case GL_NATIVE_GRAPHICS_HANDLE_PGI: *params = 0; @@ -3844,7 +4459,14 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) /* GL_ARB_transpose_matrix */ case GL_TRANSPOSE_COLOR_MATRIX_ARB: - /* don't have a color matrix */ + { + GLfloat tm[16]; + GLuint i; + gl_matrix_transposef(tm, ctx->ColorMatrix.m); + for (i=0;i<16;i++) { + params[i] = (GLint) tm[i]; + } + } break; case GL_TRANSPOSE_MODELVIEW_MATRIX_ARB: { @@ -3877,8 +4499,124 @@ _mesa_GetIntegerv( GLenum pname, GLint *params ) } break; + /* GL_HP_occlusion_test */ + case GL_OCCLUSION_TEST_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + *params = (GLint) ctx->Depth.OcclusionTest; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" ); + } + return; + case GL_OCCLUSION_TEST_RESULT_HP: + if (ctx->Extensions.HaveHpOcclusionTest) { + if (ctx->Depth.OcclusionTest) + *params = (GLint) ctx->OcclusionResult; + else + *params = (GLint) ctx->OcclusionResultSaved; + /* reset flag now */ + ctx->OcclusionResult = GL_FALSE; + ctx->OcclusionResultSaved = GL_FALSE; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" ); + } + return; + + /* GL_SGIS_pixel_texture */ + case GL_PIXEL_TEXTURE_SGIS: + *params = (GLint) ctx->Pixel.PixelTextureEnabled; + break; + + /* GL_SGIX_pixel_texture */ + case GL_PIXEL_TEX_GEN_SGIX: + *params = (GLint) ctx->Pixel.PixelTextureEnabled; + break; + case GL_PIXEL_TEX_GEN_MODE_SGIX: + *params = (GLint) pixel_texgen_mode(ctx); + break; + + /* GL_SGI_color_matrix (also in 1.2 imaging) */ + case GL_COLOR_MATRIX_SGI: + for (i=0;i<16;i++) { + params[i] = (GLint) ctx->ColorMatrix.m[i]; + } + break; + case GL_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = ctx->ColorStackDepth + 1; + break; + case GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI: + *params = MAX_COLOR_STACK_DEPTH; + break; + case GL_POST_COLOR_MATRIX_RED_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixScale[0]; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixScale[1]; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixScale[2]; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixScale[3]; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixBias[0]; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixBias[1]; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixBias[2]; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixBias[3]; + break; + + /* GL_EXT_convolution (also in 1.2 imaging) */ + case GL_MAX_CONVOLUTION_WIDTH: + *params = ctx->Const.MaxConvolutionWidth; + break; + case GL_MAX_CONVOLUTION_HEIGHT: + *params = ctx->Const.MaxConvolutionHeight; + break; + case GL_POST_CONVOLUTION_RED_SCALE_EXT: + *params = (GLint) ctx->Pixel.PostConvolutionScale[0]; + break; + case GL_POST_CONVOLUTION_GREEN_SCALE_EXT: + *params = (GLint) ctx->Pixel.PostConvolutionScale[1]; + break; + case GL_POST_CONVOLUTION_BLUE_SCALE_EXT: + *params = (GLint) ctx->Pixel.PostConvolutionScale[2]; + break; + case GL_POST_CONVOLUTION_ALPHA_SCALE_EXT: + *params = (GLint) ctx->Pixel.PostConvolutionScale[3]; + break; + case GL_POST_CONVOLUTION_RED_BIAS_EXT: + *params = (GLint) ctx->Pixel.PostConvolutionBias[0]; + break; + case GL_POST_CONVOLUTION_GREEN_BIAS_EXT: + *params = (GLint) ctx->Pixel.PostConvolutionBias[1]; + break; + case GL_POST_CONVOLUTION_BLUE_BIAS_EXT: + *params = (GLint) ctx->Pixel.PostConvolutionBias[2]; + break; + case GL_POST_CONVOLUTION_ALPHA_BIAS_EXT: + *params = (GLint) ctx->Pixel.PostConvolutionBias[2]; + break; + + /* GL_SGI_color_table (also in 1.2 imaging */ + case GL_COLOR_TABLE_SGI: + *params = (GLint) ctx->Pixel.ColorTableEnabled; + break; + case GL_POST_CONVOLUTION_COLOR_TABLE_SGI: + *params = (GLint) ctx->Pixel.PostConvolutionColorTableEnabled; + break; + case GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI: + *params = (GLint) ctx->Pixel.PostColorMatrixColorTableEnabled; + break; + default: - printf("invalid enum: %x\n", pname); gl_error( ctx, GL_INVALID_ENUM, "glGetIntegerv" ); } } diff --git a/xc/extras/Mesa/src/glapi.c b/xc/extras/Mesa/src/glapi.c index 5f5fc6de1..c3ac458cb 100644 --- a/xc/extras/Mesa/src/glapi.c +++ b/xc/extras/Mesa/src/glapi.c @@ -72,6 +72,18 @@ static _glthread_TSD ContextTSD; static GLuint MaxDispatchOffset = sizeof(struct _glapi_table) / sizeof(void *) - 1; static GLboolean GetSizeCalled = GL_FALSE; +/* strdup is actually not a standard ANSI C or POSIX routine + Irix will not define it if ANSI mode is in effect. */ +static char *str_dup(const char *str) +{ + char *copy; + copy = (char*) malloc(strlen(str) + 1); + if (!copy) + return NULL; + strcpy(copy, str); + return copy; +} + /* @@ -222,354 +234,6 @@ _glapi_get_version(void) } -struct name_address_offset { - const char *Name; - GLvoid *Address; - GLuint Offset; -}; - -static struct name_address_offset static_functions[1000]; - - - -/* - * Return dispatch table offset of the named static (built-in) function. - * Return -1 if function not found. - */ -static GLint -get_static_proc_offset(const char *funcName) -{ - GLuint i; - for (i = 0; static_functions[i].Name; i++) { - if (strcmp(static_functions[i].Name, funcName) == 0) { - return static_functions[i].Offset; - } - } - return -1; -} - - -/* - * Return dispatch function address the named static (built-in) function. - * Return NULL if function not found. - */ -static GLvoid * -get_static_proc_address(const char *funcName) -{ - GLint i = get_static_proc_offset(funcName); - if (i >= 0) - return static_functions[i].Address; - else - return NULL; -} - - - -/********************************************************************** - * Extension function management. - */ - - -#define MAX_EXTENSION_FUNCS 1000 - -static struct name_address_offset ExtEntryTable[MAX_EXTENSION_FUNCS]; -static GLuint NumExtEntryPoints = 0; - - - -/* - * Generate a dispatch function (entrypoint) which jumps through - * the given slot number (offset) in the current dispatch table. - * We need assembly language in order to accomplish this. - */ -static void * -generate_entrypoint(GLuint functionOffset) -{ -#if defined(USE_X86_ASM) - /* - * This x86 code contributed by Josh Vanderhoof. - * - * 0: a1 10 32 54 76 movl __glapi_Dispatch,%eax - * 00 01 02 03 04 - * 5: 85 c0 testl %eax,%eax - * 05 06 - * 7: 74 06 je f <entrypoint+0xf> - * 07 08 - * 9: ff a0 10 32 54 76 jmp *0x76543210(%eax) - * 09 0a 0b 0c 0d 0e - * f: e8 fc ff ff ff call __glapi_get_dispatch - * 0f 10 11 12 13 - * 14: ff a0 10 32 54 76 jmp *0x76543210(%eax) - * 14 15 16 17 18 19 - */ - static const unsigned char temp[] = { - 0xa1, 0x00, 0x00, 0x00, 0x00, - 0x85, 0xc0, - 0x74, 0x06, - 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00, - 0xe8, 0x00, 0x00, 0x00, 0x00, - 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00 - }; - unsigned char *code = malloc(sizeof(temp)); - unsigned int next_insn; - if (code) { - memcpy(code, temp, sizeof(temp)); - - *(unsigned int *)(code + 0x01) = (unsigned int)&_glapi_Dispatch; - *(unsigned int *)(code + 0x0b) = (unsigned int)functionOffset * 4; - next_insn = (unsigned int)(code + 0x14); - *(unsigned int *)(code + 0x10) = (unsigned int)_glapi_get_dispatch - next_insn; - *(unsigned int *)(code + 0x16) = (unsigned int)functionOffset * 4; - } - return code; -#else - return NULL; -#endif -} - - - -/* - * Add a new extension function entrypoint. - * Return: GL_TRUE = success or GL_FALSE = failure - */ -GLboolean -_glapi_add_entrypoint(const char *funcName, GLuint offset) -{ - /* Make sure we don't try to add a new entrypoint after someone - * has already called _glapi_get_dispatch_table_size()! If that's - * happened the caller's information will now be out of date. - */ - assert(!GetSizeCalled); - - /* first check if the named function is already statically present */ - { - GLint index = get_static_proc_offset(funcName); - if (index >= 0) { - return (GLboolean) (index == offset); /* bad offset! */ - } - } - - { - /* make sure this offset/name pair is legal */ - const char *name = _glapi_get_proc_name(offset); - if (name && strcmp(name, funcName) != 0) - return GL_FALSE; /* bad name! */ - } - - { - /* be sure index and name match known data */ - GLuint i; - for (i = 0; i < NumExtEntryPoints; i++) { - if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { - /* function already registered with api */ - if (ExtEntryTable[i].Offset == offset) { - return GL_TRUE; /* offsets match */ - } - else { - return GL_FALSE; /* bad offset! */ - } - } - } - - /* make sure we have space */ - if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS) { - return GL_FALSE; - } - else { - void *entrypoint = generate_entrypoint(offset); - if (!entrypoint) - return GL_FALSE; - - ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName); - ExtEntryTable[NumExtEntryPoints].Offset = offset; - ExtEntryTable[NumExtEntryPoints].Address = entrypoint; - NumExtEntryPoints++; - - if (offset > MaxDispatchOffset) - MaxDispatchOffset = offset; - - return GL_TRUE; /* success */ - } - } - - /* should never get here, but play it safe */ - return GL_FALSE; -} - - - -#if 0000 /* prototype code for dynamic extension slot allocation */ - -static int NextFreeOffset = 409; /*XXX*/ -#define MAX_DISPATCH_TABLE_SIZE 1000 - -/* - * Dynamically allocate a dispatch slot for an extension entrypoint - * and generate the assembly language dispatch stub. - * Return the dispatch offset for the function or -1 if no room or error. - */ -GLint -_glapi_add_entrypoint2(const char *funcName) -{ - int offset; - - /* first see if extension func is already known */ - offset = _glapi_get_proc_offset(funcName); - if (offset >= 0) - return offset; - - if (NumExtEntryPoints < MAX_EXTENSION_FUNCS - && NextFreeOffset < MAX_DISPATCH_TABLE_SIZE) { - void *entryPoint; - offset = NextFreeOffset; - entryPoint = generate_entrypoint(offset); - if (entryPoint) { - NextFreeOffset++; - ExtEntryTable[NumExtEntryPoints].Name = strdup(funcName); - ExtEntryTable[NumExtEntryPoints].Offset = offset; - ExtEntryTable[NumExtEntryPoints].Address = entryPoint; - NumExtEntryPoints++; - return offset; - } - } - return -1; -} - -#endif - - - -/* - * Return offset of entrypoint for named function within dispatch table. - */ -GLint -_glapi_get_proc_offset(const char *funcName) -{ - /* search extension functions first */ - GLint i; - for (i = 0; i < NumExtEntryPoints; i++) { - if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { - return ExtEntryTable[i].Offset; - } - } - - /* search static functions */ - return get_static_proc_offset(funcName); -} - - - -/* - * Return entrypoint for named function. - */ -const GLvoid * -_glapi_get_proc_address(const char *funcName) -{ - /* search extension functions first */ - GLint i; - for (i = 0; i < NumExtEntryPoints; i++) { - if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { - return ExtEntryTable[i].Address; - } - } - - /* search static functions */ - return get_static_proc_address(funcName); -} - - - - -/* - * Return the name of the function at the given dispatch offset. - * This is only intended for debugging. - */ -const char * -_glapi_get_proc_name(GLuint offset) -{ - const GLuint n = sizeof(static_functions) / sizeof(struct name_address_offset); - GLuint i; - for (i = 0; i < n; i++) { - if (static_functions[i].Offset == offset) - return static_functions[i].Name; - } - - /* search added extension functions */ - for (i = 0; i < NumExtEntryPoints; i++) { - if (ExtEntryTable[i].Offset == offset) { - return ExtEntryTable[i].Name; - } - } - return NULL; -} - - - -/* - * Make sure there are no NULL pointers in the given dispatch table. - * Intented for debugging purposes. - */ -void -_glapi_check_table(const struct _glapi_table *table) -{ - const GLuint entries = _glapi_get_dispatch_table_size(); - const void **tab = (const void **) table; - GLuint i; - for (i = 1; i < entries; i++) { - assert(tab[i]); - } - -#ifdef DEBUG - /* Do some spot checks to be sure that the dispatch table - * slots are assigned correctly. - */ - { - GLuint BeginOffset = _glapi_get_proc_offset("glBegin"); - char *BeginFunc = (char*) &table->Begin; - GLuint offset = (BeginFunc - (char *) table) / sizeof(void *); - assert(BeginOffset == _gloffset_Begin); - assert(BeginOffset == offset); - } - { - GLuint viewportOffset = _glapi_get_proc_offset("glViewport"); - char *viewportFunc = (char*) &table->Viewport; - GLuint offset = (viewportFunc - (char *) table) / sizeof(void *); - assert(viewportOffset == _gloffset_Viewport); - assert(viewportOffset == offset); - } - { - GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer"); - char *VertexPointerFunc = (char*) &table->VertexPointer; - GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *); - assert(VertexPointerOffset == _gloffset_VertexPointer); - assert(VertexPointerOffset == offset); - } - { - GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax"); - char *ResetMinMaxFunc = (char*) &table->ResetMinmax; - GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *); - assert(ResetMinMaxOffset == _gloffset_ResetMinmax); - assert(ResetMinMaxOffset == offset); - } - { - GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor"); - char *blendColorFunc = (char*) &table->BlendColor; - GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *); - assert(blendColorOffset == _gloffset_BlendColor); - assert(blendColorOffset == offset); - } - { - GLuint istextureOffset = _glapi_get_proc_offset("glIsTextureEXT"); - char *istextureFunc = (char*) &table->IsTextureEXT; - GLuint offset = (istextureFunc - (char *) table) / sizeof(void *); - assert(istextureOffset == _gloffset_IsTextureEXT); - assert(istextureOffset == offset); - } -#endif -} - - /* * For each entry in static_functions[] which use this function * we should implement a dispatch function in glapitemp.h and @@ -581,6 +245,12 @@ static int NotImplemented(void) } +struct name_address_offset { + const char *Name; + GLvoid *Address; + GLuint Offset; +}; + static struct name_address_offset static_functions[] = { /* GL 1.1 */ @@ -923,7 +593,7 @@ static struct name_address_offset static_functions[] = { { "glPushClientAttrib", (GLvoid *) glPushClientAttrib, _gloffset_PushClientAttrib }, /* 1.2 */ #ifdef GL_VERSION_1_2 -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else #define NAME(X) NotImplemented #endif @@ -967,9 +637,9 @@ static struct name_address_offset static_functions[] = { { "glCopyTexSubImage3D", (GLvoid *) NAME(glCopyTexSubImage3D), _gloffset_CopyTexSubImage3D }, #undef NAME - /* GL_ARB_multitexture */ + /* ARB 1. GL_ARB_multitexture */ #ifdef GL_ARB_multitexture -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else #define NAME(X) NotImplemented #endif @@ -1009,9 +679,9 @@ static struct name_address_offset static_functions[] = { { "glMultiTexCoord4svARB", (GLvoid *) NAME(glMultiTexCoord4svARB), _gloffset_MultiTexCoord4svARB }, #undef NAME - /* GL_ARB_transpose_matrix */ + /* ARB 3. GL_ARB_transpose_matrix */ #ifdef GL_ARB_transpose_matrix -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else #define NAME(X) NotImplemented #endif @@ -1021,504 +691,1107 @@ static struct name_address_offset static_functions[] = { { "glMultTransposeMatrixfARB", (GLvoid *) NAME(glMultTransposeMatrixfARB), _gloffset_MultTransposeMatrixfARB }, #undef NAME - /* GL_ARB_multisample */ + /* ARB 5. GL_ARB_multisample */ #ifdef GL_ARB_multisample -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glSampleCoverageARB", (GLvoid *) NAME(glSampleCoverageARB), _gloffset_SampleCoverageARB }, - { "glSamplePassARB", (GLvoid *) NAME(glSamplePassARB), _gloffset_SamplePassARB }, + { "glSamplePassARB", NAME(glSamplePassARB), _gloffset_SamplePassARB }, + { "glSampleCoverageARB", NAME(glSampleCoverageARB), _gloffset_SampleCoverageARB }, #undef NAME + /* ARB 12. GL_ARB_texture_compression */ +#if 000 +#if defined(GL_ARB_texture_compression) && defined(_gloffset_CompressedTexImage3DARB) +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glCompressedTexImage3DARB", NAME(glCompressedTexImage3DARB), _gloffset_CompressedTexImage3DARB }, + { "glCompressedTexImage2DARB", NAME(glCompressedTexImage2DARB), _gloffset_CompressedTexImage2DARB }, + { "glCompressedTexImage1DARB", NAME(glCompressedTexImage1DARB), _gloffset_CompressedTexImage1DARB }, + { "glCompressedTexSubImage3DARB", NAME(glCompressedTexSubImage3DARB), _gloffset_CompressedTexSubImage3DARB }, + { "glCompressedTexSubImage2DARB", NAME(glCompressedTexSubImage2DARB), _gloffset_CompressedTexSubImage2DARB }, + { "glCompressedTexSubImage1DARB", NAME(glCompressedTexSubImage1DARB), _gloffset_CompressedTexSubImage1DARB }, + { "glGetCompressedTexImageARB", NAME(glGetCompressedTexImageARB), _gloffset_GetCompressedTexImageARB }, +#undef NAME +#endif + /* 2. GL_EXT_blend_color */ #ifdef GL_EXT_blend_color -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glBlendColorEXT", (GLvoid *) NAME(glBlendColorEXT), _gloffset_BlendColor }, + { "glBlendColorEXT", NAME(glBlendColorEXT), _gloffset_BlendColor }, #undef NAME /* 3. GL_EXT_polygon_offset */ #ifdef GL_EXT_polygon_offset -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glPolygonOffsetEXT", (GLvoid *) NAME(glPolygonOffsetEXT), _gloffset_PolygonOffsetEXT }, + { "glPolygonOffsetEXT", NAME(glPolygonOffsetEXT), _gloffset_PolygonOffsetEXT }, #undef NAME /* 6. GL_EXT_texture3D */ #ifdef GL_EXT_texture3D -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glCopyTexSubImage3DEXT", (GLvoid *) NAME(glCopyTexSubImage3DEXT), _gloffset_CopyTexSubImage3D }, - { "glTexImage3DEXT", (GLvoid *) NAME(glTexImage3DEXT), _gloffset_TexImage3D }, - { "glTexSubImage3DEXT", (GLvoid *) NAME(glTexSubImage3DEXT), _gloffset_TexSubImage3D }, + { "glCopyTexSubImage3DEXT", NAME(glCopyTexSubImage3DEXT), _gloffset_CopyTexSubImage3D }, + { "glTexImage3DEXT", NAME(glTexImage3DEXT), _gloffset_TexImage3D }, + { "glTexSubImage3DEXT", NAME(glTexSubImage3DEXT), _gloffset_TexSubImage3D }, #undef NAME /* 7. GL_SGI_texture_filter4 */ #ifdef GL_SGI_texture_filter4 -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glGetTexFilterFuncSGIS", (GLvoid *) NAME(glGetTexFilterFuncSGIS), _gloffset_GetTexFilterFuncSGIS }, - { "glTexFilterFuncSGIS", (GLvoid *) NAME(glTexFilterFuncSGIS), _gloffset_TexFilterFuncSGIS }, + { "glGetTexFilterFuncSGIS", NAME(glGetTexFilterFuncSGIS), _gloffset_GetTexFilterFuncSGIS }, + { "glTexFilterFuncSGIS", NAME(glTexFilterFuncSGIS), _gloffset_TexFilterFuncSGIS }, #undef NAME /* 9. GL_EXT_subtexture */ #ifdef GL_EXT_subtexture -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glTexSubImage1DEXT", (GLvoid *) NAME(glTexSubImage1DEXT), _gloffset_TexSubImage1D }, - { "glTexSubImage2DEXT", (GLvoid *) NAME(glTexSubImage2DEXT), _gloffset_TexSubImage2D }, + { "glTexSubImage1DEXT", NAME(glTexSubImage1DEXT), _gloffset_TexSubImage1D }, + { "glTexSubImage2DEXT", NAME(glTexSubImage2DEXT), _gloffset_TexSubImage2D }, #undef NAME /* 10. GL_EXT_copy_texture */ #ifdef GL_EXT_copy_texture -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glCopyTexImage1DEXT", (GLvoid *) NAME(glCopyTexImage1DEXT), _gloffset_CopyTexImage1D }, - { "glCopyTexImage2DEXT", (GLvoid *) NAME(glCopyTexImage2DEXT), _gloffset_CopyTexImage2D }, - { "glCopyTexSubImage1DEXT", (GLvoid *) NAME(glCopyTexSubImage1DEXT), _gloffset_CopyTexSubImage1D }, - { "glCopyTexSubImage2DEXT", (GLvoid *) NAME(glCopyTexSubImage2DEXT), _gloffset_CopyTexSubImage2D }, + { "glCopyTexImage1DEXT", NAME(glCopyTexImage1DEXT), _gloffset_CopyTexImage1D }, + { "glCopyTexImage2DEXT", NAME(glCopyTexImage2DEXT), _gloffset_CopyTexImage2D }, + { "glCopyTexSubImage1DEXT", NAME(glCopyTexSubImage1DEXT), _gloffset_CopyTexSubImage1D }, + { "glCopyTexSubImage2DEXT", NAME(glCopyTexSubImage2DEXT), _gloffset_CopyTexSubImage2D }, #undef NAME /* 11. GL_EXT_histogram */ #ifdef GL_EXT_histogram -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glGetHistogramEXT", (GLvoid *) NAME(glGetHistogramEXT), _gloffset_GetHistogramEXT }, - { "glGetHistogramParameterfvEXT", (GLvoid *) NAME(glGetHistogramParameterfvEXT), _gloffset_GetHistogramParameterfvEXT }, - { "glGetHistogramParameterivEXT", (GLvoid *) NAME(glGetHistogramParameterivEXT), _gloffset_GetHistogramParameterivEXT }, - { "glGetMinmaxEXT", (GLvoid *) NAME(glGetMinmaxEXT), _gloffset_GetMinmaxEXT }, - { "glGetMinmaxParameterfvEXT", (GLvoid *) NAME(glGetMinmaxParameterfvEXT), _gloffset_GetMinmaxParameterfvEXT }, - { "glGetMinmaxParameterivEXT", (GLvoid *) NAME(glGetMinmaxParameterivEXT), _gloffset_GetMinmaxParameterivEXT }, - { "glHistogramEXT", (GLvoid *) NAME(glHistogramEXT), _gloffset_Histogram }, - { "glMinmaxEXT", (GLvoid *) NAME(glMinmaxEXT), _gloffset_Minmax }, - { "glResetHistogramEXT", (GLvoid *) NAME(glResetHistogramEXT), _gloffset_ResetHistogram }, - { "glResetMinmaxEXT", (GLvoid *) NAME(glResetMinmaxEXT), _gloffset_ResetMinmax }, + { "glGetHistogramEXT", NAME(glGetHistogramEXT), _gloffset_GetHistogramEXT }, + { "glGetHistogramParameterfvEXT", NAME(glGetHistogramParameterfvEXT), _gloffset_GetHistogramParameterfvEXT }, + { "glGetHistogramParameterivEXT", NAME(glGetHistogramParameterivEXT), _gloffset_GetHistogramParameterivEXT }, + { "glGetMinmaxEXT", NAME(glGetMinmaxEXT), _gloffset_GetMinmaxEXT }, + { "glGetMinmaxParameterfvEXT", NAME(glGetMinmaxParameterfvEXT), _gloffset_GetMinmaxParameterfvEXT }, + { "glGetMinmaxParameterivEXT", NAME(glGetMinmaxParameterivEXT), _gloffset_GetMinmaxParameterivEXT }, + { "glHistogramEXT", NAME(glHistogramEXT), _gloffset_Histogram }, + { "glMinmaxEXT", NAME(glMinmaxEXT), _gloffset_Minmax }, + { "glResetHistogramEXT", NAME(glResetHistogramEXT), _gloffset_ResetHistogram }, + { "glResetMinmaxEXT", NAME(glResetMinmaxEXT), _gloffset_ResetMinmax }, #undef NAME /* 12. GL_EXT_convolution */ #ifdef GL_EXT_convolution -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glConvolutionFilter1DEXT", (GLvoid *) NAME(glConvolutionFilter1DEXT), _gloffset_ConvolutionFilter1D }, - { "glConvolutionFilter2DEXT", (GLvoid *) NAME(glConvolutionFilter2DEXT), _gloffset_ConvolutionFilter2D }, - { "glConvolutionParameterfEXT", (GLvoid *) NAME(glConvolutionParameterfEXT), _gloffset_ConvolutionParameterf }, - { "glConvolutionParameterfvEXT", (GLvoid *) NAME(glConvolutionParameterfvEXT), _gloffset_ConvolutionParameterfv }, - { "glConvolutionParameteriEXT", (GLvoid *) NAME(glConvolutionParameteriEXT), _gloffset_ConvolutionParameteri }, - { "glConvolutionParameterivEXT", (GLvoid *) NAME(glConvolutionParameterivEXT), _gloffset_ConvolutionParameteriv }, - { "glCopyConvolutionFilter1DEXT", (GLvoid *) NAME(glCopyConvolutionFilter1DEXT), _gloffset_CopyConvolutionFilter1D }, - { "glCopyConvolutionFilter2DEXT", (GLvoid *) NAME(glCopyConvolutionFilter2DEXT), _gloffset_CopyConvolutionFilter2D }, - { "glGetConvolutionFilterEXT", (GLvoid *) NAME(glGetConvolutionFilterEXT), _gloffset_GetConvolutionFilterEXT }, - { "glGetConvolutionParameterivEXT", (GLvoid *) NAME(glGetConvolutionParameterivEXT), _gloffset_GetConvolutionParameterivEXT }, - { "glGetConvolutionParameterfvEXT", (GLvoid *) NAME(glGetConvolutionParameterfvEXT), _gloffset_GetConvolutionParameterfvEXT }, - { "glGetSeparableFilterEXT", (GLvoid *) NAME(glGetSeparableFilterEXT), _gloffset_GetSeparableFilterEXT }, - { "glSeparableFilter2DEXT", (GLvoid *) NAME(glSeparableFilter2DEXT), _gloffset_SeparableFilter2D }, + { "glConvolutionFilter1DEXT", NAME(glConvolutionFilter1DEXT), _gloffset_ConvolutionFilter1D }, + { "glConvolutionFilter2DEXT", NAME(glConvolutionFilter2DEXT), _gloffset_ConvolutionFilter2D }, + { "glConvolutionParameterfEXT", NAME(glConvolutionParameterfEXT), _gloffset_ConvolutionParameterf }, + { "glConvolutionParameterfvEXT", NAME(glConvolutionParameterfvEXT), _gloffset_ConvolutionParameterfv }, + { "glConvolutionParameteriEXT", NAME(glConvolutionParameteriEXT), _gloffset_ConvolutionParameteri }, + { "glConvolutionParameterivEXT", NAME(glConvolutionParameterivEXT), _gloffset_ConvolutionParameteriv }, + { "glCopyConvolutionFilter1DEXT", NAME(glCopyConvolutionFilter1DEXT), _gloffset_CopyConvolutionFilter1D }, + { "glCopyConvolutionFilter2DEXT", NAME(glCopyConvolutionFilter2DEXT), _gloffset_CopyConvolutionFilter2D }, + { "glGetConvolutionFilterEXT", NAME(glGetConvolutionFilterEXT), _gloffset_GetConvolutionFilterEXT }, + { "glGetConvolutionParameterivEXT", NAME(glGetConvolutionParameterivEXT), _gloffset_GetConvolutionParameterivEXT }, + { "glGetConvolutionParameterfvEXT", NAME(glGetConvolutionParameterfvEXT), _gloffset_GetConvolutionParameterfvEXT }, + { "glGetSeparableFilterEXT", NAME(glGetSeparableFilterEXT), _gloffset_GetSeparableFilterEXT }, + { "glSeparableFilter2DEXT", NAME(glSeparableFilter2DEXT), _gloffset_SeparableFilter2D }, #undef NAME /* 14. GL_SGI_color_table */ #ifdef GL_SGI_color_table -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glColorTableSGI", (GLvoid *) NAME(glColorTableSGI), _gloffset_ColorTable }, - { "glColorTableParameterfvSGI", (GLvoid *) NAME(glColorTableParameterfvSGI), _gloffset_ColorTableParameterfv }, - { "glColorTableParameterivSGI", (GLvoid *) NAME(glColorTableParameterivSGI), _gloffset_ColorTableParameteriv }, - { "glCopyColorTableSGI", (GLvoid *) NAME(glCopyColorTableSGI), _gloffset_CopyColorTable }, - { "glGetColorTableSGI", (GLvoid *) NAME(glGetColorTableSGI), _gloffset_GetColorTableSGI }, - { "glGetColorTableParameterfvSGI", (GLvoid *) NAME(glGetColorTableParameterfvSGI), _gloffset_GetColorTableParameterfvSGI }, - { "glGetColorTableParameterivSGI", (GLvoid *) NAME(glGetColorTableParameterivSGI), _gloffset_GetColorTableParameterivSGI }, + { "glColorTableSGI", NAME(glColorTableSGI), _gloffset_ColorTable }, + { "glColorTableParameterfvSGI", NAME(glColorTableParameterfvSGI), _gloffset_ColorTableParameterfv }, + { "glColorTableParameterivSGI", NAME(glColorTableParameterivSGI), _gloffset_ColorTableParameteriv }, + { "glCopyColorTableSGI", NAME(glCopyColorTableSGI), _gloffset_CopyColorTable }, + { "glGetColorTableSGI", NAME(glGetColorTableSGI), _gloffset_GetColorTableSGI }, + { "glGetColorTableParameterfvSGI", NAME(glGetColorTableParameterfvSGI), _gloffset_GetColorTableParameterfvSGI }, + { "glGetColorTableParameterivSGI", NAME(glGetColorTableParameterivSGI), _gloffset_GetColorTableParameterivSGI }, #undef NAME /* 15. GL_SGIS_pixel_texture */ #ifdef GL_SGIS_pixel_texture -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glPixelTexGenParameterfSGIS", (GLvoid *) NAME(glPixelTexGenParameterfSGIS), _gloffset_PixelTexGenParameterfSGIS }, - { "glPixelTexGenParameteriSGIS", (GLvoid *) NAME(glPixelTexGenParameteriSGIS), _gloffset_PixelTexGenParameteriSGIS }, - { "glGetPixelTexGenParameterfvSGIS", (GLvoid *) NAME(glGetPixelTexGenParameterfvSGIS), _gloffset_GetPixelTexGenParameterfvSGIS }, - { "glGetPixelTexGenParameterivSGIS", (GLvoid *) NAME(glGetPixelTexGenParameterivSGIS), _gloffset_GetPixelTexGenParameterivSGIS }, + { "glPixelTexGenParameterfSGIS", NAME(glPixelTexGenParameterfSGIS), _gloffset_PixelTexGenParameterfSGIS }, + { "glPixelTexGenParameteriSGIS", NAME(glPixelTexGenParameteriSGIS), _gloffset_PixelTexGenParameteriSGIS }, + { "glGetPixelTexGenParameterfvSGIS", NAME(glGetPixelTexGenParameterfvSGIS), _gloffset_GetPixelTexGenParameterfvSGIS }, + { "glGetPixelTexGenParameterivSGIS", NAME(glGetPixelTexGenParameterivSGIS), _gloffset_GetPixelTexGenParameterivSGIS }, #undef NAME /* 16. GL_SGIS_texture4D */ #ifdef GL_SGIS_texture4D -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glTexImage4DSGIS", (GLvoid *) NAME(glTexImage4DSGIS), _gloffset_TexImage4DSGIS }, - { "glTexSubImage4DSGIS", (GLvoid *) NAME(glTexSubImage4DSGIS), _gloffset_TexSubImage4DSGIS }, + { "glTexImage4DSGIS", NAME(glTexImage4DSGIS), _gloffset_TexImage4DSGIS }, + { "glTexSubImage4DSGIS", NAME(glTexSubImage4DSGIS), _gloffset_TexSubImage4DSGIS }, #undef NAME /* 20. GL_EXT_texture_object */ #ifdef GL_EXT_texture_object -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glAreTexturesResidentEXT", (GLvoid *) NAME(glAreTexturesResidentEXT), _gloffset_AreTexturesResidentEXT }, - { "glBindTextureEXT", (GLvoid *) NAME(glBindTextureEXT), _gloffset_BindTexture }, - { "glDeleteTexturesEXT", (GLvoid *) NAME(glDeleteTexturesEXT), _gloffset_DeleteTextures }, - { "glGenTexturesEXT", (GLvoid *) NAME(glGenTexturesEXT), _gloffset_GenTexturesEXT }, - { "glIsTextureEXT", (GLvoid *) NAME(glIsTextureEXT), _gloffset_IsTextureEXT }, - { "glPrioritizeTexturesEXT", (GLvoid *) NAME(glPrioritizeTexturesEXT), _gloffset_PrioritizeTextures }, + { "glAreTexturesResidentEXT", NAME(glAreTexturesResidentEXT), _gloffset_AreTexturesResidentEXT }, + { "glBindTextureEXT", NAME(glBindTextureEXT), _gloffset_BindTexture }, + { "glDeleteTexturesEXT", NAME(glDeleteTexturesEXT), _gloffset_DeleteTextures }, + { "glGenTexturesEXT", NAME(glGenTexturesEXT), _gloffset_GenTexturesEXT }, + { "glIsTextureEXT", NAME(glIsTextureEXT), _gloffset_IsTextureEXT }, + { "glPrioritizeTexturesEXT", NAME(glPrioritizeTexturesEXT), _gloffset_PrioritizeTextures }, #undef NAME /* 21. GL_SGIS_detail_texture */ #ifdef GL_SGIS_detail_texture -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glDetailTexFuncSGIS", (GLvoid *) NAME(glDetailTexFuncSGIS), _gloffset_DetailTexFuncSGIS }, - { "glGetDetailTexFuncSGIS", (GLvoid *) NAME(glGetDetailTexFuncSGIS), _gloffset_GetDetailTexFuncSGIS }, + { "glDetailTexFuncSGIS", NAME(glDetailTexFuncSGIS), _gloffset_DetailTexFuncSGIS }, + { "glGetDetailTexFuncSGIS", NAME(glGetDetailTexFuncSGIS), _gloffset_GetDetailTexFuncSGIS }, #undef NAME /* 22. GL_SGIS_sharpen_texture */ #ifdef GL_SGIS_sharpen_texture -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glGetSharpenTexFuncSGIS", (GLvoid *) NAME(glGetSharpenTexFuncSGIS), _gloffset_GetSharpenTexFuncSGIS }, - { "glSharpenTexFuncSGIS", (GLvoid *) NAME(glSharpenTexFuncSGIS), _gloffset_SharpenTexFuncSGIS }, + { "glGetSharpenTexFuncSGIS", NAME(glGetSharpenTexFuncSGIS), _gloffset_GetSharpenTexFuncSGIS }, + { "glSharpenTexFuncSGIS", NAME(glSharpenTexFuncSGIS), _gloffset_SharpenTexFuncSGIS }, #undef NAME /* 25. GL_SGIS_multisample */ #ifdef GL_SGIS_multisample -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glSampleMaskSGIS", (GLvoid *) NAME(glSampleMaskSGIS), _gloffset_SampleMaskSGIS }, - { "glSamplePatternSGIS", (GLvoid *) NAME(glSamplePatternSGIS), _gloffset_SamplePatternSGIS }, + { "glSampleMaskSGIS", NAME(glSampleMaskSGIS), _gloffset_SampleMaskSGIS }, + { "glSamplePatternSGIS", NAME(glSamplePatternSGIS), _gloffset_SamplePatternSGIS }, #undef NAME /* 30. GL_EXT_vertex_array */ #ifdef GL_EXT_vertex_array -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glArrayElementEXT", (GLvoid *) NAME(glArrayElementEXT), _gloffset_ArrayElement }, - { "glColorPointerEXT", (GLvoid *) NAME(glColorPointerEXT), _gloffset_ColorPointerEXT }, - { "glDrawArraysEXT", (GLvoid *) NAME(glDrawArraysEXT), _gloffset_DrawArrays }, - { "glEdgeFlagPointerEXT", (GLvoid *) NAME(glEdgeFlagPointerEXT), _gloffset_EdgeFlagPointerEXT }, - { "glGetPointervEXT", (GLvoid *) NAME(glGetPointervEXT), _gloffset_GetPointerv }, - { "glIndexPointerEXT", (GLvoid *) NAME(glIndexPointerEXT), _gloffset_IndexPointerEXT }, - { "glNormalPointerEXT", (GLvoid *) NAME(glNormalPointerEXT), _gloffset_NormalPointerEXT }, - { "glTexCoordPointerEXT", (GLvoid *) NAME(glTexCoordPointerEXT), _gloffset_TexCoordPointerEXT }, - { "glVertexPointerEXT", (GLvoid *) NAME(glVertexPointerEXT), _gloffset_VertexPointerEXT }, + { "glArrayElementEXT", NAME(glArrayElementEXT), _gloffset_ArrayElement }, + { "glColorPointerEXT", NAME(glColorPointerEXT), _gloffset_ColorPointerEXT }, + { "glDrawArraysEXT", NAME(glDrawArraysEXT), _gloffset_DrawArrays }, + { "glEdgeFlagPointerEXT", NAME(glEdgeFlagPointerEXT), _gloffset_EdgeFlagPointerEXT }, + { "glGetPointervEXT", NAME(glGetPointervEXT), _gloffset_GetPointerv }, + { "glIndexPointerEXT", NAME(glIndexPointerEXT), _gloffset_IndexPointerEXT }, + { "glNormalPointerEXT", NAME(glNormalPointerEXT), _gloffset_NormalPointerEXT }, + { "glTexCoordPointerEXT", NAME(glTexCoordPointerEXT), _gloffset_TexCoordPointerEXT }, + { "glVertexPointerEXT", NAME(glVertexPointerEXT), _gloffset_VertexPointerEXT }, #undef NAME /* 37. GL_EXT_blend_minmax */ #ifdef GL_EXT_blend_minmax -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glBlendEquationEXT", (GLvoid *) NAME(glBlendEquationEXT), _gloffset_BlendEquation }, + { "glBlendEquationEXT", NAME(glBlendEquationEXT), _gloffset_BlendEquation }, #undef NAME /* 52. GL_SGIX_sprite */ #ifdef GL_SGIX_sprite -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glSpriteParameterfSGIX", (GLvoid *) NAME(glSpriteParameterfSGIX), _gloffset_SpriteParameterfSGIX }, - { "glSpriteParameterfvSGIX", (GLvoid *) NAME(glSpriteParameterfvSGIX), _gloffset_SpriteParameterfvSGIX }, - { "glSpriteParameteriSGIX", (GLvoid *) NAME(glSpriteParameteriSGIX), _gloffset_SpriteParameteriSGIX }, - { "glSpriteParameterivSGIX", (GLvoid *) NAME(glSpriteParameterivSGIX), _gloffset_SpriteParameterivSGIX }, + { "glSpriteParameterfSGIX", NAME(glSpriteParameterfSGIX), _gloffset_SpriteParameterfSGIX }, + { "glSpriteParameterfvSGIX", NAME(glSpriteParameterfvSGIX), _gloffset_SpriteParameterfvSGIX }, + { "glSpriteParameteriSGIX", NAME(glSpriteParameteriSGIX), _gloffset_SpriteParameteriSGIX }, + { "glSpriteParameterivSGIX", NAME(glSpriteParameterivSGIX), _gloffset_SpriteParameterivSGIX }, #undef NAME /* 54. GL_EXT_point_parameters */ #ifdef GL_EXT_point_parameters -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glPointParameterfEXT", (GLvoid *) NAME(glPointParameterfEXT), _gloffset_PointParameterfEXT }, - { "glPointParameterfvEXT", (GLvoid *) NAME(glPointParameterfvEXT), _gloffset_PointParameterfvEXT }, + { "glPointParameterfEXT", NAME(glPointParameterfEXT), _gloffset_PointParameterfEXT }, + { "glPointParameterfvEXT", NAME(glPointParameterfvEXT), _gloffset_PointParameterfvEXT }, + { "glPointParameterfSGIS", NAME(glPointParameterfSGIS), _gloffset_PointParameterfEXT }, + { "glPointParameterfvSGIS", NAME(glPointParameterfvSGIS), _gloffset_PointParameterfvEXT }, #undef NAME /* 55. GL_SGIX_instruments */ #ifdef GL_SGIX_instruments -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glInstrumentsBufferSGIX", (GLvoid *) NAME(glInstrumentsBufferSGIX), _gloffset_InstrumentsBufferSGIX }, - { "glStartInstrumentsSGIX", (GLvoid *) NAME(glStartInstrumentsSGIX), _gloffset_StartInstrumentsSGIX }, - { "glStopInstrumentsSGIX", (GLvoid *) NAME(glStopInstrumentsSGIX), _gloffset_StopInstrumentsSGIX }, - { "glReadInstrumentsSGIX", (GLvoid *) NAME(glReadInstrumentsSGIX), _gloffset_ReadInstrumentsSGIX }, - { "glPollInstrumentsSGIX", (GLvoid *) NAME(glPollInstrumentsSGIX), _gloffset_PollInstrumentsSGIX }, - { "glGetInstrumentsSGIX", (GLvoid *) NAME(glGetInstrumentsSGIX), _gloffset_GetInstrumentsSGIX }, + { "glInstrumentsBufferSGIX", NAME(glInstrumentsBufferSGIX), _gloffset_InstrumentsBufferSGIX }, + { "glStartInstrumentsSGIX", NAME(glStartInstrumentsSGIX), _gloffset_StartInstrumentsSGIX }, + { "glStopInstrumentsSGIX", NAME(glStopInstrumentsSGIX), _gloffset_StopInstrumentsSGIX }, + { "glReadInstrumentsSGIX", NAME(glReadInstrumentsSGIX), _gloffset_ReadInstrumentsSGIX }, + { "glPollInstrumentsSGIX", NAME(glPollInstrumentsSGIX), _gloffset_PollInstrumentsSGIX }, + { "glGetInstrumentsSGIX", NAME(glGetInstrumentsSGIX), _gloffset_GetInstrumentsSGIX }, #undef NAME /* 57. GL_SGIX_framezoom */ #ifdef GL_SGIX_framezoom -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glFrameZoomSGIX", (GLvoid *) NAME(glFrameZoomSGIX), _gloffset_FrameZoomSGIX }, + { "glFrameZoomSGIX", NAME(glFrameZoomSGIX), _gloffset_FrameZoomSGIX }, #undef NAME /* 58. GL_SGIX_tag_sample_buffer */ #ifdef GL_SGIX_tag_sample_buffer -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glTagSampleBufferSGIX", (GLvoid *) NAME(glTagSampleBufferSGIX), _gloffset_TagSampleBufferSGIX }, + { "glTagSampleBufferSGIX", NAME(glTagSampleBufferSGIX), _gloffset_TagSampleBufferSGIX }, #undef NAME /* 60. GL_SGIX_reference_plane */ #ifdef GL_SGIX_reference_plane -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glReferencePlaneSGIX", (GLvoid *) NAME(glReferencePlaneSGIX), _gloffset_ReferencePlaneSGIX }, + { "glReferencePlaneSGIX", NAME(glReferencePlaneSGIX), _gloffset_ReferencePlaneSGIX }, #undef NAME /* 61. GL_SGIX_flush_raster */ #ifdef GL_SGIX_flush_raster -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glFlushRasterSGIX", (GLvoid *) NAME(glFlushRasterSGIX), _gloffset_FlushRasterSGIX }, + { "glFlushRasterSGIX", NAME(glFlushRasterSGIX), _gloffset_FlushRasterSGIX }, #undef NAME /* 66. GL_HP_image_transform */ #if 0 #ifdef GL_HP_image_transform -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glGetImageTransformParameterfvHP", (GLvoid *) NAME(glGetImageTransformParameterfvHP), _gloffset_GetImageTransformParameterfvHP }, - { "glGetImageTransformParameterivHP", (GLvoid *) NAME(glGetImageTransformParameterivHP), _gloffset_GetImageTransformParameterivHP }, - { "glImageTransformParameterfHP", (GLvoid *) NAME(glImageTransformParameterfHP), _gloffset_ImageTransformParameterfHP }, - { "glImageTransformParameterfvHP", (GLvoid *) NAME(glImageTransformParameterfvHP), _gloffset_ImageTransformParameterfvHP }, - { "glImageTransformParameteriHP", (GLvoid *) NAME(glImageTransformParameteriHP), _gloffset_ImageTransformParameteriHP }, - { "glImageTransformParameterivHP", (GLvoid *) NAME(glImageTransformParameterivHP), _gloffset_ImageTransformParameterivHP }, + { "glGetImageTransformParameterfvHP", NAME(glGetImageTransformParameterfvHP), _gloffset_GetImageTransformParameterfvHP }, + { "glGetImageTransformParameterivHP", NAME(glGetImageTransformParameterivHP), _gloffset_GetImageTransformParameterivHP }, + { "glImageTransformParameterfHP", NAME(glImageTransformParameterfHP), _gloffset_ImageTransformParameterfHP }, + { "glImageTransformParameterfvHP", NAME(glImageTransformParameterfvHP), _gloffset_ImageTransformParameterfvHP }, + { "glImageTransformParameteriHP", NAME(glImageTransformParameteriHP), _gloffset_ImageTransformParameteriHP }, + { "glImageTransformParameterivHP", NAME(glImageTransformParameterivHP), _gloffset_ImageTransformParameterivHP }, #undef NAME #endif /* 74. GL_EXT_color_subtable */ #ifdef GL_EXT_color_subtable -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glColorSubTableEXT", (GLvoid *) NAME(glColorSubTableEXT), _gloffset_ColorSubTable }, - { "glCopyColorSubTableEXT", (GLvoid *) NAME(glCopyColorSubTableEXT), _gloffset_CopyColorSubTable }, + { "glColorSubTableEXT", NAME(glColorSubTableEXT), _gloffset_ColorSubTable }, + { "glCopyColorSubTableEXT", NAME(glCopyColorSubTableEXT), _gloffset_CopyColorSubTable }, #undef NAME /* 77. GL_PGI_misc_hints */ #ifdef GL_PGI_misc_hints -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glHintPGI", (GLvoid *) NAME(glHintPGI), _gloffset_HintPGI }, + { "glHintPGI", NAME(glHintPGI), _gloffset_HintPGI }, #undef NAME /* 78. GL_EXT_paletted_texture */ #ifdef GL_EXT_paletted_texture -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glColorTableEXT", (GLvoid *) NAME(glColorTableEXT), _gloffset_ColorTable }, - { "glGetColorTableEXT", (GLvoid *) NAME(glGetColorTableEXT), _gloffset_GetColorTable }, - { "glGetColorTableParameterfvEXT", (GLvoid *) NAME(glGetColorTableParameterfvEXT), _gloffset_GetColorTableParameterfv }, - { "glGetColorTableParameterivEXT", (GLvoid *) NAME(glGetColorTableParameterivEXT), _gloffset_GetColorTableParameteriv }, + { "glColorTableEXT", NAME(glColorTableEXT), _gloffset_ColorTable }, + { "glGetColorTableEXT", NAME(glGetColorTableEXT), _gloffset_GetColorTable }, + { "glGetColorTableParameterfvEXT", NAME(glGetColorTableParameterfvEXT), _gloffset_GetColorTableParameterfv }, + { "glGetColorTableParameterivEXT", NAME(glGetColorTableParameterivEXT), _gloffset_GetColorTableParameteriv }, #undef NAME /* 80. GL_SGIX_list_priority */ #ifdef GL_SGIX_list_priority -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glGetListParameterfvSGIX", (GLvoid *) NAME(glGetListParameterfvSGIX), _gloffset_GetListParameterfvSGIX }, - { "glGetListParameterivSGIX", (GLvoid *) NAME(glGetListParameterivSGIX), _gloffset_GetListParameterivSGIX }, - { "glListParameterfSGIX", (GLvoid *) NAME(glListParameterfSGIX), _gloffset_ListParameterfSGIX }, - { "glListParameterfvSGIX", (GLvoid *) NAME(glListParameterfvSGIX), _gloffset_ListParameterfvSGIX }, - { "glListParameteriSGIX", (GLvoid *) NAME(glListParameteriSGIX), _gloffset_ListParameteriSGIX }, - { "glListParameterivSGIX", (GLvoid *) NAME(glListParameterivSGIX), _gloffset_ListParameterivSGIX }, + { "glGetListParameterfvSGIX", NAME(glGetListParameterfvSGIX), _gloffset_GetListParameterfvSGIX }, + { "glGetListParameterivSGIX", NAME(glGetListParameterivSGIX), _gloffset_GetListParameterivSGIX }, + { "glListParameterfSGIX", NAME(glListParameterfSGIX), _gloffset_ListParameterfSGIX }, + { "glListParameterfvSGIX", NAME(glListParameterfvSGIX), _gloffset_ListParameterfvSGIX }, + { "glListParameteriSGIX", NAME(glListParameteriSGIX), _gloffset_ListParameteriSGIX }, + { "glListParameterivSGIX", NAME(glListParameterivSGIX), _gloffset_ListParameterivSGIX }, #undef NAME /* 94. GL_EXT_index_material */ #ifdef GL_EXT_index_material -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glIndexMaterialEXT", (GLvoid *) NAME(glIndexMaterialEXT), _gloffset_IndexMaterialEXT }, + { "glIndexMaterialEXT", NAME(glIndexMaterialEXT), _gloffset_IndexMaterialEXT }, #undef NAME /* 95. GL_EXT_index_func */ #ifdef GL_EXT_index_func -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glIndexFuncEXT", (GLvoid *) NAME(glIndexFuncEXT), _gloffset_IndexFuncEXT }, + { "glIndexFuncEXT", NAME(glIndexFuncEXT), _gloffset_IndexFuncEXT }, #undef NAME /* 97. GL_EXT_compiled_vertex_array */ #ifdef GL_EXT_compiled_vertex_array -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glLockArraysEXT", (GLvoid *) NAME(glLockArraysEXT), _gloffset_LockArraysEXT }, - { "glUnlockArraysEXT", (GLvoid *) NAME(glUnlockArraysEXT), _gloffset_UnlockArraysEXT }, + { "glLockArraysEXT", NAME(glLockArraysEXT), _gloffset_LockArraysEXT }, + { "glUnlockArraysEXT", NAME(glUnlockArraysEXT), _gloffset_UnlockArraysEXT }, #undef NAME /* 98. GL_EXT_cull_vertex */ #ifdef GL_EXT_cull_vertex -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glCullParameterfvEXT", (GLvoid *) NAME(glCullParameterfvEXT), _gloffset_CullParameterfvEXT }, - { "glCullParameterdvEXT", (GLvoid *) NAME(glCullParameterdvEXT), _gloffset_CullParameterdvEXT }, + { "glCullParameterfvEXT", NAME(glCullParameterfvEXT), _gloffset_CullParameterfvEXT }, + { "glCullParameterdvEXT", NAME(glCullParameterdvEXT), _gloffset_CullParameterdvEXT }, #undef NAME /* 102. GL_SGIX_fragment_lighting */ #ifdef GL_SGIX_fragment_lighting -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glFragmentColorMaterialSGIX", (GLvoid *) NAME(glFragmentColorMaterialSGIX), _gloffset_FragmentColorMaterialSGIX }, - { "glFragmentLightfSGIX", (GLvoid *) NAME(glFragmentLightfSGIX), _gloffset_FragmentLightfSGIX }, - { "glFragmentLightfvSGIX", (GLvoid *) NAME(glFragmentLightfvSGIX), _gloffset_FragmentLightfvSGIX }, - { "glFragmentLightiSGIX", (GLvoid *) NAME(glFragmentLightiSGIX), _gloffset_FragmentLightiSGIX }, - { "glFragmentLightivSGIX", (GLvoid *) NAME(glFragmentLightivSGIX), _gloffset_FragmentLightivSGIX }, - { "glFragmentLightModelfSGIX", (GLvoid *) NAME(glFragmentLightModelfSGIX), _gloffset_FragmentLightModelfSGIX }, - { "glFragmentLightModelfvSGIX", (GLvoid *) NAME(glFragmentLightModelfvSGIX), _gloffset_FragmentLightModelfvSGIX }, - { "glFragmentLightModeliSGIX", (GLvoid *) NAME(glFragmentLightModeliSGIX), _gloffset_FragmentLightModeliSGIX }, - { "glFragmentLightModelivSGIX", (GLvoid *) NAME(glFragmentLightModelivSGIX), _gloffset_FragmentLightModelivSGIX }, - { "glFragmentMaterialfSGIX", (GLvoid *) NAME(glFragmentMaterialfSGIX), _gloffset_FragmentMaterialfSGIX }, - { "glFragmentMaterialfvSGIX", (GLvoid *) NAME(glFragmentMaterialfvSGIX), _gloffset_FragmentMaterialfvSGIX }, - { "glFragmentMaterialiSGIX", (GLvoid *) NAME(glFragmentMaterialiSGIX), _gloffset_FragmentMaterialiSGIX }, - { "glFragmentMaterialivSGIX", (GLvoid *) NAME(glFragmentMaterialivSGIX), _gloffset_FragmentMaterialivSGIX }, - { "glGetFragmentLightfvSGIX", (GLvoid *) NAME(glGetFragmentLightfvSGIX), _gloffset_GetFragmentLightfvSGIX }, - { "glGetFragmentLightivSGIX", (GLvoid *) NAME(glGetFragmentLightivSGIX), _gloffset_GetFragmentLightivSGIX }, - { "glGetFragmentMaterialfvSGIX", (GLvoid *) NAME(glGetFragmentMaterialfvSGIX), _gloffset_GetFragmentMaterialfvSGIX }, - { "glGetFragmentMaterialivSGIX", (GLvoid *) NAME(glGetFragmentMaterialivSGIX), _gloffset_GetFragmentMaterialivSGIX }, - { "glLightEnviSGIX", (GLvoid *) NAME(glLightEnviSGIX), _gloffset_LightEnviSGIX }, + { "glFragmentColorMaterialSGIX", NAME(glFragmentColorMaterialSGIX), _gloffset_FragmentColorMaterialSGIX }, + { "glFragmentLightfSGIX", NAME(glFragmentLightfSGIX), _gloffset_FragmentLightfSGIX }, + { "glFragmentLightfvSGIX", NAME(glFragmentLightfvSGIX), _gloffset_FragmentLightfvSGIX }, + { "glFragmentLightiSGIX", NAME(glFragmentLightiSGIX), _gloffset_FragmentLightiSGIX }, + { "glFragmentLightivSGIX", NAME(glFragmentLightivSGIX), _gloffset_FragmentLightivSGIX }, + { "glFragmentLightModelfSGIX", NAME(glFragmentLightModelfSGIX), _gloffset_FragmentLightModelfSGIX }, + { "glFragmentLightModelfvSGIX", NAME(glFragmentLightModelfvSGIX), _gloffset_FragmentLightModelfvSGIX }, + { "glFragmentLightModeliSGIX", NAME(glFragmentLightModeliSGIX), _gloffset_FragmentLightModeliSGIX }, + { "glFragmentLightModelivSGIX", NAME(glFragmentLightModelivSGIX), _gloffset_FragmentLightModelivSGIX }, + { "glFragmentMaterialfSGIX", NAME(glFragmentMaterialfSGIX), _gloffset_FragmentMaterialfSGIX }, + { "glFragmentMaterialfvSGIX", NAME(glFragmentMaterialfvSGIX), _gloffset_FragmentMaterialfvSGIX }, + { "glFragmentMaterialiSGIX", NAME(glFragmentMaterialiSGIX), _gloffset_FragmentMaterialiSGIX }, + { "glFragmentMaterialivSGIX", NAME(glFragmentMaterialivSGIX), _gloffset_FragmentMaterialivSGIX }, + { "glGetFragmentLightfvSGIX", NAME(glGetFragmentLightfvSGIX), _gloffset_GetFragmentLightfvSGIX }, + { "glGetFragmentLightivSGIX", NAME(glGetFragmentLightivSGIX), _gloffset_GetFragmentLightivSGIX }, + { "glGetFragmentMaterialfvSGIX", NAME(glGetFragmentMaterialfvSGIX), _gloffset_GetFragmentMaterialfvSGIX }, + { "glGetFragmentMaterialivSGIX", NAME(glGetFragmentMaterialivSGIX), _gloffset_GetFragmentMaterialivSGIX }, + { "glLightEnviSGIX", NAME(glLightEnviSGIX), _gloffset_LightEnviSGIX }, #undef NAME + /* 112. GL_EXT_draw_range_elements */ +#if 000 +#ifdef GL_EXT_draw_range_elements +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glDrawRangeElementsEXT", NAME(glDrawRangeElementsEXT), _gloffset_DrawRangeElementsEXT }, +#undef NAME +#endif + + /* 117. GL_EXT_light_texture */ +#if 000 +#ifdef GL_EXT_light_texture +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glApplyTextureEXT", NAME(glApplyTextureEXT), _gloffset_ApplyTextureEXT }, + { "glTextureLightEXT", NAME(glTextureLightEXT), _gloffset_TextureLightEXT }, + { "glTextureMaterialEXT", NAME(glTextureMaterialEXT), _gloffset_TextureMaterialEXT }, +#undef NAME + + /* 135. GL_INTEL_texture_scissor */ +#ifdef GL_INTEL_texture_scissor +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glTexScissorINTEL", NAME(glTexScissorINTEL), _gloffset_TexScissorINTEL }, + { "glTexScissorFuncINTEL", NAME(glTexScissorFuncINTEL), _gloffset_glTexScissorFuncINTEL }, +#undef NAME + + /* 136. GL_INTEL_parallel_arrays */ +#ifdef GL_INTEL_parallel_arrays +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glVertexPointervINTEL", NAME(glVertexPointervINTEL), _gloffset_VertexPointervINTEL }, + { "glNormalPointervINTEL", NAME(glNormalPointervINTEL), _gloffset_NormalPointervINTEL }, + { "glColorPointervINTEL", NAME(glColorPointervINTEL), _gloffset_ColorPointervINTEL }, + { "glTexCoordPointervINTEL", NAME(glTexCoordPointervINTEL), _gloffset_glxCoordPointervINTEL }, +#undef NAME +#endif + + /* 138. GL_EXT_pixel_transform */ +#if 000 +#ifdef GL_EXT_pixel_transform +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glPixelTransformParameteriEXT", NAME(glPixelTransformParameteriEXT), _gloffset_PixelTransformParameteriEXT }, + { "glPixelTransformParameterfEXT", NAME(glPixelTransformParameterfEXT), _gloffset_PixelTransformParameterfEXT }, + { "glPixelTransformParameterivEXT", NAME(glPixelTransformParameterivEXT), _gloffset_PixelTransformParameterivEXT }, + { "glPixelTransformParameterfvEXT", NAME(glPixelTransformParameterfvEXT), _gloffset_PixelTransformParameterfvEXT }, + { "glGetPixelTransformParameterivEXT", NAME(glGetPixelTransformParameterivEXT), _gloffset_GetPixelTransformParameterivEXT }, + { "glGetPixelTransformParameterfvEXT", NAME(glGetPixelTransformParameterfvEXT), _gloffset_GetPixelTransformParameterfvEXT }, +#undef NAME + + /* 145. GL_EXT_secondary_color */ +#ifdef GL_EXT_secondary_color +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glSecondaryColor3bEXT", NAME(glSecondaryColor3bEXT), _gloffset_SecondaryColor3bEXT }, + { "glSecondaryColor3dEXT", NAME(glSecondaryColor3dEXT), _gloffset_SecondaryColor3dEXT }, + { "glSecondaryColor3fEXT", NAME(glSecondaryColor3fEXT), _gloffset_SecondaryColor3fEXT }, + { "glSecondaryColor3iEXT", NAME(glSecondaryColor3iEXT), _gloffset_SecondaryColor3iEXT }, + { "glSecondaryColor3sEXT", NAME(glSecondaryColor3sEXT), _gloffset_SecondaryColor3sEXT }, + { "glSecondaryColor3ubEXT", NAME(glSecondaryColor3ubEXT), _gloffset_SecondaryColor3ubEXT }, + { "glSecondaryColor3uiEXT", NAME(glSecondaryColor3uiEXT), _gloffset_SecondaryColor3uiEXT }, + { "glSecondaryColor3usEXT", NAME(glSecondaryColor3usEXT), _gloffset_SecondaryColor3usEXT }, + { "glSecondaryColor4bEXT", NAME(glSecondaryColor4bEXT), _gloffset_SecondaryColor4bEXT }, + { "glSecondaryColor4dEXT", NAME(glSecondaryColor4dEXT), _gloffset_SecondaryColor4dEXT }, + { "glSecondaryColor4fEXT", NAME(glSecondaryColor4fEXT), _gloffset_SecondaryColor4fEXT }, + { "glSecondaryColor4iEXT", NAME(glSecondaryColor4iEXT), _gloffset_SecondaryColor4iEXT }, + { "glSecondaryColor4sEXT", NAME(glSecondaryColor4sEXT), _gloffset_SecondaryColor4sEXT }, + { "glSecondaryColor4ubEXT", NAME(glSecondaryColor4ubEXT), _gloffset_SecondaryColor4ubEXT }, + { "glSecondaryColor4uiEXT", NAME(glSecondaryColor4uiEXT), _gloffset_SecondaryColor4uiEXT }, + { "glSecondaryColor4usEXT", NAME(glSecondaryColor4usEXT), _gloffset_SecondaryColor4usEXT }, + { "glSecondaryColor3bvEXT", NAME(glSecondaryColor3bvEXT), _gloffset_SecondaryColor3bvEXT }, + { "glSecondaryColor3dvEXT", NAME(glSecondaryColor3dvEXT), _gloffset_SecondaryColor3dvEXT }, + { "glSecondaryColor3fvEXT", NAME(glSecondaryColor3fvEXT), _gloffset_SecondaryColor3fvEXT }, + { "glSecondaryColor3ivEXT", NAME(glSecondaryColor3ivEXT), _gloffset_SecondaryColor3ivEXT }, + { "glSecondaryColor3svEXT", NAME(glSecondaryColor3svEXT), _gloffset_SecondaryColor3svEXT }, + { "glSecondaryColor3ubvEXT", NAME(glSecondaryColor3ubvEXT), _gloffset_SecondaryColor3ubvEXT }, + { "glSecondaryColor3uivEXT", NAME(glSecondaryColor3uivEXT), _gloffset_SecondaryColor3uivEXT }, + { "glSecondaryColor3usvEXT", NAME(glSecondaryColor3usvEXT), _gloffset_SecondaryColor3usvEXT }, + { "glSecondaryColor4bvEXT", NAME(glSecondaryColor4bvEXT), _gloffset_SecondaryColor4bvEXT }, + { "glSecondaryColor4dvEXT", NAME(glSecondaryColor4dvEXT), _gloffset_SecondaryColor4dvEXT }, + { "glSecondaryColor4fvEXT", NAME(glSecondaryColor4fvEXT), _gloffset_SecondaryColor4fvEXT }, + { "glSecondaryColor4ivEXT", NAME(glSecondaryColor4ivEXT), _gloffset_SecondaryColor4ivEXT }, + { "glSecondaryColor4svEXT", NAME(glSecondaryColor4svEXT), _gloffset_SecondaryColor4svEXT }, + { "glSecondaryColor4ubvEXT", NAME(glSecondaryColor4ubvEXT), _gloffset_SecondaryColor4ubvEXT }, + { "glSecondaryColor4uivEXT", NAME(glSecondaryColor4uivEXT), _gloffset_SecondaryColor4uivEXT }, + { "glSecondaryColor4usvEXT", NAME(glSecondaryColor4usvEXT), _gloffset_SecondaryColor4usvEXT }, + { "glSecondaryColorPointerEXT", NAME(glSecondaryColorPointerEXT), _gloffset_SecondaryColorPointerEXT }, +#undef NAME + + /* 147. GL_EXT_texture_perturb_normal */ +#ifdef GL_EXT_texture_perturb_normal +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glTextureNormalEXT", NAME(glTextureNormalEXT), _gloffset_TextureNormalEXT }, +#undef NAME + + /* 148. GL_EXT_multi_draw_arrays */ +#ifdef GL_EXT_multi_draw_arrays +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glMultiDrawArraysEXT", NAME(glMultiDrawArraysEXT), _gloffset_MultiDrawArraysEXT }, +#undef NAME +#endif + /* 149. GL_EXT_fog_coord */ #ifdef GL_EXT_fog_coord -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glFogCoordfEXT", (GLvoid *) NAME(glFogCoordfEXT), _gloffset_FogCoordfEXT }, - { "glFogCoordfvEXT", (GLvoid *) NAME(glFogCoordfvEXT), _gloffset_FogCoordfvEXT }, - { "glFogCoorddEXT", (GLvoid *) NAME(glFogCoorddEXT), _gloffset_FogCoorddEXT }, - { "glFogCoorddEXT", (GLvoid *) NAME(glFogCoorddEXT), _gloffset_FogCoorddEXT }, - { "glFogCoordPointerEXT", (GLvoid *) NAME(glFogCoordPointerEXT), _gloffset_FogCoordPointerEXT }, + { "glFogCoordfEXT", NAME(glFogCoordfEXT), _gloffset_FogCoordfEXT }, + { "glFogCoordfvEXT", NAME(glFogCoordfvEXT), _gloffset_FogCoordfvEXT }, + { "glFogCoorddEXT", NAME(glFogCoorddEXT), _gloffset_FogCoorddEXT }, + { "glFogCoorddEXT", NAME(glFogCoorddEXT), _gloffset_FogCoorddEXT }, + { "glFogCoordPointerEXT", NAME(glFogCoordPointerEXT), _gloffset_FogCoordPointerEXT }, #undef NAME +#if 000 + /* 156. GL_EXT_coordinate_frame */ +#ifdef GL_EXT_coordinate_frame +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glTangent3bEXT", NAME(glTangent3bEXT), _gloffset_Tangent3bEXT }, + { "glTangent3dEXT", NAME(glTangent3dEXT), _gloffset_Tangent3dEXT }, + { "glTangent3fEXT", NAME(glTangent3fEXT), _gloffset_Tangent3fEXT }, + { "glTangent3iEXT", NAME(glTangent3iEXT), _gloffset_Tangent3iEXT }, + { "glTangent3sEXT", NAME(glTangent3sEXT), _gloffset_Tangent3sEXT }, + { "glTangent3bvEXT", NAME(glTangent3bvEXT), _gloffset_Tangent3bvEXT }, + { "glTangent3dvEXT", NAME(glTangent3dvEXT), _gloffset_Tangent3dvEXT }, + { "glTangent3fvEXT", NAME(glTangent3fvEXT), _gloffset_Tangent3fvEXT }, + { "glTangent3ivEXT", NAME(glTangent3ivEXT), _gloffset_Tangent3ivEXT }, + { "glTangent3svEXT", NAME(glTangent3svEXT), _gloffset_Tangent3svEXT }, + { "glBinormal3bEXT", NAME(glBinormal3bEXT), _gloffset_Binormal3bEXT }, + { "glBinormal3dEXT", NAME(glBinormal3dEXT), _gloffset_Binormal3dEXT }, + { "glBinormal3fEXT", NAME(glBinormal3fEXT), _gloffset_Binormal3fEXT }, + { "glBinormal3iEXT", NAME(glBinormal3iEXT), _gloffset_Binormal3iEXT }, + { "glBinormal3sEXT", NAME(glBinormal3sEXT), _gloffset_Binormal3sEXT }, + { "glBinormal3bvEXT", NAME(glBinormal3bvEXT), _gloffset_Binormal3bvEXT }, + { "glBinormal3dvEXT", NAME(glBinormal3dvEXT), _gloffset_Binormal3dvEXT }, + { "glBinormal3fvEXT", NAME(glBinormal3fvEXT), _gloffset_Binormal3fvEXT }, + { "glBinormal3ivEXT", NAME(glBinormal3ivEXT), _gloffset_Binormal3ivEXT }, + { "glBinormal3svEXT", NAME(glBinormal3svEXT), _gloffset_Binormal3svEXT }, + { "glTangentPointerEXT", NAME(glTangentPointerEXT), _gloffset_TangentPointerEXT }, + { "glBinormalPointerEXT", NAME(glBinormalPointerEXT), _gloffset_BinormalPointerEXT }, +#undef NAME + + /* 164. GL_SUN_global_alpha */ +#ifdef GL_SUN_global_alpha +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glGlobalAlphaFactorbSUN", NAME(glGlobalAlphaFactorbSUN), _gloffset_GlobalAlphaFactorbSUN }, + { "glGlobalAlphaFactorsSUN", NAME(glGlobalAlphaFactorsSUN), _gloffset_GlobalAlphaFactorsSUN }, + { "glGlobalAlphaFactoriSUN", NAME(glGlobalAlphaFactoriSUN), _gloffset_GlobalAlphaFactoriSUN }, + { "glGlobalAlphaFactorfSUN", NAME(glGlobalAlphaFactorfSUN), _gloffset_GlobalAlphaFactorfSUN }, + { "glGlobalAlphaFactordSUN", NAME(glGlobalAlphaFactordSUN), _gloffset_GlobalAlphaFactordSUN }, + { "glGlobalAlphaFactorubSUN", NAME(glGlobalAlphaFactorubSUN), _gloffset_GlobalAlphaFactorubSUN }, + { "glGlobalAlphaFactorusSUN", NAME(glGlobalAlphaFactorusSUN), _gloffset_GlobalAlphaFactorusSUN }, + { "glGlobalAlphaFactoruiSUN", NAME(glGlobalAlphaFactoruiSUN), _gloffset_GlobalAlphaFactoruiSUN }, +#undef NAME + + /* 165. GL_SUN_triangle_list */ +#ifdef GL_SUN_triangle_list +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glReplacementCodeuiSUN", NAME(glReplacementCodeuiSUN), _gloffset_ReplacementCodeuiSUN }, + { "glReplacementCodeusSUN", NAME(glReplacementCodeusSUN), _gloffset_ReplacementCodeusSUN }, + { "glReplacementCodeubSUN", NAME(glReplacementCodeubSUN), _gloffset_ReplacementCodeubSUN }, + { "glReplacementCodeuivSUN", NAME(glReplacementCodeuivSUN), _gloffset_ReplacementCodeuivSUN }, + { "glReplacementCodeusvSUN", NAME(glReplacementCodeusvSUN), _gloffset_ReplacementCodeusvSUN }, + { "glReplacementCodeubvSUN", NAME(glReplacementCodeubvSUN), _gloffset_ReplacementCodeubvSUN }, + { "glReplacementCodePointerSUN", NAME(glReplacementCodePointerSUN), _gloffset_ReplacementCodePointerSUN }, +#undef NAME + + /* 166. GL_SUN_vertex */ +#ifdef GL_SUN_vertex +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glColor4ubVertex2fSUN", NAME(glColor4ubVertex2fSUN), _gloffset_Color4ubVertex2fSUN }, + { "glColor4ubVertex2fvSUN", NAME(glColor4ubVertex2fvSUN), _gloffset_Color4ubVertex2fvSUN }, + { "glColor4ubVertex3fSUN", NAME(glColor4ubVertex3fSUN), _gloffset_Color4ubVertex3fSUN }, + { "glColor4ubVertex3fvSUN", NAME(glColor4ubVertex3fvSUN), _gloffset_Color4ubVertex3fvSUN }, + { "glColor3fVertex3fSUN", NAME(glColor3fVertex3fSUN), _gloffset_Color3fVertex3fSUN }, + { "glColor3fVertex3fvSUN", NAME(glColor3fVertex3fvSUN), _gloffset_Color3fVertex3fvSUN }, + { "glNormal3fVertex3fSUN", NAME(glNormal3fVertex3fSUN), _gloffset_Normal3fVertex3fSUN }, + { "glNormal3fVertex3fvSUN", NAME(glNormal3fVertex3fvSUN), _gloffset_Normal3fVertex3fvSUN }, + { "glColor4fNormal3fVertex3fSUN", NAME(glColor4fNormal3fVertex3fSUN), _gloffset_Color4fNormal3fVertex3fSUN }, + { "glColor4fNormal3fVertex3fvSUN", NAME(glColor4fNormal3fVertex3fvSUN), _gloffset_Color4fNormal3fVertex3fvSUN }, + { "glTexCoord2fVertex3fSUN", NAME(glTexCoord2fVertex3fSUN), _gloffset_TexCoord2fVertex3fSUN }, + { "glTexCoord2fVertex3fvSUN", NAME(glTexCoord2fVertex3fvSUN), _gloffset_TexCoord2fVertex3fvSUN }, + { "glTexCoord4fVertex4fSUN", NAME(glTexCoord4fVertex4fSUN), _gloffset_TexCoord4fVertex4fSUN }, + { "glTexCoord4fVertex4fvSUN", NAME(glTexCoord4fVertex4fvSUN), _gloffset_TexCoord4fVertex4fvSUN }, + { "glTexCoord2fColor4ubVertex3fSUN", NAME(glTexCoord2fColor4ubVertex3fSUN), _gloffset_TexCoord2fColor4ubVertex3fSUN }, + { "glTexCoord2fColor4ubVertex3fvSUN", NAME(glTexCoord2fColor4ubVertex3fvSUN), _gloffset_TexCoord2fColor4ubVertex3fvSUN }, + { "glTexCoord2fColor3fVertex3fSUN", NAME(glTexCoord2fColor3fVertex3fSUN), _gloffset_TexCoord2fColor3fVertex3fSUN }, + { "glTexCoord2fColor3fVertex3fvSUN", NAME(glTexCoord2fColor3fVertex3fvSUN), _gloffset_TexCoord2fColor3fVertex3fvSUN }, + { "glTexCoord2fNormal3fVertex3fSUN", NAME(glTexCoord2fNormal3fVertex3fSUN), _gloffset_TexCoord2fNormal3fVertex3fSUN }, + { "glTexCoord2fNormal3fVertex3fvSUN", NAME(glTexCoord2fNormal3fVertex3fvSUN), _gloffset_TexCoord2fNormal3fVertex3fvSUN }, + { "glTexCoord2fColor4fNormal3fVertex3fSUN", NAME(glTexCoord2fColor4fNormal3fVertex3fSUN), _gloffset_TexCoord2fColor4fNormal3fVertex3fSUN }, + { "glTexCoord2fColor4fNormal3fVertex3fvSUN", NAME(glTexCoord2fColor4fNormal3fVertex3fvSUN), _gloffset_TexCoord2fColor4fNormal3fVertex3fvSUN }, + { "glTexCoord4fColor4fNormal3fVertex4fSUN", NAME(glTexCoord4fColor4fNormal3fVertex4fSUN), _gloffset_TexCoord4fColor4fNormal3fVertex4fSUN }, + { "glTexCoord4fColor4fNormal3fVertex4fvSUN", NAME(glTexCoord4fColor4fNormal3fVertex4fvSUN), _gloffset_TexCoord4fColor4fNormal3fVertex4fvSUN }, + { "glReplacementCodeuiVertex3fSUN", NAME(glReplacementCodeuiVertex3fSUN), _gloffset_ReplacementCodeuiVertex3fSUN }, + { "glReplacementCodeuiVertex3fvSUN", NAME(glReplacementCodeuiVertex3fvSUN), _gloffset_ReplacementCodeuiVertex3fvSUN }, + { "glReplacementCodeuiColor4ubVertex3fSUN", NAME(glReplacementCodeuiColor4ubVertex3fSUN), _gloffset_ReplacementCodeuiColor4ubVertex3fSUN }, + { "glReplacementCodeuiColor4ubVertex3fvSUN", NAME(glReplacementCodeuiColor4ubVertex3fvSUN), _gloffset_ReplacementCodeuiColor4ubVertex3fvSUN }, + { "glReplacementCodeuiColor3fVertex3fSUN", NAME(glReplacementCodeuiColor3fVertex3fSUN), _gloffset_ReplacementCodeuiColor3fVertex3fSUN }, + { "glReplacementCodeuiColor3fVertex3fvSUN", NAME(glReplacementCodeuiColor3fVertex3fvSUN), _gloffset_ReplacementCodeuiColor3fVertex3fvSUN }, + { "glReplacementCodeuiNormal3fVertex3fSUN", NAME(glReplacementCodeuiNormal3fVertex3fSUN), _gloffset_ReplacementCodeuiNormal3fVertex3fSUN }, + { "glReplacementCodeuiNormal3fVertex3fvSUN", NAME(glReplacementCodeuiNormal3fVertex3fvSUN), _gloffset_ReplacementCodeuiNormal3fVertex3fvSUN }, + { "glReplacementCodeuiColor4fNormal3fVertex3fSUN", NAME(glReplacementCodeuiColor4fNormal3fVertex3fSUN), _gloffset_ReplacementCodeuiColor4fNormal3fVertex3fSUN }, + { "glReplacementCodeuiColor4fNormal3fVertex3fvSUN", NAME(glReplacementCodeuiColor4fNormal3fVertex3fvSUN), _gloffset_ReplacementCodeuiColor4fNormal3fVertex3fvSUN }, + { "glReplacementCodeuiTexCoord2fVertex3fSUN", NAME(glReplacementCodeuiTexCoord2fVertex3fSUN), _gloffset_ReplacementCodeuiTexCoord2fVertex3fSUN }, + { "glReplacementCodeuiTexCoord2fVertex3fvSUN", NAME(glReplacementCodeuiTexCoord2fVertex3fvSUN), _gloffset_ReplacementCodeuiTexCoord2fVertex3fvSUN }, + { "glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN", NAME(glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN), _gloffset_ReplacementCodeuiTexCoord2fNormal3fVertex3fSUN }, + { "glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN", NAME(glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN), _gloffset_ReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN }, + { "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN", NAME(glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN), _gloffset_ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN }, + { "glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN", NAME(glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN), _gloffset_ReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN }, +#undef NAME +#endif + /* 173. GL_EXT/INGR_blend_func_separate */ #ifdef GL_EXT_blend_func_separate -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glBlendFuncSeparateEXT", (GLvoid *) NAME(glBlendFuncSeparateEXT), _gloffset_BlendFuncSeparateEXT }, - { "glBlendFuncSeparateINGR", (GLvoid *) NAME(glBlendFuncSeparateEXT), _gloffset_BlendFuncSeparateEXT }, + { "glBlendFuncSeparateEXT", NAME(glBlendFuncSeparateEXT), _gloffset_BlendFuncSeparateEXT }, + { "glBlendFuncSeparateINGR", NAME(glBlendFuncSeparateEXT), _gloffset_BlendFuncSeparateEXT }, #undef NAME /* 188. GL_EXT_vertex_weighting */ #ifdef GL_EXT_vertex_weighting -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glVertexWeightfEXT", (GLvoid *) NAME(glVertexWeightfEXT), _gloffset_VertexWeightfEXT }, - { "glVertexWeightfvEXT", (GLvoid *) NAME(glVertexWeightfvEXT), _gloffset_VertexWeightfvEXT }, - { "glVertexWeightPointerEXT", (GLvoid *) NAME(glVertexWeightPointerEXT), _gloffset_VertexWeightPointerEXT }, + { "glVertexWeightfEXT", NAME(glVertexWeightfEXT), _gloffset_VertexWeightfEXT }, + { "glVertexWeightfvEXT", NAME(glVertexWeightfvEXT), _gloffset_VertexWeightfvEXT }, + { "glVertexWeightPointerEXT", NAME(glVertexWeightPointerEXT), _gloffset_VertexWeightPointerEXT }, #undef NAME /* 190. GL_NV_vertex_array_range */ #ifdef GL_NV_vertex_array_range -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glFlushVertexArrayRangeNV", (GLvoid *) NAME(glFlushVertexArrayRangeNV), _gloffset_FlushVertexArrayRangeNV }, - { "glVertexArrayRangeNV", (GLvoid *) NAME(glVertexArrayRangeNV), _gloffset_VertexArrayRangeNV }, + { "glFlushVertexArrayRangeNV", NAME(glFlushVertexArrayRangeNV), _gloffset_FlushVertexArrayRangeNV }, + { "glVertexArrayRangeNV", NAME(glVertexArrayRangeNV), _gloffset_VertexArrayRangeNV }, #undef NAME /* 191. GL_NV_register_combiners */ #ifdef GL_NV_register_combiners -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glCombinerParameterfvNV", (GLvoid *) NAME(glCombinerParameterfvNV), _gloffset_CombinerParameterfvNV }, - { "glCombinerParameterfNV", (GLvoid *) NAME(glCombinerParameterfNV), _gloffset_CombinerParameterfNV }, - { "glCombinerParameterivNV", (GLvoid *) NAME(glCombinerParameterivNV), _gloffset_CombinerParameterivNV }, - { "glCombinerParameteriNV", (GLvoid *) NAME(glCombinerParameteriNV), _gloffset_CombinerParameteriNV }, - { "glCombinerInputNV", (GLvoid *) NAME(glCombinerInputNV), _gloffset_CombinerInputNV }, - { "glCombinerOutputNV", (GLvoid *) NAME(glCombinerOutputNV), _gloffset_CombinerOutputNV }, - { "glFinalCombinerInputNV", (GLvoid *) NAME(glFinalCombinerInputNV), _gloffset_FinalCombinerInputNV }, - { "glGetCombinerInputParameterfvNV", (GLvoid *) NAME(glGetCombinerInputParameterfvNV), _gloffset_GetCombinerInputParameterfvNV }, - { "glGetCombinerInputParameterivNV", (GLvoid *) NAME(glGetCombinerInputParameterivNV), _gloffset_GetCombinerInputParameterivNV }, - { "glGetCombinerOutputParameterfvNV", (GLvoid *) NAME(glGetCombinerOutputParameterfvNV), _gloffset_GetCombinerOutputParameterfvNV }, - { "glGetCombinerOutputParameterivNV", (GLvoid *) NAME(glGetCombinerOutputParameterivNV), _gloffset_GetCombinerOutputParameterivNV }, - { "glGetFinalCombinerInputParameterfvNV", (GLvoid *) NAME(glGetFinalCombinerInputParameterfvNV), _gloffset_GetFinalCombinerInputParameterfvNV }, - { "glGetFinalCombinerInputParameterivNV", (GLvoid *) NAME(glGetFinalCombinerInputParameterivNV), _gloffset_GetFinalCombinerInputParameterivNV }, + { "glCombinerParameterfvNV", NAME(glCombinerParameterfvNV), _gloffset_CombinerParameterfvNV }, + { "glCombinerParameterfNV", NAME(glCombinerParameterfNV), _gloffset_CombinerParameterfNV }, + { "glCombinerParameterivNV", NAME(glCombinerParameterivNV), _gloffset_CombinerParameterivNV }, + { "glCombinerParameteriNV", NAME(glCombinerParameteriNV), _gloffset_CombinerParameteriNV }, + { "glCombinerInputNV", NAME(glCombinerInputNV), _gloffset_CombinerInputNV }, + { "glCombinerOutputNV", NAME(glCombinerOutputNV), _gloffset_CombinerOutputNV }, + { "glFinalCombinerInputNV", NAME(glFinalCombinerInputNV), _gloffset_FinalCombinerInputNV }, + { "glGetCombinerInputParameterfvNV", NAME(glGetCombinerInputParameterfvNV), _gloffset_GetCombinerInputParameterfvNV }, + { "glGetCombinerInputParameterivNV", NAME(glGetCombinerInputParameterivNV), _gloffset_GetCombinerInputParameterivNV }, + { "glGetCombinerOutputParameterfvNV", NAME(glGetCombinerOutputParameterfvNV), _gloffset_GetCombinerOutputParameterfvNV }, + { "glGetCombinerOutputParameterivNV", NAME(glGetCombinerOutputParameterivNV), _gloffset_GetCombinerOutputParameterivNV }, + { "glGetFinalCombinerInputParameterfvNV", NAME(glGetFinalCombinerInputParameterfvNV), _gloffset_GetFinalCombinerInputParameterfvNV }, + { "glGetFinalCombinerInputParameterivNV", NAME(glGetFinalCombinerInputParameterivNV), _gloffset_GetFinalCombinerInputParameterivNV }, #undef NAME /* 196. GL_MESA_resize_buffers */ #ifdef MESA_resize_buffers -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glResizeBuffersMESA", (GLvoid *) NAME(glResizeBuffersMESA), _gloffset_ResizeBuffersMESA }, + { "glResizeBuffersMESA", NAME(glResizeBuffersMESA), _gloffset_ResizeBuffersMESA }, #undef NAME /* 197. GL_MESA_window_pos */ #ifdef MESA_window_pos -#define NAME(X) X +#define NAME(X) (GLvoid *) X #else -#define NAME(X) NotImplemented +#define NAME(X) (GLvoid *) NotImplemented #endif - { "glWindowPos4fMESA", (GLvoid *) NAME(glWindowPos4fMESA), _gloffset_WindowPos4fMESA }, + { "glWindowPos4fMESA", NAME(glWindowPos4fMESA), _gloffset_WindowPos4fMESA }, #undef NAME + /* 209. WGL_EXT_multisample */ +#ifdef WGL_EXT_multisample +#define NAME(X) (GLvoid *) X +#else +#define NAME(X) (GLvoid *) NotImplemented +#endif + { "glSampleMaskEXT", NAME(glSampleMaskEXT), _gloffset_SampleMaskSGIS }, + { "glSamplePatternEXT", NAME(glSamplePatternEXT), _gloffset_SamplePatternSGIS }, +#undef NAME { NULL, NULL } /* end of list marker */ }; + + +/* + * Return dispatch table offset of the named static (built-in) function. + * Return -1 if function not found. + */ +static GLint +get_static_proc_offset(const char *funcName) +{ + GLuint i; + for (i = 0; static_functions[i].Name; i++) { + if (strcmp(static_functions[i].Name, funcName) == 0) { + return static_functions[i].Offset; + } + } + return -1; +} + + +/* + * Return dispatch function address the named static (built-in) function. + * Return NULL if function not found. + */ +static GLvoid * +get_static_proc_address(const char *funcName) +{ + GLint i = get_static_proc_offset(funcName); + if (i >= 0) + return static_functions[i].Address; + else + return NULL; +} + + + +/********************************************************************** + * Extension function management. + */ + + +#define MAX_EXTENSION_FUNCS 1000 + +static struct name_address_offset ExtEntryTable[MAX_EXTENSION_FUNCS]; +static GLuint NumExtEntryPoints = 0; + + + +/* + * Generate a dispatch function (entrypoint) which jumps through + * the given slot number (offset) in the current dispatch table. + * We need assembly language in order to accomplish this. + */ +static void * +generate_entrypoint(GLuint functionOffset) +{ +#if defined(USE_X86_ASM) + /* + * This x86 code contributed by Josh Vanderhoof. + * + * 0: a1 10 32 54 76 movl __glapi_Dispatch,%eax + * 00 01 02 03 04 + * 5: 85 c0 testl %eax,%eax + * 05 06 + * 7: 74 06 je f <entrypoint+0xf> + * 07 08 + * 9: ff a0 10 32 54 76 jmp *0x76543210(%eax) + * 09 0a 0b 0c 0d 0e + * f: e8 fc ff ff ff call __glapi_get_dispatch + * 0f 10 11 12 13 + * 14: ff a0 10 32 54 76 jmp *0x76543210(%eax) + * 14 15 16 17 18 19 + */ + static const unsigned char temp[] = { + 0xa1, 0x00, 0x00, 0x00, 0x00, + 0x85, 0xc0, + 0x74, 0x06, + 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00, + 0xe8, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xa0, 0x00, 0x00, 0x00, 0x00 + }; + unsigned char *code = malloc(sizeof(temp)); + unsigned int next_insn; + if (code) { + memcpy(code, temp, sizeof(temp)); + + *(unsigned int *)(code + 0x01) = (unsigned int)&_glapi_Dispatch; + *(unsigned int *)(code + 0x0b) = (unsigned int)functionOffset * 4; + next_insn = (unsigned int)(code + 0x14); + *(unsigned int *)(code + 0x10) = (unsigned int)_glapi_get_dispatch - next_insn; + *(unsigned int *)(code + 0x16) = (unsigned int)functionOffset * 4; + } + return code; +#else + return NULL; +#endif +} + + + +/* + * Add a new extension function entrypoint. + * Return: GL_TRUE = success or GL_FALSE = failure + */ +GLboolean +_glapi_add_entrypoint(const char *funcName, GLuint offset) +{ + /* first check if the named function is already statically present */ + { + GLint index = get_static_proc_offset(funcName); + if (index >= 0) { + return (GLboolean) (index == offset); /* bad offset! */ + } + } + + { + /* make sure this offset/name pair is legal */ + const char *name = _glapi_get_proc_name(offset); + if (name && strcmp(name, funcName) != 0) + return GL_FALSE; /* bad name! */ + } + + { + /* be sure index and name match known data */ + GLuint i; + for (i = 0; i < NumExtEntryPoints; i++) { + if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { + /* function already registered with api */ + if (ExtEntryTable[i].Offset == offset) { + return GL_TRUE; /* offsets match */ + } + else { + return GL_FALSE; /* bad offset! */ + } + } + } + + /* Make sure we don't try to add a new entrypoint after someone + * has already called _glapi_get_dispatch_table_size()! If that's + * happened the caller's information would become out of date. + */ + if (GetSizeCalled) + return GL_FALSE; + + /* make sure we have space */ + if (NumExtEntryPoints >= MAX_EXTENSION_FUNCS) { + return GL_FALSE; + } + else { + void *entrypoint = generate_entrypoint(offset); + if (!entrypoint) + return GL_FALSE; + + ExtEntryTable[NumExtEntryPoints].Name = str_dup(funcName); + ExtEntryTable[NumExtEntryPoints].Offset = offset; + ExtEntryTable[NumExtEntryPoints].Address = entrypoint; + NumExtEntryPoints++; + + if (offset > MaxDispatchOffset) + MaxDispatchOffset = offset; + + return GL_TRUE; /* success */ + } + } + + /* should never get here, but play it safe */ + return GL_FALSE; +} + + + +#if 0000 /* prototype code for dynamic extension slot allocation */ + +static int NextFreeOffset = 409; /*XXX*/ +#define MAX_DISPATCH_TABLE_SIZE 1000 + +/* + * Dynamically allocate a dispatch slot for an extension entrypoint + * and generate the assembly language dispatch stub. + * Return the dispatch offset for the function or -1 if no room or error. + */ +GLint +_glapi_add_entrypoint2(const char *funcName) +{ + int offset; + + /* first see if extension func is already known */ + offset = _glapi_get_proc_offset(funcName); + if (offset >= 0) + return offset; + + if (NumExtEntryPoints < MAX_EXTENSION_FUNCS + && NextFreeOffset < MAX_DISPATCH_TABLE_SIZE) { + void *entryPoint; + offset = NextFreeOffset; + entryPoint = generate_entrypoint(offset); + if (entryPoint) { + NextFreeOffset++; + ExtEntryTable[NumExtEntryPoints].Name = str_dup(funcName); + ExtEntryTable[NumExtEntryPoints].Offset = offset; + ExtEntryTable[NumExtEntryPoints].Address = entryPoint; + NumExtEntryPoints++; + return offset; + } + } + return -1; +} + +#endif + + + +/* + * Return offset of entrypoint for named function within dispatch table. + */ +GLint +_glapi_get_proc_offset(const char *funcName) +{ + /* search extension functions first */ + GLint i; + for (i = 0; i < NumExtEntryPoints; i++) { + if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { + return ExtEntryTable[i].Offset; + } + } + + /* search static functions */ + return get_static_proc_offset(funcName); +} + + + +/* + * Return entrypoint for named function. + */ +const GLvoid * +_glapi_get_proc_address(const char *funcName) +{ + /* search extension functions first */ + GLint i; + for (i = 0; i < NumExtEntryPoints; i++) { + if (strcmp(ExtEntryTable[i].Name, funcName) == 0) { + return ExtEntryTable[i].Address; + } + } + + /* search static functions */ + return get_static_proc_address(funcName); +} + + + + +/* + * Return the name of the function at the given dispatch offset. + * This is only intended for debugging. + */ +const char * +_glapi_get_proc_name(GLuint offset) +{ + const GLuint n = sizeof(static_functions) / sizeof(struct name_address_offset); + GLuint i; + for (i = 0; i < n; i++) { + if (static_functions[i].Offset == offset) + return static_functions[i].Name; + } + + /* search added extension functions */ + for (i = 0; i < NumExtEntryPoints; i++) { + if (ExtEntryTable[i].Offset == offset) { + return ExtEntryTable[i].Name; + } + } + return NULL; +} + + + +/* + * Make sure there are no NULL pointers in the given dispatch table. + * Intented for debugging purposes. + */ +void +_glapi_check_table(const struct _glapi_table *table) +{ + const GLuint entries = _glapi_get_dispatch_table_size(); + const void **tab = (const void **) table; + GLuint i; + for (i = 1; i < entries; i++) { + assert(tab[i]); + } + +#ifdef DEBUG + /* Do some spot checks to be sure that the dispatch table + * slots are assigned correctly. + */ + { + GLuint BeginOffset = _glapi_get_proc_offset("glBegin"); + char *BeginFunc = (char*) &table->Begin; + GLuint offset = (BeginFunc - (char *) table) / sizeof(void *); + assert(BeginOffset == _gloffset_Begin); + assert(BeginOffset == offset); + } + { + GLuint viewportOffset = _glapi_get_proc_offset("glViewport"); + char *viewportFunc = (char*) &table->Viewport; + GLuint offset = (viewportFunc - (char *) table) / sizeof(void *); + assert(viewportOffset == _gloffset_Viewport); + assert(viewportOffset == offset); + } + { + GLuint VertexPointerOffset = _glapi_get_proc_offset("glVertexPointer"); + char *VertexPointerFunc = (char*) &table->VertexPointer; + GLuint offset = (VertexPointerFunc - (char *) table) / sizeof(void *); + assert(VertexPointerOffset == _gloffset_VertexPointer); + assert(VertexPointerOffset == offset); + } + { + GLuint ResetMinMaxOffset = _glapi_get_proc_offset("glResetMinmax"); + char *ResetMinMaxFunc = (char*) &table->ResetMinmax; + GLuint offset = (ResetMinMaxFunc - (char *) table) / sizeof(void *); + assert(ResetMinMaxOffset == _gloffset_ResetMinmax); + assert(ResetMinMaxOffset == offset); + } + { + GLuint blendColorOffset = _glapi_get_proc_offset("glBlendColor"); + char *blendColorFunc = (char*) &table->BlendColor; + GLuint offset = (blendColorFunc - (char *) table) / sizeof(void *); + assert(blendColorOffset == _gloffset_BlendColor); + assert(blendColorOffset == offset); + } + { + GLuint istextureOffset = _glapi_get_proc_offset("glIsTextureEXT"); + char *istextureFunc = (char*) &table->IsTextureEXT; + GLuint offset = (istextureFunc - (char *) table) / sizeof(void *); + assert(istextureOffset == _gloffset_IsTextureEXT); + assert(istextureOffset == offset); + } +#endif +} + + + + diff --git a/xc/extras/Mesa/src/glapioffsets.h b/xc/extras/Mesa/src/glapioffsets.h index 67481c8e0..b05d49e6f 100644 --- a/xc/extras/Mesa/src/glapioffsets.h +++ b/xc/extras/Mesa/src/glapioffsets.h @@ -1,4 +1,4 @@ -/* DO NOT EDIT - This file generated automatically */ +/* DO NOT EDIT - This file generated automatically by gloffsets.py script */ #ifndef _GLAPI_OFFSETS_H_ #define _GLAPI_OFFSETS_H_ @@ -555,5 +555,13 @@ #define _gloffset_GetColorTableEXT 550 #define _gloffset_GetColorTableParameterivEXT 551 #define _gloffset_GetColorTableParameterfvEXT 552 +#define _gloffset_TbufferMask3DFX 553 +#define _gloffset_CompressedTexImage3DARB 554 +#define _gloffset_CompressedTexImage2DARB 555 +#define _gloffset_CompressedTexImage1DARB 556 +#define _gloffset_CompressedTexSubImage3DARB 557 +#define _gloffset_CompressedTexSubImage2DARB 558 +#define _gloffset_CompressedTexSubImage1DARB 559 +#define _gloffset_GetCompressedTexImageARB 560 #endif diff --git a/xc/extras/Mesa/src/glapitable.h b/xc/extras/Mesa/src/glapitable.h index 9e5d121dd..94690afb2 100644 --- a/xc/extras/Mesa/src/glapitable.h +++ b/xc/extras/Mesa/src/glapitable.h @@ -1,4 +1,4 @@ -/* DO NOT EDIT - This file generated automatically */ +/* DO NOT EDIT - This file generated automatically with gltable.py script */ #ifndef _GLAPI_TABLE_H_ #define _GLAPI_TABLE_H_ @@ -443,7 +443,7 @@ struct _glapi_table void (*PixelTexGenParameterfvSGIS)(GLenum pname, const GLfloat * params); /* 434 */ void (*GetPixelTexGenParameterivSGIS)(GLenum pname, GLint * params); /* 435 */ void (*GetPixelTexGenParameterfvSGIS)(GLenum pname, GLfloat * params); /* 436 */ - void (*TexImage4DSGIS)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid * pixels); /* 437 */ + void (*TexImage4DSGIS)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid * pixels); /* 437 */ void (*TexSubImage4DSGIS)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid * pixels); /* 438 */ GLboolean (*AreTexturesResidentEXT)(GLsizei n, const GLenum * textures, GLboolean * residences); /* 439 */ void (*GenTexturesEXT)(GLsizei n, GLenum * textures); /* 440 */ @@ -559,6 +559,14 @@ struct _glapi_table void (*GetColorTableEXT)(GLenum target, GLenum format, GLenum type, GLvoid * data); /* 550 */ void (*GetColorTableParameterivEXT)(GLenum target, GLenum pname, GLint * params); /* 551 */ void (*GetColorTableParameterfvEXT)(GLenum target, GLenum pname, GLfloat * params); /* 552 */ + void (*TbufferMask3DFX)(GLuint mask); /* 553 */ + void (*CompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * data); /* 554 */ + void (*CompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * data); /* 555 */ + void (*CompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid * data); /* 556 */ + void (*CompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid * data); /* 557 */ + void (*CompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid * data); /* 558 */ + void (*CompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid * data); /* 559 */ + void (*GetCompressedTexImageARB)(GLenum target, GLint level, void * img); /* 560 */ }; #endif diff --git a/xc/extras/Mesa/src/glapitemp.h b/xc/extras/Mesa/src/glapitemp.h index 7b940def6..b1b443e44 100644 --- a/xc/extras/Mesa/src/glapitemp.h +++ b/xc/extras/Mesa/src/glapitemp.h @@ -1978,180 +1978,6 @@ KEYWORD1 void KEYWORD2 NAME(SeparableFilter2D)(GLenum target, GLenum internalfor -/* ARB 0. GL_ARB_multitexture */ - -KEYWORD1 void KEYWORD2 NAME(ActiveTextureARB)(GLenum texture) -{ - DISPATCH(ActiveTextureARB, (texture), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(ClientActiveTextureARB)(GLenum texture) -{ - DISPATCH(ClientActiveTextureARB, (texture), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1dARB)(GLenum target, GLdouble s) -{ - DISPATCH(MultiTexCoord1dARB, (target, s), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1dvARB)(GLenum target, const GLdouble *v) -{ - DISPATCH(MultiTexCoord1dvARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1fARB)(GLenum target, GLfloat s) -{ - DISPATCH(MultiTexCoord1fARB, (target, s), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1fvARB)(GLenum target, const GLfloat *v) -{ - DISPATCH(MultiTexCoord1fvARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1iARB)(GLenum target, GLint s) -{ - DISPATCH(MultiTexCoord1iARB, (target, s), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1ivARB)(GLenum target, const GLint *v) -{ - DISPATCH(MultiTexCoord1ivARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1sARB)(GLenum target, GLshort s) -{ - DISPATCH(MultiTexCoord1sARB, (target, s), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1svARB)(GLenum target, const GLshort *v) -{ - DISPATCH(MultiTexCoord1svARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2dARB)(GLenum target, GLdouble s, GLdouble t) -{ - DISPATCH(MultiTexCoord2dARB, (target, s, t), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2dvARB)(GLenum target, const GLdouble *v) -{ - DISPATCH(MultiTexCoord2dvARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2fARB)(GLenum target, GLfloat s, GLfloat t) -{ - DISPATCH(MultiTexCoord2fARB, (target, s, t), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2fvARB)(GLenum target, const GLfloat *v) -{ - DISPATCH(MultiTexCoord2fvARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2iARB)(GLenum target, GLint s, GLint t) -{ - DISPATCH(MultiTexCoord2iARB, (target, s, t), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2ivARB)(GLenum target, const GLint *v) -{ - DISPATCH(MultiTexCoord2ivARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2sARB)(GLenum target, GLshort s, GLshort t) -{ - DISPATCH(MultiTexCoord2sARB, (target, s, t), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2svARB)(GLenum target, const GLshort *v) -{ - DISPATCH(MultiTexCoord2svARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3dARB)(GLenum target, GLdouble s, GLdouble t, GLdouble r) -{ - DISPATCH(MultiTexCoord3dARB, (target, s, t, r), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3dvARB)(GLenum target, const GLdouble *v) -{ - DISPATCH(MultiTexCoord3dvARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3fARB)(GLenum target, GLfloat s, GLfloat t, GLfloat r) -{ - DISPATCH(MultiTexCoord3fARB, (target, s, t, r), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3fvARB)(GLenum target, const GLfloat *v) -{ - DISPATCH(MultiTexCoord3fvARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3iARB)(GLenum target, GLint s, GLint t, GLint r) -{ - DISPATCH(MultiTexCoord3iARB, (target, s, t, r), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3ivARB)(GLenum target, const GLint *v) -{ - DISPATCH(MultiTexCoord3ivARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3sARB)(GLenum target, GLshort s, GLshort t, GLshort r) -{ - DISPATCH(MultiTexCoord3sARB, (target, s, t, r), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3svARB)(GLenum target, const GLshort *v) -{ - DISPATCH(MultiTexCoord3svARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4dARB)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) -{ - DISPATCH(MultiTexCoord4dARB, (target, s, t, r, q), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4dvARB)(GLenum target, const GLdouble *v) -{ - DISPATCH(MultiTexCoord4dvARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4fARB)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) -{ - DISPATCH(MultiTexCoord4fARB, (target, s, t, r, q), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4fvARB)(GLenum target, const GLfloat *v) -{ - DISPATCH(MultiTexCoord4fvARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4iARB)(GLenum target, GLint s, GLint t, GLint r, GLint q) -{ - DISPATCH(MultiTexCoord4iARB, (target, s, t, r, q), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4ivARB)(GLenum target, const GLint *v) -{ - DISPATCH(MultiTexCoord4ivARB, (target, v), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4sARB)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) -{ - DISPATCH(MultiTexCoord4sARB, (target, s, t, r, q), (F, ";")); -} - -KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4svARB)(GLenum target, const GLshort *v) -{ - DISPATCH(MultiTexCoord4svARB, (target, v), (F, ";")); -} - - - /*** *** Extension functions ***/ @@ -2448,7 +2274,7 @@ KEYWORD1 void KEYWORD2 NAME(GetPixelTexGenParameterivSGIS)(GLenum target, GLint /* 16. GL_SGIS_texture4D */ -KEYWORD1 void KEYWORD2 NAME(TexImage4DSGIS)(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels) +KEYWORD1 void KEYWORD2 NAME(TexImage4DSGIS)(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei extent, GLint border, GLenum format, GLenum type, const void *pixels) { DISPATCH(TexImage4DSGIS, (target, level, internalFormat, width, height, depth, extent, border, format, type, pixels), (F, ";")); } @@ -2624,6 +2450,16 @@ KEYWORD1 void KEYWORD2 NAME(PointParameterfvEXT)(GLenum target, const GLfloat *p DISPATCH(PointParameterfvEXT, (target, param), (F, ";")); } +KEYWORD1 void KEYWORD2 NAME(PointParameterfSGIS)(GLenum target, GLfloat param) +{ + DISPATCH(PointParameterfEXT, (target, param), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(PointParameterfvSGIS)(GLenum target, const GLfloat *param) +{ + DISPATCH(PointParameterfvEXT, (target, param), (F, ";")); +} + /* 55. GL_SGIX_instruments */ @@ -2816,7 +2652,6 @@ KEYWORD1 void KEYWORD2 NAME(IndexFuncEXT)(GLenum func, GLfloat ref) /* 97. GL_EXT_compiled_vertex_array */ - KEYWORD1 void KEYWORD2 NAME(LockArraysEXT)(GLint first, GLsizei count) { DISPATCH(LockArraysEXT, (first, count), (F, ";")); @@ -2933,6 +2768,112 @@ KEYWORD1 void KEYWORD2 NAME(LightEnviSGIX)(GLenum pname, GLint param) } +/* 112. GL_EXT_draw_range_elements */ +KEYWORD1 void KEYWORD2 NAME(DrawRangeElementsEXT)(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices) +{ + DISPATCH(DrawRangeElements, (mode, start, end, count, type, indices), (F, "glDrawRangeElementsEXT(0x%x, %u %u %d 0x%x %p);", mode, start, end, count, type, indices)); +} + + +/* 117. GL_EXT_light_texture */ +#if 00 +KEYWORD1 void KEYWORD2 NAME(ApplyTextureEXT)(GLenum mode) +{ + DISPATCH(ApplyTextureEXT, (mode), (F, "glApplyTextureEXT(0x%x);", mode)); +} + +KEYWORD1 void KEYWORD2 NAME(TextureLightEXT)(GLenum pname) +{ + DISPATCH(TextureLightEXT, (pname), (F, "glTextureLightEXT(0x%x);", pname)); +} + +KEYWORD1 void KEYWORD2 NAME(TextureMaterialEXT)(GLenum face, GLenum mode) +{ + DISPATCH(TextureMaterialEXT, (face, mode), (F, "glTextureMaterialEXT(0x%x, 0x%x);", face, mode)); +} +#endif + + + +/* 135. GL_INTEL_texture_scissor */ +#if 00 +KEYWORD1 void KEYWORD2 NAME(TexScissorINTEL)(GLenum target, GLclampf tlow, GLclampf thigh) +{ + DISPATCH(TexScissorINTEL, (target, tlow, thigh), (F, "glTexScissorINTEL(0x%x %g %g);", target, tlow, thigh)); +} + +KEYWORD1 void KEYWORD2 NAME(TexScissorFuncINTEL)(GLenum target, GLenum lfunc, GLenum hfunc) +{ + DISPATCH(TexScissorFuncINTEL, (target, lfunc, hfunc), (F, "glTexScissorFuncINTEL(0x%x 0x%x 0x%x);", target, tlow, thigh)); +} +#endif + + + +/* 136. GL_INTEL_parallel_arrays */ +#if 00 +KEYWORD1 void KEYWORD2 NAME(VertexPointervINTEL)(GLint size, GLenum type, const void ** pointer) +{ + DISPATCH(VertexPointervINTEL, (size, type, pointer), (F, "glVertexPointervINTEL(%d, 0x%x, %p);", size, type, pointer)); +} + +KEYWORD1 void KEYWORD2 NAME(NormalPointervINTEL)(GLenum type, const void** pointer) +{ + DISPATCH(NormalPointervINTEL, (size, pointer), (F, "glNormalPointervINTEL(%d, %p);", size, pointer)); +} + +KEYWORD1 void KEYWORD2 NAME(ColorPointervINTEL)(GLint size, GLenum type, const void** pointer) +{ + DISPATCH(ColorPointervINTEL, (size, type, pointer), (F, "glColorPointervINTEL(%d, 0x%x, %p);", size, type, pointer)); +} + +KEYWORD1 void KEYWORD2 NAME(TexCoordPointervINTEL)(GLint size, GLenum type, const void** pointer) +{ + DISPATCH(TexCoordPointervINTEL, (size, type, pointer), (F, "glTexCoordPointervINTEL(%d, 0x%x, %p);", size, type, pointer)); +} +#endif + + +/* 138. GL_EXT_pixel_transform */ +#if 0 +KEYWORD1 void KEYWORD2 NAME(PixelTransformParameteriEXT)(GLenum target, GLenum pname, const GLint param) +{ + DISPATCH(PixelTransformParameteriEXT, (target, pname, param), (F, "glPixelTransformParameteriEXT(0x%x, 0x%x, %d);", target, pname, param)); +} + +KEYWORD1 void KEYWORD2 NAME(PixelTransformParameterfEXT)(GLenum target, GLenum pname, const GLfloat param) +{ + DISPATCH(PixelTransformParameterfEXT, (target, pname, param), (F, "glPixelTransformParameterfEXT(0x%x, 0x%x, %f);", target, pname, param)); +} + +KEYWORD1 void KEYWORD2 NAME(PixelTransformParameterivEXT)(GLenum target, GLenum pname, const GLint *params) +{ + DISPATCH(PixelTransformParameterivEXT, (target, pname, params), (F, "glPixelTransformParameterivEXT(0x%x, 0x%x, %p);", target, pname, params)); +} + +KEYWORD1 void KEYWORD2 NAME(PixelTransformParameterfvEXT)(GLenum target, GLenum pname, const GLfloat *params) +{ + DISPATCH(PixelTransformParameterfvEXT, (target, pname, params), (F, "glPixelTransformParameterfvEXT(0x%x, 0x%x, %p);", target, pname, params)); +} + +KEYWORD1 void KEYWORD2 NAME(GetPixelTransformParameterivEXT)(GLenum target, GLenum pname, const GLint *params) +{ + DISPATCH(GetPixelTransformParameterivEXT, (target, pname, params), (F, "glGetPixelTransformParameterivEXT(0x%x, 0x%x, %p);", target, pname, params)); +} + +KEYWORD1 void KEYWORD2 NAME(GetPixelTransformParameterfvEXT)(GLenum target, GLenum pname, const GLfloat *params) +{ + DISPATCH(GetPixelTransformParameterfvEXT, (target, pname, params), (F, "glGetPixelTransformParameterfvEXT(0x%x, 0x%x, %p);", target, pname, params)); +} +#endif + + + +/* 145. GL_EXT_secondary_color */ +/* XXX todo */ + + + /* 149. GL_EXT_fog_coord */ KEYWORD1 void KEYWORD2 NAME(FogCoordfEXT)(GLfloat coord) { @@ -3080,7 +3021,6 @@ KEYWORD1 void KEYWORD2 NAME(ResizeBuffersMESA)(void) /* 197. GL_MESA_window_pos */ - KEYWORD1 void KEYWORD2 NAME(WindowPos2iMESA)(GLint x, GLint y) { DISPATCH(WindowPos2iMESA, (x, y), (F, ";")); @@ -3202,8 +3142,201 @@ KEYWORD1 void KEYWORD2 NAME(WindowPos4dvMESA)(const GLdouble *p) } +/* 208. GL_3DFX_tbuffer */ +KEYWORD1 void KEYWORD2 NAME(TbufferMask3DFX)(GLuint mask) +{ + DISPATCH(TbufferMask3DFX, (mask), (F, "glTbufferMask3DFX(0x%x);", mask)); +} + + +/* 209. WGL_EXT_multisample */ + +KEYWORD1 void KEYWORD2 NAME(SampleMaskEXT)(GLclampf value, GLboolean invert) +{ + DISPATCH(SampleMaskSGIS, (value, invert), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(SamplePatternEXT)(GLenum pattern) +{ + DISPATCH(SamplePatternSGIS, (pattern), (F, ";")); +} + + +/* ARB 1. GL_ARB_multitexture */ + +KEYWORD1 void KEYWORD2 NAME(ActiveTextureARB)(GLenum texture) +{ + DISPATCH(ActiveTextureARB, (texture), (F, ";")); +} -/* ARB 2. GL_ARB_transpose_matrix */ +KEYWORD1 void KEYWORD2 NAME(ClientActiveTextureARB)(GLenum texture) +{ + DISPATCH(ClientActiveTextureARB, (texture), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1dARB)(GLenum target, GLdouble s) +{ + DISPATCH(MultiTexCoord1dARB, (target, s), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1dvARB)(GLenum target, const GLdouble *v) +{ + DISPATCH(MultiTexCoord1dvARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1fARB)(GLenum target, GLfloat s) +{ + DISPATCH(MultiTexCoord1fARB, (target, s), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1fvARB)(GLenum target, const GLfloat *v) +{ + DISPATCH(MultiTexCoord1fvARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1iARB)(GLenum target, GLint s) +{ + DISPATCH(MultiTexCoord1iARB, (target, s), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1ivARB)(GLenum target, const GLint *v) +{ + DISPATCH(MultiTexCoord1ivARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1sARB)(GLenum target, GLshort s) +{ + DISPATCH(MultiTexCoord1sARB, (target, s), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord1svARB)(GLenum target, const GLshort *v) +{ + DISPATCH(MultiTexCoord1svARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2dARB)(GLenum target, GLdouble s, GLdouble t) +{ + DISPATCH(MultiTexCoord2dARB, (target, s, t), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2dvARB)(GLenum target, const GLdouble *v) +{ + DISPATCH(MultiTexCoord2dvARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2fARB)(GLenum target, GLfloat s, GLfloat t) +{ + DISPATCH(MultiTexCoord2fARB, (target, s, t), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2fvARB)(GLenum target, const GLfloat *v) +{ + DISPATCH(MultiTexCoord2fvARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2iARB)(GLenum target, GLint s, GLint t) +{ + DISPATCH(MultiTexCoord2iARB, (target, s, t), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2ivARB)(GLenum target, const GLint *v) +{ + DISPATCH(MultiTexCoord2ivARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2sARB)(GLenum target, GLshort s, GLshort t) +{ + DISPATCH(MultiTexCoord2sARB, (target, s, t), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord2svARB)(GLenum target, const GLshort *v) +{ + DISPATCH(MultiTexCoord2svARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3dARB)(GLenum target, GLdouble s, GLdouble t, GLdouble r) +{ + DISPATCH(MultiTexCoord3dARB, (target, s, t, r), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3dvARB)(GLenum target, const GLdouble *v) +{ + DISPATCH(MultiTexCoord3dvARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3fARB)(GLenum target, GLfloat s, GLfloat t, GLfloat r) +{ + DISPATCH(MultiTexCoord3fARB, (target, s, t, r), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3fvARB)(GLenum target, const GLfloat *v) +{ + DISPATCH(MultiTexCoord3fvARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3iARB)(GLenum target, GLint s, GLint t, GLint r) +{ + DISPATCH(MultiTexCoord3iARB, (target, s, t, r), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3ivARB)(GLenum target, const GLint *v) +{ + DISPATCH(MultiTexCoord3ivARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3sARB)(GLenum target, GLshort s, GLshort t, GLshort r) +{ + DISPATCH(MultiTexCoord3sARB, (target, s, t, r), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord3svARB)(GLenum target, const GLshort *v) +{ + DISPATCH(MultiTexCoord3svARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4dARB)(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) +{ + DISPATCH(MultiTexCoord4dARB, (target, s, t, r, q), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4dvARB)(GLenum target, const GLdouble *v) +{ + DISPATCH(MultiTexCoord4dvARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4fARB)(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) +{ + DISPATCH(MultiTexCoord4fARB, (target, s, t, r, q), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4fvARB)(GLenum target, const GLfloat *v) +{ + DISPATCH(MultiTexCoord4fvARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4iARB)(GLenum target, GLint s, GLint t, GLint r, GLint q) +{ + DISPATCH(MultiTexCoord4iARB, (target, s, t, r, q), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4ivARB)(GLenum target, const GLint *v) +{ + DISPATCH(MultiTexCoord4ivARB, (target, v), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4sARB)(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) +{ + DISPATCH(MultiTexCoord4sARB, (target, s, t, r, q), (F, ";")); +} + +KEYWORD1 void KEYWORD2 NAME(MultiTexCoord4svARB)(GLenum target, const GLshort *v) +{ + DISPATCH(MultiTexCoord4svARB, (target, v), (F, ";")); +} + + + +/* ARB 3. GL_ARB_transpose_matrix */ KEYWORD1 void KEYWORD2 NAME(LoadTransposeMatrixdARB)(const GLdouble m[16]) { DISPATCH(LoadTransposeMatrixdARB, (m), (F, "glLoadTransposeMatrixARB(%p);", m)); @@ -3225,13 +3358,13 @@ KEYWORD1 void KEYWORD2 NAME(MultTransposeMatrixfARB)(const GLfloat m[16]) } -/* ARB 4. GL_ARB_multisample */ + +/* ARB 5. GL_ARB_multisample */ KEYWORD1 void KEYWORD2 NAME(SampleCoverageARB)(GLclampf value, GLboolean invert) { DISPATCH(SampleCoverageARB, (value, invert), (F, "glSampleCoverageARB(%f, %d);", value, invert)); } - KEYWORD1 void KEYWORD2 NAME(SamplePassARB)(GLenum pass) { DISPATCH(SamplePassARB, (pass), (F, "glSamplePassARB(0x%x);", pass)); @@ -3239,6 +3372,44 @@ KEYWORD1 void KEYWORD2 NAME(SamplePassARB)(GLenum pass) +/* ARB 12. GL_ARB_texture_compression */ +KEYWORD1 void KEYWORD2 NAME(CompressedTexImage3DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data) +{ + DISPATCH(CompressedTexImage3DARB, (target, level, internalformat, width, height, depth, border, imageSize, data), (F, "glCompressedTexImage3DARB();")); +} + +KEYWORD1 void KEYWORD2 NAME(CompressedTexImage2DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data) +{ + DISPATCH(CompressedTexImage2DARB, (target, level, internalformat, width, height, border, imageSize, data), (F, "glCompressedTexImage2DARB();")); +} + +KEYWORD1 void KEYWORD2 NAME(CompressedTexImage1DARB)(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data) +{ + DISPATCH(CompressedTexImage1DARB, (target, level, internalformat, width, border, imageSize, data), (F, "glCompressedTexImage1DARB();")); +} + +KEYWORD1 void KEYWORD2 NAME(CompressedTexSubImage3DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data) +{ + DISPATCH(CompressedTexSubImage3DARB, (target, level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data), (F, "glCompressedTexSubImage3DARB();")); +} + +KEYWORD1 void KEYWORD2 NAME(CompressedTexSubImage2DARB)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data) +{ + DISPATCH(CompressedTexSubImage2DARB, (target, level, xoffset, yoffset, width, height, format, imageSize, data), (F, "glCompressedTexSubImage2DARB();")); +} + +KEYWORD1 void KEYWORD2 NAME(CompressedTexSubImage1DARB)(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data) +{ + DISPATCH(CompressedTexSubImage1DARB, (target, level, xoffset, width, format, imageSize, data), (F, "glCompressedTexSubImage1DARB();")); +} + +KEYWORD1 void KEYWORD2 NAME(GetCompressedTexImageARB)(GLenum target, GLint lod, GLvoid *img) +{ + DISPATCH(GetCompressedTexImageARB, (target, lod, img), (F, "glGetCompressedTexImageARB();")); +} + + + #undef KEYWORD1 #undef KEYWORD2 #undef NAME diff --git a/xc/extras/Mesa/src/glheader.h b/xc/extras/Mesa/src/glheader.h index 4789ec7a3..00748699d 100644 --- a/xc/extras/Mesa/src/glheader.h +++ b/xc/extras/Mesa/src/glheader.h @@ -51,6 +51,9 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> +#if defined(__linux__) && defined(__i386__) +#include <fpu_control.h> +#endif #endif #include <float.h> @@ -59,16 +62,104 @@ #include "conf.h" #endif +/* Make sure we include glext.h */ #include "GL/gl.h" #include "GL/glext.h" + /* * Put compiler/OS/assembly pragmas and macros here to avoid * cluttering other source files. */ + +/* + * XXX move as many of these pragma's and MS Windows-isms into + * the new src/glheader.h file. + */ + +#if defined(_WIN32) && !defined(__WIN32__) +# define __WIN32__ +#endif + +#if !defined(OPENSTEP) && (defined(__WIN32__) || defined(__CYGWIN__)) +# pragma warning( disable : 4068 ) /* unknown pragma */ +# pragma warning( disable : 4710 ) /* function 'foo' not inlined */ +# pragma warning( disable : 4711 ) /* function 'foo' selected for automatic inline expansion */ +# pragma warning( disable : 4127 ) /* conditional expression is constant */ +# if defined(MESA_MINWARN) +# pragma warning( disable : 4244 ) /* '=' : conversion from 'const double ' to 'float ', possible loss of data */ +# pragma warning( disable : 4018 ) /* '<' : signed/unsigned mismatch */ +# pragma warning( disable : 4305 ) /* '=' : truncation from 'const double ' to 'float ' */ +# pragma warning( disable : 4550 ) /* 'function' undefined; assuming extern returning int */ +# pragma warning( disable : 4761 ) /* integral size mismatch in argument; conversion supplied */ +# endif +# if defined(_MSC_VER) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */ +# define GLAPI __declspec(dllexport) +# define WGLAPI __declspec(dllexport) +# elif defined(_MSC_VER) && defined(_DLL) /* tag specifying we're building for DLL runtime support */ +# define GLAPI __declspec(dllimport) +# define WGLAPI __declspec(dllimport) +# else /* for use with static link lib build of Win32 edition only */ +# define GLAPI extern +# define WGLAPI __declspec(dllimport) +# endif /* _STATIC_MESA support */ +# define GLAPIENTRY __stdcall +# define GLAPIENTRYP __stdcall * +# define GLCALLBACK __stdcall +# define GLCALLBACKP __stdcall * +# if defined(__CYGWIN__) +# define GLCALLBACKPCAST * +# else +# define GLCALLBACKPCAST __stdcall * +# endif +# define GLWINAPI __stdcall +# define GLWINAPIV __cdecl +#else +/* non-Windows compilation */ +# define GLAPI extern +# define GLAPIENTRY +# define GLAPIENTRYP * +# define GLCALLBACK +# define GLCALLBACKP * +# define GLCALLBACKPCAST * +# define GLWINAPI +# define GLWINAPIV +#endif /* WIN32 / CYGWIN bracket */ + +/* compatability guard so we don't need to change client code */ + +#if defined(_WIN32) && !defined(_WINDEF_) && !defined(_GNU_H_WINDOWS32_BASE) && !defined(OPENSTEP) +# define CALLBACK GLCALLBACK +typedef int (GLAPIENTRY *PROC)(); +typedef void *HGLRC; +typedef void *HDC; +typedef unsigned long COLORREF; +#endif + +#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) +# define WGL_FONT_LINES 0 +# define WGL_FONT_POLYGONS 1 +#ifndef _GNU_H_WINDOWS32_FUNCTIONS +# ifdef UNICODE +# define wglUseFontBitmaps wglUseFontBitmapsW +# define wglUseFontOutlines wglUseFontOutlinesW +# else +# define wglUseFontBitmaps wglUseFontBitmapsA +# define wglUseFontOutlines wglUseFontOutlinesA +# endif /* !UNICODE */ +#endif /* _GNU_H_WINDOWS32_FUNCTIONS */ +typedef struct tagLAYERPLANEDESCRIPTOR LAYERPLANEDESCRIPTOR, *PLAYERPLANEDESCRIPTOR, *LPLAYERPLANEDESCRIPTOR; +typedef struct _GLYPHMETRICSFLOAT GLYPHMETRICSFLOAT, *PGLYPHMETRICSFLOAT, *LPGLYPHMETRICSFLOAT; +typedef struct tagPIXELFORMATDESCRIPTOR PIXELFORMATDESCRIPTOR, *PPIXELFORMATDESCRIPTOR, *LPPIXELFORMATDESCRIPTOR; +#include <gl/mesa_wgl.h> +#endif + + + + /* Disable unreachable code warnings for Watcom C++ */ #ifdef __WATCOMC__ #pragma disable_message(201) diff --git a/xc/extras/Mesa/src/hint.c b/xc/extras/Mesa/src/hint.c index 210138d2b..6537bd004 100644 --- a/xc/extras/Mesa/src/hint.c +++ b/xc/extras/Mesa/src/hint.c @@ -52,78 +52,94 @@ _mesa_try_Hint( GLcontext *ctx, GLenum target, GLenum mode ) if (MESA_VERBOSE & VERBOSE_API) fprintf(stderr, "glHint %s %d\n", gl_lookup_enum_by_nr(target), mode); + if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { + gl_error(ctx, GL_INVALID_ENUM, "glHint(mode)"); + return GL_FALSE; + } + switch (target) { - case GL_FOG_HINT: - ctx->Hint.Fog = mode; - break; - case GL_LINE_SMOOTH_HINT: - ctx->Hint.LineSmooth = mode; - break; - case GL_PERSPECTIVE_CORRECTION_HINT: - ctx->Hint.PerspectiveCorrection = mode; - break; - case GL_POINT_SMOOTH_HINT: - ctx->Hint.PointSmooth = mode; - break; - case GL_POLYGON_SMOOTH_HINT: - ctx->Hint.PolygonSmooth = mode; - break; - case GL_PREFER_DOUBLEBUFFER_HINT_PGI: - case GL_STRICT_DEPTHFUNC_HINT_PGI: - break; - case GL_STRICT_LIGHTING_HINT_PGI: - ctx->Hint.StrictLighting = mode; - break; - case GL_STRICT_SCISSOR_HINT_PGI: - case GL_FULL_STIPPLE_HINT_PGI: - case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI: - case GL_NATIVE_GRAPHICS_END_HINT_PGI: - case GL_CONSERVE_MEMORY_HINT_PGI: - case GL_RECLAIM_MEMORY_HINT_PGI: - break; - case GL_ALWAYS_FAST_HINT_PGI: - if (mode) { - ctx->Hint.AllowDrawWin = GL_TRUE; - ctx->Hint.AllowDrawSpn = GL_FALSE; - ctx->Hint.AllowDrawMem = GL_FALSE; - } else { - ctx->Hint.AllowDrawWin = GL_TRUE; - ctx->Hint.AllowDrawSpn = GL_TRUE; - ctx->Hint.AllowDrawMem = GL_TRUE; - } - break; - case GL_ALWAYS_SOFT_HINT_PGI: - ctx->Hint.AllowDrawWin = GL_TRUE; - ctx->Hint.AllowDrawSpn = GL_TRUE; - ctx->Hint.AllowDrawMem = GL_TRUE; - break; - case GL_ALLOW_DRAW_OBJ_HINT_PGI: - break; - case GL_ALLOW_DRAW_WIN_HINT_PGI: - ctx->Hint.AllowDrawWin = mode; - break; - case GL_ALLOW_DRAW_SPN_HINT_PGI: - ctx->Hint.AllowDrawSpn = mode; - break; - case GL_ALLOW_DRAW_MEM_HINT_PGI: - ctx->Hint.AllowDrawMem = mode; - break; - case GL_CLIP_NEAR_HINT_PGI: - case GL_CLIP_FAR_HINT_PGI: - case GL_WIDE_LINE_HINT_PGI: - case GL_BACK_NORMALS_HINT_PGI: - case GL_NATIVE_GRAPHICS_HANDLE_PGI: - break; + case GL_FOG_HINT: + ctx->Hint.Fog = mode; + break; + case GL_LINE_SMOOTH_HINT: + ctx->Hint.LineSmooth = mode; + break; + case GL_PERSPECTIVE_CORRECTION_HINT: + ctx->Hint.PerspectiveCorrection = mode; + break; + case GL_POINT_SMOOTH_HINT: + ctx->Hint.PointSmooth = mode; + break; + case GL_POLYGON_SMOOTH_HINT: + ctx->Hint.PolygonSmooth = mode; + break; + case GL_PREFER_DOUBLEBUFFER_HINT_PGI: + case GL_STRICT_DEPTHFUNC_HINT_PGI: + break; + case GL_STRICT_LIGHTING_HINT_PGI: + ctx->Hint.StrictLighting = mode; + break; + case GL_STRICT_SCISSOR_HINT_PGI: + case GL_FULL_STIPPLE_HINT_PGI: + case GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI: + case GL_NATIVE_GRAPHICS_END_HINT_PGI: + case GL_CONSERVE_MEMORY_HINT_PGI: + case GL_RECLAIM_MEMORY_HINT_PGI: + break; + case GL_ALWAYS_FAST_HINT_PGI: + if (mode) { + ctx->Hint.AllowDrawWin = GL_TRUE; + ctx->Hint.AllowDrawFrg = GL_FALSE; + ctx->Hint.AllowDrawMem = GL_FALSE; + } else { + ctx->Hint.AllowDrawWin = GL_TRUE; + ctx->Hint.AllowDrawFrg = GL_TRUE; + ctx->Hint.AllowDrawMem = GL_TRUE; + } + break; + case GL_ALWAYS_SOFT_HINT_PGI: + ctx->Hint.AllowDrawWin = GL_TRUE; + ctx->Hint.AllowDrawFrg = GL_TRUE; + ctx->Hint.AllowDrawMem = GL_TRUE; + break; + case GL_ALLOW_DRAW_OBJ_HINT_PGI: + break; + case GL_ALLOW_DRAW_WIN_HINT_PGI: + ctx->Hint.AllowDrawWin = mode; + break; + case GL_ALLOW_DRAW_FRG_HINT_PGI: + ctx->Hint.AllowDrawFrg = mode; + break; + case GL_ALLOW_DRAW_MEM_HINT_PGI: + ctx->Hint.AllowDrawMem = mode; + break; + case GL_CLIP_NEAR_HINT_PGI: + case GL_CLIP_FAR_HINT_PGI: + case GL_WIDE_LINE_HINT_PGI: + case GL_BACK_NORMALS_HINT_PGI: + case GL_NATIVE_GRAPHICS_HANDLE_PGI: + break; /* GL_EXT_clip_volume_hint */ - case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: - ctx->Hint.ClipVolumeClipping = mode; - break; + case GL_CLIP_VOLUME_CLIPPING_HINT_EXT: + ctx->Hint.ClipVolumeClipping = mode; + break; - default: - gl_error( ctx, GL_INVALID_ENUM, "glHint(target)" ); - return GL_FALSE; + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSION_HINT_ARB: + if (ctx->Extensions.HaveTextureCompression) { + ctx->Hint.TextureCompression = mode; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glHint(target)"); + } + break; + + default: + gl_error(ctx, GL_INVALID_ENUM, "glHint(target)"); + return GL_FALSE; } + ctx->NewState |= NEW_ALL; /* just to be safe */ if (ctx->Driver.Hint) { @@ -143,6 +159,11 @@ _mesa_HintPGI( GLenum target, GLint mode ) if (MESA_VERBOSE & VERBOSE_API) fprintf(stderr, "glHintPGI %s %d\n", gl_lookup_enum_by_nr(target), mode); + if (mode != GL_NICEST && mode != GL_FASTEST && mode != GL_DONT_CARE) { + gl_error(ctx, GL_INVALID_ENUM, "glHintPGI(mode)"); + return; + } + switch (target) { case GL_PREFER_DOUBLEBUFFER_HINT_PGI: case GL_STRICT_DEPTHFUNC_HINT_PGI: @@ -157,7 +178,7 @@ _mesa_HintPGI( GLenum target, GLint mode ) case GL_ALWAYS_SOFT_HINT_PGI: case GL_ALLOW_DRAW_OBJ_HINT_PGI: case GL_ALLOW_DRAW_WIN_HINT_PGI: - case GL_ALLOW_DRAW_SPN_HINT_PGI: + case GL_ALLOW_DRAW_FRG_HINT_PGI: case GL_ALLOW_DRAW_MEM_HINT_PGI: case GL_CLIP_NEAR_HINT_PGI: case GL_CLIP_FAR_HINT_PGI: diff --git a/xc/extras/Mesa/src/image.c b/xc/extras/Mesa/src/image.c index 16c8d4921..825ce7ed5 100644 --- a/xc/extras/Mesa/src/image.c +++ b/xc/extras/Mesa/src/image.c @@ -30,6 +30,7 @@ #include "glheader.h" #include "context.h" #include "image.h" +#include "imaging.h" #include "macros.h" #include "mem.h" #include "mmath.h" @@ -46,7 +47,7 @@ * from within display lists we have to be sure to set the current * unpacking params to these values! */ -struct gl_pixelstore_attrib _mesa_native_packing = { +const struct gl_pixelstore_attrib _mesa_native_packing = { 1, /* Alignment */ 0, /* RowLength */ 0, /* SkipPixels */ @@ -62,7 +63,8 @@ struct gl_pixelstore_attrib _mesa_native_packing = { /* * Flip the 8 bits in each byte of the given array. */ -void gl_flip_bytes( GLubyte *p, GLuint n ) +static void +flip_bytes( GLubyte *p, GLuint n ) { register GLuint i, a, b; @@ -84,7 +86,8 @@ void gl_flip_bytes( GLubyte *p, GLuint n ) /* * Flip the order of the 2 bytes in each word in the given array. */ -void gl_swap2( GLushort *p, GLuint n ) +void +_mesa_swap2( GLushort *p, GLuint n ) { register GLuint i; @@ -98,7 +101,8 @@ void gl_swap2( GLushort *p, GLuint n ) /* * Flip the order of the 4 bytes in each word in the given array. */ -void gl_swap4( GLuint *p, GLuint n ) +void +_mesa_swap4( GLuint *p, GLuint n ) { register GLuint i, a, b; @@ -120,7 +124,7 @@ void gl_swap4( GLuint *p, GLuint n ) * Return 0 if GL_BITMAP. * Return -1 if invalid type enum. */ -GLint gl_sizeof_type( GLenum type ) +GLint _mesa_sizeof_type( GLenum type ) { switch (type) { case GL_BITMAP: @@ -146,10 +150,10 @@ GLint gl_sizeof_type( GLenum type ) /* - * Same as gl_sizeof_packed_type() but we also accept the + * Same as _mesa_sizeof_packed_type() but we also accept the * packed pixel format datatypes. */ -GLint gl_sizeof_packed_type( GLenum type ) +GLint _mesa_sizeof_packed_type( GLenum type ) { switch (type) { case GL_BITMAP: @@ -203,7 +207,7 @@ GLint gl_sizeof_packed_type( GLenum type ) * Return the number of components in a GL enum pixel type. * Return -1 if bad format. */ -GLint gl_components_in_format( GLenum format ) +GLint _mesa_components_in_format( GLenum format ) { switch (format) { case GL_COLOR_INDEX: @@ -220,6 +224,7 @@ GLint gl_components_in_format( GLenum format ) case GL_BLUE: case GL_ALPHA: case GL_LUMINANCE: + case GL_INTENSITY: return 1; case GL_LUMINANCE_ALPHA: return 2; @@ -243,9 +248,9 @@ GLint gl_components_in_format( GLenum format ) * Return bytes per pixel for given format and type * Return -1 if bad format or type. */ -GLint gl_bytes_per_pixel( GLenum format, GLenum type ) +GLint _mesa_bytes_per_pixel( GLenum format, GLenum type ) { - GLint comps = gl_components_in_format( format ); + GLint comps = _mesa_components_in_format( format ); if (comps < 0) return -1; @@ -301,7 +306,8 @@ GLint gl_bytes_per_pixel( GLenum format, GLenum type ) * Test if the given pixel format and type are legal. * Return GL_TRUE for legal, GL_FALSE for illegal. */ -GLboolean gl_is_legal_format_and_type( GLenum format, GLenum type ) +GLboolean +_mesa_is_legal_format_and_type( GLenum format, GLenum type ) { switch (format) { case GL_COLOR_INDEX: @@ -399,10 +405,11 @@ GLboolean gl_is_legal_format_and_type( GLenum format, GLenum type ) * row, column - location of pixel in the image * Return: address of pixel at (image,row,column) in image or NULL if error. */ -GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, GLsizei width, - GLsizei height, GLenum format, GLenum type, - GLint img, GLint row, GLint column ) +GLvoid * +_mesa_image_address( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, GLsizei width, + GLsizei height, GLenum format, GLenum type, + GLint img, GLint row, GLint column ) { GLint alignment; /* 1, 2 or 4 */ GLint pixels_per_row; @@ -437,13 +444,13 @@ GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, GLint bytes_per_image; /* Compute bytes per component */ - bytes_per_comp = gl_sizeof_packed_type( type ); + bytes_per_comp = _mesa_sizeof_packed_type( type ); if (bytes_per_comp<0) { return NULL; } /* Compute number of components per pixel */ - comp_per_pixel = gl_components_in_format( format ); + comp_per_pixel = _mesa_components_in_format( format ); if (comp_per_pixel<0 && type != GL_BITMAP) { return NULL; } @@ -462,7 +469,7 @@ GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, /* Non-BITMAP data */ GLint bytes_per_pixel, bytes_per_row, remainder, bytes_per_image; - bytes_per_pixel = gl_bytes_per_pixel( format, type ); + bytes_per_pixel = _mesa_bytes_per_pixel( format, type ); /* The pixel type and format should have been error checked earlier */ assert(bytes_per_pixel > 0); @@ -489,25 +496,69 @@ GLvoid *gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, /* - * Unpack a 32x32 pixel polygon stipple from user memory using the - * current pixel unpack settings. + * Compute the stride between image rows (in bytes) for the given + * pixel packing parameters and image width, format and type. */ -void gl_unpack_polygon_stipple( const GLcontext *ctx, - const GLubyte *pattern, GLuint dest[32] ) +GLint +_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, + GLint width, GLenum format, GLenum type ) { - GLint i; - for (i = 0; i < 32; i++) { - GLubyte *src = (GLubyte *) gl_pixel_addr_in_image( &ctx->Unpack, pattern, - 32, 32, GL_COLOR_INDEX, GL_BITMAP, 0, i, 0 ); - dest[i] = (src[0] << 24) - | (src[1] << 16) - | (src[2] << 8) - | (src[3] ); + ASSERT(packing); + if (type == GL_BITMAP) { + /* BITMAP data */ + if (packing->RowLength == 0) { + GLint bytes = (width + 7) / 8; + return bytes; + } + else { + GLint bytes = (packing->RowLength + 7) / 8; + return bytes; + } } + else { + /* Non-BITMAP data */ + const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); + GLint bytesPerRow, remainder; + if (bytesPerPixel <= 0) + return -1; /* error */ + if (packing->RowLength == 0) { + bytesPerRow = bytesPerPixel * width; + } + else { + bytesPerRow = bytesPerPixel * packing->RowLength; + } + remainder = bytesPerRow % packing->Alignment; + if (remainder > 0) + bytesPerRow += (packing->Alignment - remainder); + return bytesPerRow; + } +} + + - /* Bit flipping within each byte */ - if (ctx->Unpack.LsbFirst) { - gl_flip_bytes( (GLubyte *) dest, 32 * 4 ); +/* + * Unpack a 32x32 pixel polygon stipple from user memory using the + * current pixel unpack settings. + */ +void +_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], + const struct gl_pixelstore_attrib *unpacking ) +{ + GLubyte *ptrn = (GLubyte *) _mesa_unpack_bitmap( 32, 32, pattern, unpacking ); + if (ptrn) { + /* Convert pattern from GLubytes to GLuints and handle big/little + * endian differences + */ + GLubyte *p = ptrn; + GLint i; + for (i = 0; i < 32; i++) { + dest[i] = (p[0] << 24) + | (p[1] << 16) + | (p[2] << 8) + | (p[3] ); + p += 4; + } + FREE(ptrn); } } @@ -517,24 +568,23 @@ void gl_unpack_polygon_stipple( const GLcontext *ctx, * Pack polygon stipple into user memory given current pixel packing * settings. */ -void gl_pack_polygon_stipple( const GLcontext *ctx, - const GLuint pattern[32], - GLubyte *dest ) +void +_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, + const struct gl_pixelstore_attrib *packing ) { + /* Convert pattern from GLuints to GLubytes to handle big/little + * endian differences. + */ + GLubyte ptrn[32*4]; GLint i; for (i = 0; i < 32; i++) { - GLubyte *dst = (GLubyte *) gl_pixel_addr_in_image( &ctx->Pack, dest, - 32, 32, GL_COLOR_INDEX, GL_BITMAP, 0, i, 0 ); - dst[0] = (pattern[i] >> 24) & 0xff; - dst[1] = (pattern[i] >> 16) & 0xff; - dst[2] = (pattern[i] >> 8) & 0xff; - dst[3] = (pattern[i] ) & 0xff; - - /* Bit flipping within each byte */ - if (ctx->Pack.LsbFirst) { - gl_flip_bytes( (GLubyte *) dst, 4 ); - } + ptrn[i * 4 + 0] = (GLubyte) ((pattern[i] >> 24) & 0xff); + ptrn[i * 4 + 1] = (GLubyte) ((pattern[i] >> 16) & 0xff); + ptrn[i * 4 + 2] = (GLubyte) ((pattern[i] >> 8 ) & 0xff); + ptrn[i * 4 + 3] = (GLubyte) ((pattern[i] ) & 0xff); } + + _mesa_pack_bitmap(32, 32, ptrn, dest, packing); } @@ -554,66 +604,100 @@ void gl_pack_polygon_stipple( const GLcontext *ctx, * packing - pixel packing parameters * applyTransferOps - apply scale/bias/lookup-table ops? */ -void gl_pack_rgba_span( const GLcontext *ctx, - GLuint n, CONST GLubyte rgba[][4], - GLenum format, GLenum type, GLvoid *destination, - const struct gl_pixelstore_attrib *packing, - GLboolean applyTransferOps ) +void +_mesa_pack_rgba_span( GLcontext *ctx, + GLuint n, CONST GLubyte srcRgba[][4], + GLenum format, GLenum type, GLvoid *destination, + const struct gl_pixelstore_attrib *packing, + GLboolean applyTransferOps ) { - applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag); + applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled || + ctx->Pixel.HistogramEnabled); /* Test for optimized case first */ if (!applyTransferOps && format == GL_RGBA && type == GL_UNSIGNED_BYTE) { /* common simple case */ - MEMCPY( destination, rgba, n * 4 * sizeof(GLubyte) ); + MEMCPY( destination, srcRgba, n * 4 * sizeof(GLubyte) ); } else if (!applyTransferOps && format == GL_RGB && type == GL_UNSIGNED_BYTE) { /* common simple case */ GLint i; GLubyte *dest = (GLubyte *) destination; for (i = 0; i < n; i++) { - dest[0] = rgba[i][RCOMP]; - dest[1] = rgba[i][GCOMP]; - dest[2] = rgba[i][BCOMP]; + dest[0] = srcRgba[i][RCOMP]; + dest[1] = srcRgba[i][GCOMP]; + dest[2] = srcRgba[i][BCOMP]; dest += 3; } } else { /* general solution */ - GLfloat red[MAX_WIDTH], green[MAX_WIDTH], blue[MAX_WIDTH]; - GLfloat alpha[MAX_WIDTH], luminance[MAX_WIDTH]; + GLfloat rgba[MAX_WIDTH][4], luminance[MAX_WIDTH]; const GLfloat rscale = 1.0F / 255.0F; const GLfloat gscale = 1.0F / 255.0F; const GLfloat bscale = 1.0F / 255.0F; const GLfloat ascale = 1.0F / 255.0F; - const GLint comps = gl_components_in_format(format); + const GLint comps = _mesa_components_in_format(format); GLuint i; assert(n <= MAX_WIDTH); /* convert color components to floating point */ for (i=0;i<n;i++) { - red[i] = rgba[i][RCOMP] * rscale; - green[i] = rgba[i][GCOMP] * gscale; - blue[i] = rgba[i][BCOMP] * bscale; - alpha[i] = rgba[i][ACOMP] * ascale; + rgba[i][RCOMP] = srcRgba[i][RCOMP] * rscale; + rgba[i][GCOMP] = srcRgba[i][GCOMP] * gscale; + rgba[i][BCOMP] = srcRgba[i][BCOMP] * bscale; + rgba[i][ACOMP] = srcRgba[i][ACOMP] * ascale; } /* * Apply scale, bias and lookup-tables if enabled. */ if (applyTransferOps) { + /* scale & bias */ if (ctx->Pixel.ScaleOrBiasRGBA) { - gl_scale_and_bias_color( ctx, n, red, green, blue, alpha ); + _mesa_scale_and_bias_rgba( ctx, n, rgba ); } + /* color map lookup */ if (ctx->Pixel.MapColorFlag) { - gl_map_color( ctx, n, red, green, blue, alpha ); + _mesa_map_rgba( ctx, n, rgba ); + } + /* GL_COLOR_TABLE lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, n, rgba); + } + /* XXX convolution here */ + /* XXX post-convolution color table look-up here */ + /* color matrix */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, n, rgba); + } + /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ + if (ctx->Pixel.PostColorMatrixColorTableEnabled) { + _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba); + } + /* update histogram count */ + if (ctx->Pixel.HistogramEnabled) { + _mesa_update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba); + } + /* XXX min/max here */ + if (ctx->Pixel.MinMaxEnabled) { + _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba); + if (ctx->MinMax.Sink) + return; } } if (format==GL_LUMINANCE || format==GL_LUMINANCE_ALPHA) { for (i=0;i<n;i++) { - GLfloat sum = red[i] + green[i] + blue[i]; + GLfloat sum = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; luminance[i] = CLAMP( sum, 0.0F, 1.0F ); } } @@ -628,19 +712,19 @@ void gl_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UBYTE(red[i]); + dst[i] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UBYTE(green[i]); + dst[i] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UBYTE(blue[i]); + dst[i] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UBYTE(alpha[i]); + dst[i] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -649,49 +733,49 @@ void gl_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_UBYTE(luminance[i]); - dst[i*2+1] = FLOAT_TO_UBYTE(alpha[i]); + dst[i*2+1] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_UBYTE(red[i]); - dst[i*3+1] = FLOAT_TO_UBYTE(green[i]); - dst[i*3+2] = FLOAT_TO_UBYTE(blue[i]); + dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UBYTE(red[i]); - dst[i*4+1] = FLOAT_TO_UBYTE(green[i]); - dst[i*4+2] = FLOAT_TO_UBYTE(blue[i]); - dst[i*4+3] = FLOAT_TO_UBYTE(alpha[i]); + dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_UBYTE(blue[i]); - dst[i*3+1] = FLOAT_TO_UBYTE(green[i]); - dst[i*3+2] = FLOAT_TO_UBYTE(red[i]); + dst[i*3+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UBYTE(blue[i]); - dst[i*4+1] = FLOAT_TO_UBYTE(green[i]); - dst[i*4+2] = FLOAT_TO_UBYTE(red[i]); - dst[i*4+3] = FLOAT_TO_UBYTE(alpha[i]); + dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UBYTE(alpha[i]); - dst[i*4+1] = FLOAT_TO_UBYTE(blue[i]); - dst[i*4+2] = FLOAT_TO_UBYTE(green[i]); - dst[i*4+3] = FLOAT_TO_UBYTE(red[i]); + dst[i*4+0] = FLOAT_TO_UBYTE(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_UBYTE(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_UBYTE(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_UBYTE(rgba[i][RCOMP]); } break; default: - gl_problem(ctx, "bad format in gl_pack_rgba_span\n"); + gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } } break; @@ -701,19 +785,19 @@ void gl_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(red[i]); + dst[i] = FLOAT_TO_BYTE(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(green[i]); + dst[i] = FLOAT_TO_BYTE(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(blue[i]); + dst[i] = FLOAT_TO_BYTE(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_BYTE(alpha[i]); + dst[i] = FLOAT_TO_BYTE(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -722,48 +806,48 @@ void gl_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_BYTE(luminance[i]); - dst[i*2+1] = FLOAT_TO_BYTE(alpha[i]); + dst[i*2+1] = FLOAT_TO_BYTE(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_BYTE(red[i]); - dst[i*3+1] = FLOAT_TO_BYTE(green[i]); - dst[i*3+2] = FLOAT_TO_BYTE(blue[i]); + dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(red[i]); - dst[i*4+1] = FLOAT_TO_BYTE(green[i]); - dst[i*4+2] = FLOAT_TO_BYTE(blue[i]); - dst[i*4+3] = FLOAT_TO_BYTE(alpha[i]); + dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_BYTE(blue[i]); - dst[i*3+1] = FLOAT_TO_BYTE(green[i]); - dst[i*3+2] = FLOAT_TO_BYTE(red[i]); + dst[i*3+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(blue[i]); - dst[i*4+1] = FLOAT_TO_BYTE(green[i]); - dst[i*4+2] = FLOAT_TO_BYTE(red[i]); - dst[i*4+3] = FLOAT_TO_BYTE(alpha[i]); + dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][ACOMP]); } case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_BYTE(alpha[i]); - dst[i*4+1] = FLOAT_TO_BYTE(blue[i]); - dst[i*4+2] = FLOAT_TO_BYTE(green[i]); - dst[i*4+3] = FLOAT_TO_BYTE(red[i]); + dst[i*4+0] = FLOAT_TO_BYTE(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_BYTE(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_BYTE(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_BYTE(rgba[i][RCOMP]); } break; default: - gl_problem(ctx, "bad format in gl_pack_rgba_span\n"); + gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } } break; @@ -773,19 +857,19 @@ void gl_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_USHORT(red[i]); + dst[i] = FLOAT_TO_USHORT(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_USHORT(green[i]); + dst[i] = FLOAT_TO_USHORT(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_USHORT(blue[i]); + dst[i] = FLOAT_TO_USHORT(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_USHORT(alpha[i]); + dst[i] = FLOAT_TO_USHORT(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -794,52 +878,52 @@ void gl_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_USHORT(luminance[i]); - dst[i*2+1] = FLOAT_TO_USHORT(alpha[i]); + dst[i*2+1] = FLOAT_TO_USHORT(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_USHORT(red[i]); - dst[i*3+1] = FLOAT_TO_USHORT(green[i]); - dst[i*3+2] = FLOAT_TO_USHORT(blue[i]); + dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_USHORT(red[i]); - dst[i*4+1] = FLOAT_TO_USHORT(green[i]); - dst[i*4+2] = FLOAT_TO_USHORT(blue[i]); - dst[i*4+3] = FLOAT_TO_USHORT(alpha[i]); + dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_USHORT(blue[i]); - dst[i*3+1] = FLOAT_TO_USHORT(green[i]); - dst[i*3+2] = FLOAT_TO_USHORT(red[i]); + dst[i*3+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_USHORT(blue[i]); - dst[i*4+1] = FLOAT_TO_USHORT(green[i]); - dst[i*4+2] = FLOAT_TO_USHORT(red[i]); - dst[i*4+3] = FLOAT_TO_USHORT(alpha[i]); + dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_USHORT(alpha[i]); - dst[i*4+1] = FLOAT_TO_USHORT(blue[i]); - dst[i*4+2] = FLOAT_TO_USHORT(green[i]); - dst[i*4+3] = FLOAT_TO_USHORT(red[i]); + dst[i*4+0] = FLOAT_TO_USHORT(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_USHORT(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_USHORT(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_USHORT(rgba[i][RCOMP]); } break; default: - gl_problem(ctx, "bad format in gl_pack_rgba_span\n"); + gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } if (packing->SwapBytes) { - gl_swap2( (GLushort *) dst, n * comps); + _mesa_swap2( (GLushort *) dst, n * comps); } } break; @@ -849,19 +933,19 @@ void gl_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(red[i]); + dst[i] = FLOAT_TO_SHORT(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(green[i]); + dst[i] = FLOAT_TO_SHORT(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(blue[i]); + dst[i] = FLOAT_TO_SHORT(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_SHORT(alpha[i]); + dst[i] = FLOAT_TO_SHORT(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -870,51 +954,51 @@ void gl_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_SHORT(luminance[i]); - dst[i*2+1] = FLOAT_TO_SHORT(alpha[i]); + dst[i*2+1] = FLOAT_TO_SHORT(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_SHORT(red[i]); - dst[i*3+1] = FLOAT_TO_SHORT(green[i]); - dst[i*3+2] = FLOAT_TO_SHORT(blue[i]); + dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(red[i]); - dst[i*4+1] = FLOAT_TO_SHORT(green[i]); - dst[i*4+2] = FLOAT_TO_SHORT(blue[i]); - dst[i*4+3] = FLOAT_TO_SHORT(alpha[i]); + dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_SHORT(blue[i]); - dst[i*3+1] = FLOAT_TO_SHORT(green[i]); - dst[i*3+2] = FLOAT_TO_SHORT(red[i]); + dst[i*3+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(blue[i]); - dst[i*4+1] = FLOAT_TO_SHORT(green[i]); - dst[i*4+2] = FLOAT_TO_SHORT(red[i]); - dst[i*4+3] = FLOAT_TO_SHORT(alpha[i]); + dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][ACOMP]); } case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_SHORT(alpha[i]); - dst[i*4+1] = FLOAT_TO_SHORT(blue[i]); - dst[i*4+2] = FLOAT_TO_SHORT(green[i]); - dst[i*4+3] = FLOAT_TO_SHORT(red[i]); + dst[i*4+0] = FLOAT_TO_SHORT(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_SHORT(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_SHORT(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_SHORT(rgba[i][RCOMP]); } break; default: - gl_problem(ctx, "bad format in gl_pack_rgba_span\n"); + gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } if (packing->SwapBytes) { - gl_swap2( (GLushort *) dst, n * comps ); + _mesa_swap2( (GLushort *) dst, n * comps ); } } break; @@ -924,19 +1008,19 @@ void gl_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UINT(red[i]); + dst[i] = FLOAT_TO_UINT(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UINT(green[i]); + dst[i] = FLOAT_TO_UINT(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UINT(blue[i]); + dst[i] = FLOAT_TO_UINT(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_UINT(alpha[i]); + dst[i] = FLOAT_TO_UINT(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -945,52 +1029,52 @@ void gl_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_UINT(luminance[i]); - dst[i*2+1] = FLOAT_TO_UINT(alpha[i]); + dst[i*2+1] = FLOAT_TO_UINT(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_UINT(red[i]); - dst[i*3+1] = FLOAT_TO_UINT(green[i]); - dst[i*3+2] = FLOAT_TO_UINT(blue[i]); + dst[i*3+0] = FLOAT_TO_UINT(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_UINT(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UINT(red[i]); - dst[i*4+1] = FLOAT_TO_UINT(green[i]); - dst[i*4+2] = FLOAT_TO_UINT(blue[i]); - dst[i*4+3] = FLOAT_TO_UINT(alpha[i]); + dst[i*4+0] = FLOAT_TO_UINT(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_UINT(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_UINT(blue[i]); - dst[i*3+1] = FLOAT_TO_UINT(green[i]); - dst[i*3+2] = FLOAT_TO_UINT(red[i]); + dst[i*3+0] = FLOAT_TO_UINT(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_UINT(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UINT(blue[i]); - dst[i*4+1] = FLOAT_TO_UINT(green[i]); - dst[i*4+2] = FLOAT_TO_UINT(red[i]); - dst[i*4+3] = FLOAT_TO_UINT(alpha[i]); + dst[i*4+0] = FLOAT_TO_UINT(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_UINT(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_UINT(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_UINT(alpha[i]); - dst[i*4+1] = FLOAT_TO_UINT(blue[i]); - dst[i*4+2] = FLOAT_TO_UINT(green[i]); - dst[i*4+3] = FLOAT_TO_UINT(red[i]); + dst[i*4+0] = FLOAT_TO_UINT(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_UINT(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_UINT(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_UINT(rgba[i][RCOMP]); } break; default: - gl_problem(ctx, "bad format in gl_pack_rgba_span\n"); + gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, n * comps ); + _mesa_swap4( (GLuint *) dst, n * comps ); } } break; @@ -1000,19 +1084,19 @@ void gl_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_INT(red[i]); + dst[i] = FLOAT_TO_INT(rgba[i][RCOMP]); break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_INT(green[i]); + dst[i] = FLOAT_TO_INT(rgba[i][GCOMP]); break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_INT(blue[i]); + dst[i] = FLOAT_TO_INT(rgba[i][BCOMP]); break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = FLOAT_TO_INT(alpha[i]); + dst[i] = FLOAT_TO_INT(rgba[i][ACOMP]); break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -1021,52 +1105,52 @@ void gl_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = FLOAT_TO_INT(luminance[i]); - dst[i*2+1] = FLOAT_TO_INT(alpha[i]); + dst[i*2+1] = FLOAT_TO_INT(rgba[i][ACOMP]); } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_INT(red[i]); - dst[i*3+1] = FLOAT_TO_INT(green[i]); - dst[i*3+2] = FLOAT_TO_INT(blue[i]); + dst[i*3+0] = FLOAT_TO_INT(rgba[i][RCOMP]); + dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_INT(rgba[i][BCOMP]); } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_INT(red[i]); - dst[i*4+1] = FLOAT_TO_INT(green[i]); - dst[i*4+2] = FLOAT_TO_INT(blue[i]); - dst[i*4+3] = FLOAT_TO_INT(alpha[i]); + dst[i*4+0] = FLOAT_TO_INT(rgba[i][RCOMP]); + dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_INT(rgba[i][BCOMP]); + dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]); } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = FLOAT_TO_INT(blue[i]); - dst[i*3+1] = FLOAT_TO_INT(green[i]); - dst[i*3+2] = FLOAT_TO_INT(red[i]); + dst[i*3+0] = FLOAT_TO_INT(rgba[i][BCOMP]); + dst[i*3+1] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*3+2] = FLOAT_TO_INT(rgba[i][RCOMP]); } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_INT(blue[i]); - dst[i*4+1] = FLOAT_TO_INT(green[i]); - dst[i*4+2] = FLOAT_TO_INT(red[i]); - dst[i*4+3] = FLOAT_TO_INT(alpha[i]); + dst[i*4+0] = FLOAT_TO_INT(rgba[i][BCOMP]); + dst[i*4+1] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*4+2] = FLOAT_TO_INT(rgba[i][RCOMP]); + dst[i*4+3] = FLOAT_TO_INT(rgba[i][ACOMP]); } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = FLOAT_TO_INT(alpha[i]); - dst[i*4+1] = FLOAT_TO_INT(blue[i]); - dst[i*4+2] = FLOAT_TO_INT(green[i]); - dst[i*4+3] = FLOAT_TO_INT(red[i]); + dst[i*4+0] = FLOAT_TO_INT(rgba[i][ACOMP]); + dst[i*4+1] = FLOAT_TO_INT(rgba[i][BCOMP]); + dst[i*4+2] = FLOAT_TO_INT(rgba[i][GCOMP]); + dst[i*4+3] = FLOAT_TO_INT(rgba[i][RCOMP]); } break; default: - gl_problem(ctx, "bad format in gl_pack_rgba_span\n"); + gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, n * comps ); + _mesa_swap4( (GLuint *) dst, n * comps ); } } break; @@ -1076,19 +1160,19 @@ void gl_pack_rgba_span( const GLcontext *ctx, switch (format) { case GL_RED: for (i=0;i<n;i++) - dst[i] = red[i]; + dst[i] = rgba[i][RCOMP]; break; case GL_GREEN: for (i=0;i<n;i++) - dst[i] = green[i]; + dst[i] = rgba[i][GCOMP]; break; case GL_BLUE: for (i=0;i<n;i++) - dst[i] = blue[i]; + dst[i] = rgba[i][BCOMP]; break; case GL_ALPHA: for (i=0;i<n;i++) - dst[i] = alpha[i]; + dst[i] = rgba[i][ACOMP]; break; case GL_LUMINANCE: for (i=0;i<n;i++) @@ -1097,52 +1181,52 @@ void gl_pack_rgba_span( const GLcontext *ctx, case GL_LUMINANCE_ALPHA: for (i=0;i<n;i++) { dst[i*2+0] = luminance[i]; - dst[i*2+1] = alpha[i]; + dst[i*2+1] = rgba[i][ACOMP]; } break; case GL_RGB: for (i=0;i<n;i++) { - dst[i*3+0] = red[i]; - dst[i*3+1] = green[i]; - dst[i*3+2] = blue[i]; + dst[i*3+0] = rgba[i][RCOMP]; + dst[i*3+1] = rgba[i][GCOMP]; + dst[i*3+2] = rgba[i][BCOMP]; } break; case GL_RGBA: for (i=0;i<n;i++) { - dst[i*4+0] = red[i]; - dst[i*4+1] = green[i]; - dst[i*4+2] = blue[i]; - dst[i*4+3] = alpha[i]; + dst[i*4+0] = rgba[i][RCOMP]; + dst[i*4+1] = rgba[i][GCOMP]; + dst[i*4+2] = rgba[i][BCOMP]; + dst[i*4+3] = rgba[i][ACOMP]; } break; case GL_BGR: for (i=0;i<n;i++) { - dst[i*3+0] = blue[i]; - dst[i*3+1] = green[i]; - dst[i*3+2] = red[i]; + dst[i*3+0] = rgba[i][BCOMP]; + dst[i*3+1] = rgba[i][GCOMP]; + dst[i*3+2] = rgba[i][RCOMP]; } break; case GL_BGRA: for (i=0;i<n;i++) { - dst[i*4+0] = blue[i]; - dst[i*4+1] = green[i]; - dst[i*4+2] = red[i]; - dst[i*4+3] = alpha[i]; + dst[i*4+0] = rgba[i][BCOMP]; + dst[i*4+1] = rgba[i][GCOMP]; + dst[i*4+2] = rgba[i][RCOMP]; + dst[i*4+3] = rgba[i][ACOMP]; } break; case GL_ABGR_EXT: for (i=0;i<n;i++) { - dst[i*4+0] = alpha[i]; - dst[i*4+1] = blue[i]; - dst[i*4+2] = green[i]; - dst[i*4+3] = red[i]; + dst[i*4+0] = rgba[i][ACOMP]; + dst[i*4+1] = rgba[i][BCOMP]; + dst[i*4+2] = rgba[i][GCOMP]; + dst[i*4+3] = rgba[i][RCOMP]; } break; default: - gl_problem(ctx, "bad format in gl_pack_rgba_span\n"); + gl_problem(ctx, "bad format in _mesa_pack_rgba_span\n"); } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, n * comps ); + _mesa_swap4( (GLuint *) dst, n * comps ); } } break; @@ -1150,9 +1234,9 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLubyte *dst = (GLubyte *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 7.0F)) << 5) - | (((GLint) (green[i] * 7.0F)) << 2) - | (((GLint) (blue[i] * 3.0F)) ); + dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) << 5) + | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 2) + | (((GLint) (rgba[i][BCOMP] * 3.0F)) ); } } break; @@ -1160,9 +1244,9 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLubyte *dst = (GLubyte *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 7.0F)) ) - | (((GLint) (green[i] * 7.0F)) << 3) - | (((GLint) (blue[i] * 3.0F)) << 5); + dst[i] = (((GLint) (rgba[i][RCOMP] * 7.0F)) ) + | (((GLint) (rgba[i][GCOMP] * 7.0F)) << 3) + | (((GLint) (rgba[i][BCOMP] * 3.0F)) << 5); } } break; @@ -1170,9 +1254,9 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 31.0F)) << 11) - | (((GLint) (green[i] * 63.0F)) << 5) - | (((GLint) (blue[i] * 31.0F)) ); + dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11) + | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5) + | (((GLint) (rgba[i][BCOMP] * 31.0F)) ); } } break; @@ -1180,9 +1264,9 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 31.0F)) ) - | (((GLint) (green[i] * 63.0F)) << 5) - | (((GLint) (blue[i] * 31.0F)) << 11); + dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) ) + | (((GLint) (rgba[i][GCOMP] * 63.0F)) << 5) + | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 11); } } break; @@ -1190,10 +1274,10 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 15.0F)) << 12) - | (((GLint) (green[i] * 15.0F)) << 8) - | (((GLint) (blue[i] * 15.0F)) << 4) - | (((GLint) (alpha[i] * 15.0F)) ); + dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) << 12) + | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 8) + | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 4) + | (((GLint) (rgba[i][ACOMP] * 15.0F)) ); } } break; @@ -1201,10 +1285,10 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 15.0F)) ) - | (((GLint) (green[i] * 15.0F)) << 4) - | (((GLint) (blue[i] * 15.0F)) << 8) - | (((GLint) (alpha[i] * 15.0F)) << 12); + dst[i] = (((GLint) (rgba[i][RCOMP] * 15.0F)) ) + | (((GLint) (rgba[i][GCOMP] * 15.0F)) << 4) + | (((GLint) (rgba[i][BCOMP] * 15.0F)) << 8) + | (((GLint) (rgba[i][ACOMP] * 15.0F)) << 12); } } break; @@ -1212,10 +1296,10 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 31.0F)) << 11) - | (((GLint) (green[i] * 31.0F)) << 6) - | (((GLint) (blue[i] * 31.0F)) << 1) - | (((GLint) (alpha[i] * 1.0F)) ); + dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) << 11) + | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 6) + | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 1) + | (((GLint) (rgba[i][ACOMP] * 1.0F)) ); } } break; @@ -1223,10 +1307,10 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGB) { GLushort *dst = (GLushort *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLint) (red[i] * 31.0F)) ) - | (((GLint) (green[i] * 31.0F)) << 5) - | (((GLint) (blue[i] * 31.0F)) << 10) - | (((GLint) (alpha[i] * 1.0F)) << 15); + dst[i] = (((GLint) (rgba[i][RCOMP] * 31.0F)) ) + | (((GLint) (rgba[i][GCOMP] * 31.0F)) << 5) + | (((GLint) (rgba[i][BCOMP] * 31.0F)) << 10) + | (((GLint) (rgba[i][ACOMP] * 1.0F)) << 15); } } break; @@ -1234,28 +1318,28 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGBA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (red[i] * 255.0F)) << 24) - | (((GLuint) (green[i] * 255.0F)) << 16) - | (((GLuint) (blue[i] * 255.0F)) << 8) - | (((GLuint) (alpha[i] * 255.0F)) ); + dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][ACOMP] * 255.0F)) ); } } else if (format == GL_BGRA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (blue[i] * 255.0F)) << 24) - | (((GLuint) (green[i] * 255.0F)) << 16) - | (((GLuint) (red[i] * 255.0F)) << 8) - | (((GLuint) (alpha[i] * 255.0F)) ); + dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 24) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][ACOMP] * 255.0F)) ); } } else if (format == GL_ABGR_EXT) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (alpha[i] * 255.0F)) << 24) - | (((GLuint) (blue[i] * 255.0F)) << 16) - | (((GLuint) (green[i] * 255.0F)) << 8) - | (((GLuint) (red[i] * 255.0F)) ); + dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24) + | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][RCOMP] * 255.0F)) ); } } break; @@ -1263,28 +1347,28 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGBA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (red[i] * 255.0F)) ) - | (((GLuint) (green[i] * 255.0F)) << 8) - | (((GLuint) (blue[i] * 255.0F)) << 16) - | (((GLuint) (alpha[i] * 255.0F)) << 24); + dst[i] = (((GLuint) (rgba[i][RCOMP] * 255.0F)) ) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24); } } else if (format == GL_BGRA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (blue[i] * 255.0F)) ) - | (((GLuint) (green[i] * 255.0F)) << 8) - | (((GLuint) (red[i] * 255.0F)) << 16) - | (((GLuint) (alpha[i] * 255.0F)) << 24); + dst[i] = (((GLuint) (rgba[i][BCOMP] * 255.0F)) ) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][ACOMP] * 255.0F)) << 24); } } else if (format == GL_ABGR_EXT) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (alpha[i] * 255.0F)) ) - | (((GLuint) (blue[i] * 255.0F)) << 8) - | (((GLuint) (green[i] * 255.0F)) << 16) - | (((GLuint) (red[i] * 255.0F)) << 24); + dst[i] = (((GLuint) (rgba[i][ACOMP] * 255.0F)) ) + | (((GLuint) (rgba[i][BCOMP] * 255.0F)) << 8) + | (((GLuint) (rgba[i][GCOMP] * 255.0F)) << 16) + | (((GLuint) (rgba[i][RCOMP] * 255.0F)) << 24); } } break; @@ -1292,28 +1376,28 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGBA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (red[i] * 1023.0F)) << 22) - | (((GLuint) (green[i] * 1023.0F)) << 12) - | (((GLuint) (blue[i] * 1023.0F)) << 2) - | (((GLuint) (alpha[i] * 3.0F)) ); + dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 22) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12) + | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 2) + | (((GLuint) (rgba[i][ACOMP] * 3.0F)) ); } } else if (format == GL_BGRA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (blue[i] * 1023.0F)) << 22) - | (((GLuint) (green[i] * 1023.0F)) << 12) - | (((GLuint) (red[i] * 1023.0F)) << 2) - | (((GLuint) (alpha[i] * 3.0F)) ); + dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 22) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 12) + | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 2) + | (((GLuint) (rgba[i][ACOMP] * 3.0F)) ); } } else if (format == GL_ABGR_EXT) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (alpha[i] * 1023.0F)) << 22) - | (((GLuint) (blue[i] * 1023.0F)) << 12) - | (((GLuint) (green[i] * 1023.0F)) << 2) - | (((GLuint) (red[i] * 3.0F)) ); + dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) << 22) + | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 12) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 2) + | (((GLuint) (rgba[i][RCOMP] * 3.0F)) ); } } break; @@ -1321,38 +1405,39 @@ void gl_pack_rgba_span( const GLcontext *ctx, if (format == GL_RGBA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (red[i] * 1023.0F)) ) - | (((GLuint) (green[i] * 1023.0F)) << 10) - | (((GLuint) (blue[i] * 1023.0F)) << 20) - | (((GLuint) (alpha[i] * 3.0F)) << 30); + dst[i] = (((GLuint) (rgba[i][RCOMP] * 1023.0F)) ) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10) + | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 20) + | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30); } } else if (format == GL_BGRA) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (blue[i] * 1023.0F)) ) - | (((GLuint) (green[i] * 1023.0F)) << 10) - | (((GLuint) (red[i] * 1023.0F)) << 20) - | (((GLuint) (alpha[i] * 3.0F)) << 30); + dst[i] = (((GLuint) (rgba[i][BCOMP] * 1023.0F)) ) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 10) + | (((GLuint) (rgba[i][RCOMP] * 1023.0F)) << 20) + | (((GLuint) (rgba[i][ACOMP] * 3.0F)) << 30); } } else if (format == GL_ABGR_EXT) { GLuint *dst = (GLuint *) destination; for (i=0;i<n;i++) { - dst[i] = (((GLuint) (alpha[i] * 1023.0F)) ) - | (((GLuint) (blue[i] * 1023.0F)) << 10) - | (((GLuint) (green[i] * 1023.0F)) << 20) - | (((GLuint) (red[i] * 3.0F)) << 30); + dst[i] = (((GLuint) (rgba[i][ACOMP] * 1023.0F)) ) + | (((GLuint) (rgba[i][BCOMP] * 1023.0F)) << 10) + | (((GLuint) (rgba[i][GCOMP] * 1023.0F)) << 20) + | (((GLuint) (rgba[i][RCOMP] * 3.0F)) << 30); } } break; default: - gl_problem( ctx, "bad type in gl_pack_rgba_span" ); + gl_problem( ctx, "bad type in _mesa_pack_rgba_span" ); } } } + #define SWAP2BYTE(VALUE) \ { \ GLubyte *bytes = (GLubyte *) &(VALUE); \ @@ -1515,12 +1600,12 @@ extract_uint_indexes(GLuint n, GLuint indexes[], for (i = 0; i < n; i++) { GLfloat value = s[i]; SWAP4BYTE(value); - indexes[i] = value; + indexes[i] = (GLuint) value; } } else { for (i = 0; i < n; i++) - indexes[i] = s[i]; + indexes[i] = (GLuint) s[i]; } } break; @@ -2056,7 +2141,7 @@ extract_float_rgba(GLuint n, GLfloat rgba[][4], * XXX perhaps expand this to process whole images someday. */ void -_mesa_unpack_ubyte_color_span( const GLcontext *ctx, +_mesa_unpack_ubyte_color_span( GLcontext *ctx, GLuint n, GLenum dstFormat, GLubyte dest[], GLenum srcFormat, GLenum srcType, const GLvoid *source, @@ -2106,12 +2191,17 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, srcType == GL_UNSIGNED_INT_10_10_10_2 || srcType == GL_UNSIGNED_INT_2_10_10_10_REV); - /* this is intended for RGBA mode */ + /* this is intended for RGBA mode only */ assert(ctx->Visual->RGBAflag); applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag || - ctx->Pixel.MapColorFlag); + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled || + ctx->Pixel.HistogramEnabled); /* Try simple cases first */ if (!applyTransferOps && srcType == GL_UNSIGNED_BYTE) { @@ -2155,7 +2245,7 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, } } else if (dstFormat == srcFormat) { - GLint comps = gl_components_in_format(srcFormat); + GLint comps = _mesa_components_in_format(srcFormat); assert(comps > 0); MEMCPY( dest, source, n * comps * sizeof(GLubyte) ); return; @@ -2163,14 +2253,14 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, } + /* general solution begins here */ { - /* general solution */ GLfloat rgba[MAX_WIDTH][4]; GLint dstComponents; GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex; GLint dstLuminanceIndex, dstIntensityIndex; - dstComponents = gl_components_in_format( dstFormat ); + dstComponents = _mesa_components_in_format( dstFormat ); /* source & dest image formats should have been error checked by now */ assert(dstComponents > 0); @@ -2183,32 +2273,26 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, extract_uint_indexes(n, indexes, srcFormat, srcType, source, unpacking); - /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); - - if (dstFormat == GL_COLOR_INDEX) { - if (applyTransferOps) { - if (ctx->Pixel.MapColorFlag) { - /* Apply lookup table */ - gl_map_ci(ctx, n, indexes); - } - - if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { - - } + if (applyTransferOps) { + if (ctx->Pixel.MapColorFlag) { + _mesa_map_ci(ctx, n, indexes); + } + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { + _mesa_shift_and_offset_ci(ctx, n, indexes); } + } + if (dstFormat == GL_COLOR_INDEX) { /* convert to GLubyte and return */ - { - GLuint i; - for (i = 0; i < n; i++) { - dest[i] = (GLubyte) (indexes[i] & 0xff); - } + GLuint i; + for (i = 0; i < n; i++) { + dest[i] = (GLubyte) (indexes[i] & 0xff); } + return; } else { /* Convert indexes to RGBA */ - gl_map_ci_to_rgba_float(ctx, n, indexes, rgba); + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); } } else { @@ -2217,23 +2301,41 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, if (applyTransferOps) { /* scale and bias colors */ - gl_scale_and_bias_rgba_float(ctx, n, rgba); - - /* color table lookup */ + if (ctx->Pixel.ScaleOrBiasRGBA) { + _mesa_scale_and_bias_rgba(ctx, n, rgba); + } + /* color map lookup */ if (ctx->Pixel.MapColorFlag) { - gl_map_rgba_float(ctx, n, rgba); + _mesa_map_rgba(ctx, n, rgba); } } } - - /* - * XXX This is where more color table lookups, convolution, - * histograms, minmax, color matrix, etc would take place if - * implemented. - * See figure 3.7 in the OpenGL 1.2 specification for more info. - */ - + if (applyTransferOps) { + /* GL_COLOR_TABLE lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, n, rgba); + } + /* XXX convolution here */ + /* XXX post-convolution color table look-up here */ + /* color matrix transform */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, n, rgba); + } + /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ + if (ctx->Pixel.PostColorMatrixColorTableEnabled) { + _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba); + } + /* update histogram count */ + if (ctx->Pixel.HistogramEnabled) { + _mesa_update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba); + } + /* XXX min/max here */ + if (ctx->Pixel.MinMaxEnabled) { + _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba); + } + } /* clamp to [0,1] */ { @@ -2353,6 +2455,270 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, } +void +_mesa_unpack_float_color_span( GLcontext *ctx, + GLuint n, GLenum dstFormat, GLfloat dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *unpacking, + GLboolean applyTransferOps, GLboolean clamp ) +{ + ASSERT(dstFormat == GL_ALPHA || + dstFormat == GL_LUMINANCE || + dstFormat == GL_LUMINANCE_ALPHA || + dstFormat == GL_INTENSITY || + dstFormat == GL_RGB || + dstFormat == GL_RGBA || + dstFormat == GL_COLOR_INDEX); + + ASSERT(srcFormat == GL_RED || + srcFormat == GL_GREEN || + srcFormat == GL_BLUE || + srcFormat == GL_ALPHA || + srcFormat == GL_LUMINANCE || + srcFormat == GL_LUMINANCE_ALPHA || + srcFormat == GL_INTENSITY || + srcFormat == GL_RGB || + srcFormat == GL_BGR || + srcFormat == GL_RGBA || + srcFormat == GL_BGRA || + srcFormat == GL_ABGR_EXT || + srcFormat == GL_COLOR_INDEX); + + ASSERT(srcType == GL_BITMAP || + srcType == GL_UNSIGNED_BYTE || + srcType == GL_BYTE || + srcType == GL_UNSIGNED_SHORT || + srcType == GL_SHORT || + srcType == GL_UNSIGNED_INT || + srcType == GL_INT || + srcType == GL_FLOAT || + srcType == GL_UNSIGNED_BYTE_3_3_2 || + srcType == GL_UNSIGNED_BYTE_2_3_3_REV || + srcType == GL_UNSIGNED_SHORT_5_6_5 || + srcType == GL_UNSIGNED_SHORT_5_6_5_REV || + srcType == GL_UNSIGNED_SHORT_4_4_4_4 || + srcType == GL_UNSIGNED_SHORT_4_4_4_4_REV || + srcType == GL_UNSIGNED_SHORT_5_5_5_1 || + srcType == GL_UNSIGNED_SHORT_1_5_5_5_REV || + srcType == GL_UNSIGNED_INT_8_8_8_8 || + srcType == GL_UNSIGNED_INT_8_8_8_8_REV || + srcType == GL_UNSIGNED_INT_10_10_10_2 || + srcType == GL_UNSIGNED_INT_2_10_10_10_REV); + + /* this is intended for RGBA mode only */ + assert(ctx->Visual->RGBAflag); + + applyTransferOps &= (ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled || + ctx->Pixel.HistogramEnabled); + + /* general solution, no special cases, yet */ + { + GLfloat rgba[MAX_WIDTH][4]; + GLint dstComponents; + GLint dstRedIndex, dstGreenIndex, dstBlueIndex, dstAlphaIndex; + GLint dstLuminanceIndex, dstIntensityIndex; + + dstComponents = _mesa_components_in_format( dstFormat ); + /* source & dest image formats should have been error checked by now */ + assert(dstComponents > 0); + + /* + * Extract image data and convert to RGBA floats + */ + assert(n <= MAX_WIDTH); + if (srcFormat == GL_COLOR_INDEX) { + GLuint indexes[MAX_WIDTH]; + extract_uint_indexes(n, indexes, srcFormat, srcType, source, + unpacking); + + if (applyTransferOps) { + if (ctx->Pixel.MapColorFlag) { + _mesa_map_ci(ctx, n, indexes); + } + if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { + _mesa_shift_and_offset_ci(ctx, n, indexes); + } + } + + if (dstFormat == GL_COLOR_INDEX) { + /* convert to GLubyte and return */ + GLuint i; + for (i = 0; i < n; i++) { + dest[i] = (GLubyte) (indexes[i] & 0xff); + } + return; + } + else { + /* Convert indexes to RGBA */ + _mesa_map_ci_to_rgba(ctx, n, indexes, rgba); + } + } + else { + extract_float_rgba(n, rgba, srcFormat, srcType, source, + unpacking->SwapBytes); + + if (applyTransferOps) { + /* scale and bias colors */ + if (ctx->Pixel.ScaleOrBiasRGBA) { + _mesa_scale_and_bias_rgba(ctx, n, rgba); + } + /* color map lookup */ + if (ctx->Pixel.MapColorFlag) { + _mesa_map_rgba(ctx, n, rgba); + } + } + } + + if (applyTransferOps) { + /* GL_COLOR_TABLE lookup */ + if (ctx->Pixel.ColorTableEnabled) { + _mesa_lookup_rgba(&ctx->ColorTable, n, rgba); + } + /* XXX convolution here */ + /* XXX post-convolution color table look-up here */ + /* color matrix transform */ + if (ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm) { + _mesa_transform_rgba(ctx, n, rgba); + } + /* GL_POST_COLOR_MATRIX_COLOR_TABLE lookup */ + if (ctx->Pixel.PostColorMatrixColorTableEnabled) { + _mesa_lookup_rgba(&ctx->PostColorMatrixColorTable, n, rgba); + } + /* update histogram count */ + if (ctx->Pixel.HistogramEnabled) { + _mesa_update_histogram(ctx, n, (CONST GLfloat (*)[4]) rgba); + } + /* XXX min/max here */ + if (ctx->Pixel.MinMaxEnabled) { + _mesa_update_minmax(ctx, n, (CONST GLfloat (*)[4]) rgba); + } + } + + /* clamp to [0,1] */ + if (clamp) { + GLuint i; + for (i = 0; i < n; i++) { + rgba[i][RCOMP] = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F); + rgba[i][GCOMP] = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F); + rgba[i][BCOMP] = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F); + rgba[i][ACOMP] = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F); + } + } + + /* Now determine which color channels we need to produce. + * And determine the dest index (offset) within each color tuple. + */ + switch (dstFormat) { + case GL_ALPHA: + dstAlphaIndex = 0; + dstRedIndex = dstGreenIndex = dstBlueIndex = -1; + dstLuminanceIndex = dstIntensityIndex = -1; + break; + case GL_LUMINANCE: + dstLuminanceIndex = 0; + dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1; + dstIntensityIndex = -1; + break; + case GL_LUMINANCE_ALPHA: + dstLuminanceIndex = 0; + dstAlphaIndex = 1; + dstRedIndex = dstGreenIndex = dstBlueIndex = -1; + dstIntensityIndex = -1; + break; + case GL_INTENSITY: + dstIntensityIndex = 0; + dstRedIndex = dstGreenIndex = dstBlueIndex = dstAlphaIndex = -1; + dstLuminanceIndex = -1; + break; + case GL_RGB: + dstRedIndex = 0; + dstGreenIndex = 1; + dstBlueIndex = 2; + dstAlphaIndex = dstLuminanceIndex = dstIntensityIndex = -1; + break; + case GL_RGBA: + dstRedIndex = 0; + dstGreenIndex = 1; + dstBlueIndex = 2; + dstAlphaIndex = 3; + dstLuminanceIndex = dstIntensityIndex = -1; + break; + default: + gl_problem(ctx, "bad dstFormat in _mesa_unpack_float_span()"); + return; + } + + /* Now pack results in teh requested dstFormat */ + if (dstRedIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[dstRedIndex] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + + if (dstGreenIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[dstGreenIndex] = rgba[i][GCOMP]; + dst += dstComponents; + } + } + + if (dstBlueIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[dstBlueIndex] = rgba[i][BCOMP]; + dst += dstComponents; + } + } + + if (dstAlphaIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + for (i = 0; i < n; i++) { + dst[dstAlphaIndex] = rgba[i][ACOMP]; + dst += dstComponents; + } + } + + if (dstIntensityIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + assert(dstIntensityIndex == 0); + assert(dstComponents == 1); + for (i = 0; i < n; i++) { + /* Intensity comes from red channel */ + dst[i] = rgba[i][RCOMP]; + } + } + + if (dstLuminanceIndex >= 0) { + GLfloat *dst = dest; + GLuint i; + assert(dstLuminanceIndex == 0); + for (i = 0; i < n; i++) { + /* Luminance comes from red channel */ + dst[0] = rgba[i][RCOMP]; + dst += dstComponents; + } + } + } +} + + + /* * Unpack a row of color index data from a client buffer according to @@ -2415,12 +2781,11 @@ _mesa_unpack_index_span( const GLcontext *ctx, GLuint n, if (applyTransferOps) { if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); + _mesa_shift_and_offset_ci(ctx, n, indexes); } - if (ctx->Pixel.MapColorFlag) { /* Apply lookup table */ - gl_map_ci(ctx, n, indexes); + _mesa_map_ci(ctx, n, indexes); } } @@ -2515,7 +2880,7 @@ _mesa_unpack_stencil_span( const GLcontext *ctx, GLuint n, if (applyTransferOps) { if (ctx->Pixel.IndexShift || ctx->Pixel.IndexOffset) { /* shift and offset indexes */ - gl_shift_and_offset_ci(ctx, n, indexes); + _mesa_shift_and_offset_ci(ctx, n, indexes); } if (ctx->Pixel.MapStencilFlag) { @@ -2643,9 +3008,10 @@ _mesa_unpack_depth_span( const GLcontext *ctx, GLuint n, GLdepth *dest, /* clamp depth values to [0,1] and convert from floats to integers */ { + const GLfloat zs = ctx->Visual->DepthMaxF; GLuint i; for (i = 0; i < n; i++) { - dest[i] = (GLdepth) (CLAMP(depth[i], 0.0F, 1.0F) * DEPTH_SCALE); + dest[i] = (GLdepth) (CLAMP(depth[i], 0.0F, 1.0F) * zs); } } @@ -2679,8 +3045,8 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth, compsPerRow = 0; } else { - const GLint bytesPerPixel = gl_bytes_per_pixel(format, type); - const GLint components = gl_components_in_format(format); + const GLint bytesPerPixel = _mesa_bytes_per_pixel(format, type); + const GLint components = _mesa_components_in_format(format); GLint bytesPerComp; if (bytesPerPixel <= 0 || components <= 0) return NULL; /* bad format or type. generate error later */ @@ -2703,18 +3069,18 @@ _mesa_unpack_image( GLsizei width, GLsizei height, GLsizei depth, dst = destBuffer; for (img = 0; img < depth; img++) { for (row = 0; row < height; row++) { - const GLvoid *src = gl_pixel_addr_in_image(unpack, pixels, + const GLvoid *src = _mesa_image_address(unpack, pixels, width, height, format, type, img, row, 0); MEMCPY(dst, src, bytesPerRow); /* byte flipping/swapping */ if (flipBytes) { - gl_flip_bytes((GLubyte *) dst, bytesPerRow); + flip_bytes((GLubyte *) dst, bytesPerRow); } else if (swap2) { - gl_swap2((GLushort*) dst, compsPerRow); + _mesa_swap2((GLushort*) dst, compsPerRow); } else if (swap4) { - gl_swap4((GLuint*) dst, compsPerRow); + _mesa_swap4((GLuint*) dst, compsPerRow); } dst += bytesPerRow; } @@ -2748,9 +3114,9 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, width_in_bytes = CEILING( width, 8 ); dst = buffer; for (row = 0; row < height; row++) { - GLubyte *src = gl_pixel_addr_in_image( packing, pixels, width, height, - GL_COLOR_INDEX, GL_BITMAP, - 0, row, 0 ); + GLubyte *src = _mesa_image_address( packing, pixels, width, height, + GL_COLOR_INDEX, GL_BITMAP, + 0, row, 0 ); if (!src) { FREE(buffer); return NULL; @@ -2759,7 +3125,7 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, if (packing->SkipPixels == 0) { MEMCPY( dst, src, width_in_bytes ); if (packing->LsbFirst) { - gl_flip_bytes( dst, width_in_bytes ); + flip_bytes( dst, width_in_bytes ); } } else { @@ -2825,3 +3191,94 @@ _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, return buffer; } + + +/* + * Pack bitmap data. + */ +void +_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, + GLubyte *dest, const struct gl_pixelstore_attrib *packing ) +{ + GLint row, width_in_bytes; + const GLubyte *src; + + if (!source) + return; + + width_in_bytes = CEILING( width, 8 ); + src = source; + for (row = 0; row < height; row++) { + GLubyte *dst = _mesa_image_address( packing, dest, width, height, + GL_COLOR_INDEX, GL_BITMAP, + 0, row, 0 ); + if (!dst) + return; + + if (packing->SkipPixels == 0) { + MEMCPY( dst, src, width_in_bytes ); + if (packing->LsbFirst) { + flip_bytes( dst, width_in_bytes ); + } + } + else { + /* handling SkipPixels is a bit tricky (no pun intended!) */ + GLint i; + if (packing->LsbFirst) { + GLubyte srcMask = 1 << (packing->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 128) { + srcMask = 1; + s++; + } + else { + srcMask = srcMask << 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + else { + GLubyte srcMask = 128 >> (packing->SkipPixels & 0x7); + GLubyte dstMask = 128; + const GLubyte *s = src; + GLubyte *d = dst; + *d = 0; + for (i = 0; i < width; i++) { + if (*s & srcMask) { + *d |= dstMask; + } + if (srcMask == 1) { + srcMask = 128; + s++; + } + else { + srcMask = srcMask >> 1; + } + if (dstMask == 1) { + dstMask = 128; + d++; + *d = 0; + } + else { + dstMask = dstMask >> 1; + } + } + } + } + src += width_in_bytes; + } +} diff --git a/xc/extras/Mesa/src/image.h b/xc/extras/Mesa/src/image.h index 84f104422..65c12c53c 100644 --- a/xc/extras/Mesa/src/image.h +++ b/xc/extras/Mesa/src/image.h @@ -1,9 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -31,57 +31,63 @@ #include "types.h" -extern struct gl_pixelstore_attrib _mesa_native_packing; +extern const struct gl_pixelstore_attrib _mesa_native_packing; -extern void gl_flip_bytes( GLubyte *p, GLuint n ); +extern void +_mesa_swap2( GLushort *p, GLuint n ); +extern void +_mesa_swap4( GLuint *p, GLuint n ); -extern void gl_swap2( GLushort *p, GLuint n ); +extern GLint +_mesa_sizeof_type( GLenum type ); -extern void gl_swap4( GLuint *p, GLuint n ); +extern GLint +_mesa_sizeof_packed_type( GLenum type ); +extern GLint +_mesa_components_in_format( GLenum format ); -extern GLint gl_sizeof_type( GLenum type ); +extern GLint +_mesa_bytes_per_pixel( GLenum format, GLenum type ); -extern GLint gl_sizeof_packed_type( GLenum type ); +extern GLboolean +_mesa_is_legal_format_and_type( GLenum format, GLenum type ); -extern GLint gl_components_in_format( GLenum format ); -extern GLint gl_bytes_per_pixel( GLenum format, GLenum type ); +extern GLvoid * +_mesa_image_address( const struct gl_pixelstore_attrib *packing, + const GLvoid *image, GLsizei width, + GLsizei height, GLenum format, GLenum type, + GLint img, GLint row, GLint column ); -extern GLboolean gl_is_legal_format_and_type( GLenum format, GLenum type ); - -extern GLvoid * -gl_pixel_addr_in_image( const struct gl_pixelstore_attrib *packing, - const GLvoid *image, GLsizei width, - GLsizei height, GLenum format, GLenum type, - GLint img, GLint row, GLint column ); +extern GLint +_mesa_image_row_stride( const struct gl_pixelstore_attrib *packing, + GLint width, GLenum format, GLenum type ); extern void -gl_unpack_polygon_stipple( const GLcontext *ctx, - const GLubyte *pattern, - GLuint dest[32] ); +_mesa_unpack_polygon_stipple( const GLubyte *pattern, GLuint dest[32], + const struct gl_pixelstore_attrib *unpacking ); extern void -gl_pack_polygon_stipple( const GLcontext *ctx, - const GLuint pattern[32], - GLubyte *dest ); +_mesa_pack_polygon_stipple( const GLuint pattern[32], GLubyte *dest, + const struct gl_pixelstore_attrib *packing ); extern void -gl_pack_rgba_span( const GLcontext *ctx, - GLuint n, CONST GLubyte rgba[][4], - GLenum format, GLenum type, GLvoid *dest, - const struct gl_pixelstore_attrib *packing, - GLboolean applyTransferOps ); +_mesa_pack_rgba_span( GLcontext *ctx, + GLuint n, CONST GLubyte rgba[][4], + GLenum format, GLenum type, GLvoid *dest, + const struct gl_pixelstore_attrib *packing, + GLboolean applyTransferOps ); extern void -_mesa_unpack_ubyte_color_span( const GLcontext *ctx, +_mesa_unpack_ubyte_color_span( GLcontext *ctx, GLuint n, GLenum dstFormat, GLubyte dest[], GLenum srcFormat, GLenum srcType, const GLvoid *source, @@ -90,6 +96,15 @@ _mesa_unpack_ubyte_color_span( const GLcontext *ctx, extern void +_mesa_unpack_float_color_span( GLcontext *ctx, + GLuint n, GLenum dstFormat, GLfloat dest[], + GLenum srcFormat, GLenum srcType, + const GLvoid *source, + const struct gl_pixelstore_attrib *unpacking, + GLboolean applyTransferOps, GLboolean clamp ); + + +extern void _mesa_unpack_index_span( const GLcontext *ctx, GLuint n, GLenum dstType, GLvoid *dest, GLenum srcType, const GLvoid *source, @@ -122,5 +137,9 @@ extern GLvoid * _mesa_unpack_bitmap( GLint width, GLint height, const GLubyte *pixels, const struct gl_pixelstore_attrib *packing ); +extern void +_mesa_pack_bitmap( GLint width, GLint height, const GLubyte *source, + GLubyte *dest, const struct gl_pixelstore_attrib *packing ); + #endif diff --git a/xc/extras/Mesa/src/imaging.c b/xc/extras/Mesa/src/imaging.c index f1d912b6d..1dd37112d 100644 --- a/xc/extras/Mesa/src/imaging.c +++ b/xc/extras/Mesa/src/imaging.c @@ -24,327 +24,1594 @@ */ -/* Stub functions for GL_ARB_imaging subset */ +/* + * Histogram, Min/max and convolution for GL_ARB_imaging subset + * + */ #ifdef PC_HEADER #include "all.h" #else #include "glheader.h" +#include "context.h" +#include "image.h" #include "imaging.h" +#include "mmath.h" +#include "span.h" #endif -#define WARNING(MSG) fprintf(stderr,"Mesa warning: GL_ARB_imaging functions not implemented\n") +/**********************************************************************/ +/**** Histogram and Min/max *****/ +/**********************************************************************/ - -#if 0 -void _mesa_BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) +static void +pack_histogram( GLcontext *ctx, + GLuint n, CONST GLuint rgba[][4], + GLenum format, GLenum type, GLvoid *destination, + const struct gl_pixelstore_attrib *packing ) { - (void) r; - (void) g; - (void) b; - (void) a; - WARNING("glBlendColor"); -} + const GLint comps = _mesa_components_in_format(format); + GLuint luminance[MAX_WIDTH]; -void _mesa_BlendEquation(GLenum eq) -{ - (void) eq; - WARNING("glBlendEquation"); + if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) { + GLuint i; + for (i = 0; i < n; i++) { + luminance[i] = rgba[i][RCOMP] + rgba[i][GCOMP] + rgba[i][BCOMP]; + } + } + +#define PACK_MACRO(TYPE) \ + { \ + GLuint i; \ + switch (format) { \ + case GL_RED: \ + for (i=0;i<n;i++) \ + dst[i] = (TYPE) rgba[i][RCOMP]; \ + break; \ + case GL_GREEN: \ + for (i=0;i<n;i++) \ + dst[i] = (TYPE) rgba[i][GCOMP]; \ + break; \ + case GL_BLUE: \ + for (i=0;i<n;i++) \ + dst[i] = (TYPE) rgba[i][BCOMP]; \ + break; \ + case GL_ALPHA: \ + for (i=0;i<n;i++) \ + dst[i] = (TYPE) rgba[i][ACOMP]; \ + break; \ + case GL_LUMINANCE: \ + for (i=0;i<n;i++) \ + dst[i] = (TYPE) luminance[i]; \ + break; \ + case GL_LUMINANCE_ALPHA: \ + for (i=0;i<n;i++) { \ + dst[i*2+0] = (TYPE) luminance[i]; \ + dst[i*2+1] = (TYPE) rgba[i][ACOMP]; \ + } \ + break; \ + case GL_RGB: \ + for (i=0;i<n;i++) { \ + dst[i*3+0] = (TYPE) rgba[i][RCOMP]; \ + dst[i*3+1] = (TYPE) rgba[i][GCOMP]; \ + dst[i*3+2] = (TYPE) rgba[i][BCOMP]; \ + } \ + break; \ + case GL_RGBA: \ + for (i=0;i<n;i++) { \ + dst[i*4+0] = (TYPE) rgba[i][RCOMP]; \ + dst[i*4+1] = (TYPE) rgba[i][GCOMP]; \ + dst[i*4+2] = (TYPE) rgba[i][BCOMP]; \ + dst[i*4+3] = (TYPE) rgba[i][ACOMP]; \ + } \ + break; \ + case GL_BGR: \ + for (i=0;i<n;i++) { \ + dst[i*3+0] = (TYPE) rgba[i][BCOMP]; \ + dst[i*3+1] = (TYPE) rgba[i][GCOMP]; \ + dst[i*3+2] = (TYPE) rgba[i][RCOMP]; \ + } \ + break; \ + case GL_BGRA: \ + for (i=0;i<n;i++) { \ + dst[i*4+0] = (TYPE) rgba[i][BCOMP]; \ + dst[i*4+1] = (TYPE) rgba[i][GCOMP]; \ + dst[i*4+2] = (TYPE) rgba[i][RCOMP]; \ + dst[i*4+3] = (TYPE) rgba[i][ACOMP]; \ + } \ + break; \ + case GL_ABGR_EXT: \ + for (i=0;i<n;i++) { \ + dst[i*4+0] = (TYPE) rgba[i][ACOMP]; \ + dst[i*4+1] = (TYPE) rgba[i][BCOMP]; \ + dst[i*4+2] = (TYPE) rgba[i][GCOMP]; \ + dst[i*4+3] = (TYPE) rgba[i][RCOMP]; \ + } \ + break; \ + default: \ + gl_problem(ctx, "bad format in pack_histogram"); \ + } \ + } + + switch (type) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) destination; + PACK_MACRO(GLubyte); + } + break; + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) destination; + PACK_MACRO(GLbyte); + } + break; + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) destination; + PACK_MACRO(GLushort); + if (packing->SwapBytes) { + _mesa_swap2(dst, n * comps); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) destination; + PACK_MACRO(GLshort); + if (packing->SwapBytes) { + _mesa_swap2((GLushort *) dst, n * comps); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) destination; + PACK_MACRO(GLuint); + if (packing->SwapBytes) { + _mesa_swap4(dst, n * comps); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) destination; + PACK_MACRO(GLint); + if (packing->SwapBytes) { + _mesa_swap4((GLuint *) dst, n * comps); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) destination; + PACK_MACRO(GLfloat); + if (packing->SwapBytes) { + _mesa_swap4((GLuint *) dst, n * comps); + } + } + break; + default: + gl_problem(ctx, "Bad type in pack_histogram"); + } + +#undef PACK_MACRO } -void _mesa_ColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data) + + +static void +pack_minmax( GLcontext *ctx, CONST GLfloat minmax[2][4], + GLenum format, GLenum type, GLvoid *destination, + const struct gl_pixelstore_attrib *packing ) { - (void) target; - (void) start; - (void) count; - (void) format; - (void) type; - (void) data; - WARNING("glColorSubTable"); + const GLint comps = _mesa_components_in_format(format); + GLuint luminance[2]; + + if (format == GL_LUMINANCE || format == GL_LUMINANCE_ALPHA) { + luminance[0] = minmax[0][RCOMP] + minmax[0][GCOMP] + minmax[0][BCOMP]; + luminance[1] = minmax[1][RCOMP] + minmax[1][GCOMP] + minmax[1][BCOMP]; + } + +#define PACK_MACRO(TYPE, CONVERSION) \ + { \ + GLuint i; \ + switch (format) { \ + case GL_RED: \ + for (i=0;i<2;i++) \ + dst[i] = CONVERSION (minmax[i][RCOMP]); \ + break; \ + case GL_GREEN: \ + for (i=0;i<2;i++) \ + dst[i] = CONVERSION (minmax[i][GCOMP]); \ + break; \ + case GL_BLUE: \ + for (i=0;i<2;i++) \ + dst[i] = CONVERSION (minmax[i][BCOMP]); \ + break; \ + case GL_ALPHA: \ + for (i=0;i<2;i++) \ + dst[i] = CONVERSION (minmax[i][ACOMP]); \ + break; \ + case GL_LUMINANCE: \ + for (i=0;i<2;i++) \ + dst[i] = CONVERSION (luminance[i]); \ + break; \ + case GL_LUMINANCE_ALPHA: \ + for (i=0;i<2;i++) { \ + dst[i*2+0] = CONVERSION (luminance[i]); \ + dst[i*2+1] = CONVERSION (minmax[i][ACOMP]); \ + } \ + break; \ + case GL_RGB: \ + for (i=0;i<2;i++) { \ + dst[i*3+0] = CONVERSION (minmax[i][RCOMP]); \ + dst[i*3+1] = CONVERSION (minmax[i][GCOMP]); \ + dst[i*3+2] = CONVERSION (minmax[i][BCOMP]); \ + } \ + break; \ + case GL_RGBA: \ + for (i=0;i<2;i++) { \ + dst[i*4+0] = CONVERSION (minmax[i][RCOMP]); \ + dst[i*4+1] = CONVERSION (minmax[i][GCOMP]); \ + dst[i*4+2] = CONVERSION (minmax[i][BCOMP]); \ + dst[i*4+3] = CONVERSION (minmax[i][ACOMP]); \ + } \ + break; \ + case GL_BGR: \ + for (i=0;i<2;i++) { \ + dst[i*3+0] = CONVERSION (minmax[i][BCOMP]); \ + dst[i*3+1] = CONVERSION (minmax[i][GCOMP]); \ + dst[i*3+2] = CONVERSION (minmax[i][RCOMP]); \ + } \ + break; \ + case GL_BGRA: \ + for (i=0;i<2;i++) { \ + dst[i*4+0] = CONVERSION (minmax[i][BCOMP]); \ + dst[i*4+1] = CONVERSION (minmax[i][GCOMP]); \ + dst[i*4+2] = CONVERSION (minmax[i][RCOMP]); \ + dst[i*4+3] = CONVERSION (minmax[i][ACOMP]); \ + } \ + break; \ + case GL_ABGR_EXT: \ + for (i=0;i<2;i++) { \ + dst[i*4+0] = CONVERSION (minmax[i][ACOMP]); \ + dst[i*4+1] = CONVERSION (minmax[i][BCOMP]); \ + dst[i*4+2] = CONVERSION (minmax[i][GCOMP]); \ + dst[i*4+3] = CONVERSION (minmax[i][RCOMP]); \ + } \ + break; \ + default: \ + gl_problem(ctx, "bad format in pack_minmax"); \ + } \ + } + + switch (type) { + case GL_UNSIGNED_BYTE: + { + GLubyte *dst = (GLubyte *) destination; + PACK_MACRO(GLubyte, FLOAT_TO_UBYTE); + } + break; + case GL_BYTE: + { + GLbyte *dst = (GLbyte *) destination; + PACK_MACRO(GLbyte, FLOAT_TO_BYTE); + } + break; + case GL_UNSIGNED_SHORT: + { + GLushort *dst = (GLushort *) destination; + PACK_MACRO(GLushort, FLOAT_TO_USHORT); + if (packing->SwapBytes) { + _mesa_swap2(dst, 2 * comps); + } + } + break; + case GL_SHORT: + { + GLshort *dst = (GLshort *) destination; + PACK_MACRO(GLshort, FLOAT_TO_SHORT); + if (packing->SwapBytes) { + _mesa_swap2((GLushort *) dst, 2 * comps); + } + } + break; + case GL_UNSIGNED_INT: + { + GLuint *dst = (GLuint *) destination; + PACK_MACRO(GLuint, FLOAT_TO_UINT); + if (packing->SwapBytes) { + _mesa_swap4(dst, 2 * comps); + } + } + break; + case GL_INT: + { + GLint *dst = (GLint *) destination; + PACK_MACRO(GLint, FLOAT_TO_INT); + if (packing->SwapBytes) { + _mesa_swap4((GLuint *) dst, 2 * comps); + } + } + break; + case GL_FLOAT: + { + GLfloat *dst = (GLfloat *) destination; + PACK_MACRO(GLfloat, (GLfloat)); + if (packing->SwapBytes) { + _mesa_swap4((GLuint *) dst, 2 * comps); + } + } + break; + default: + gl_problem(ctx, "Bad type in pack_minmax"); + } + +#undef PACK_MACRO } -void _mesa_ColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table) + +/* + * Given an internalFormat token passed to glHistogram or glMinMax, + * return the corresponding base format. + * Return -1 if invalid token. + */ +static GLint +base_histogram_format( GLenum format ) { - (void) target; - (void) internalformat; - (void) width; - (void) format; - (void) type; - (void) table; - WARNING("glColorTable"); + switch (format) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return GL_LUMINANCE_ALPHA; + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_RGBA; + default: + return -1; /* error */ + } } -#endif -void _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params) + +/* + * Given an internalFormat token passed to glConvolutionFilter + * or glSeparableFilter, return the corresponding base format. + * Return -1 if invalid token. + */ +static GLint +base_filter_format( GLenum format ) { - (void) target; - (void) pname; - (void) params; - WARNING("glColorTableParameterfv"); + switch (format) { + case GL_ALPHA: + case GL_ALPHA4: + case GL_ALPHA8: + case GL_ALPHA12: + case GL_ALPHA16: + return GL_ALPHA; + case GL_LUMINANCE: + case GL_LUMINANCE4: + case GL_LUMINANCE8: + case GL_LUMINANCE12: + case GL_LUMINANCE16: + return GL_LUMINANCE; + case GL_LUMINANCE_ALPHA: + case GL_LUMINANCE4_ALPHA4: + case GL_LUMINANCE6_ALPHA2: + case GL_LUMINANCE8_ALPHA8: + case GL_LUMINANCE12_ALPHA4: + case GL_LUMINANCE12_ALPHA12: + case GL_LUMINANCE16_ALPHA16: + return GL_LUMINANCE_ALPHA; + case GL_INTENSITY: + case GL_INTENSITY4: + case GL_INTENSITY8: + case GL_INTENSITY12: + case GL_INTENSITY16: + return GL_INTENSITY; + case GL_RGB: + case GL_R3_G3_B2: + case GL_RGB4: + case GL_RGB5: + case GL_RGB8: + case GL_RGB10: + case GL_RGB12: + case GL_RGB16: + return GL_RGB; + case 4: + case GL_RGBA: + case GL_RGBA2: + case GL_RGBA4: + case GL_RGB5_A1: + case GL_RGBA8: + case GL_RGB10_A2: + case GL_RGBA12: + case GL_RGBA16: + return GL_RGBA; + default: + return -1; /* error */ + } } -void _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params) + +void +_mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) { - (void) target; - (void) pname; - (void) params; - WARNING("glColorTableParameteriv"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetHistogram"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinmax(target)"); + return; + } + + if (format != GL_RED && + format != GL_GREEN && + format != GL_BLUE && + format != GL_ALPHA && + format != GL_RGB && + format != GL_RGBA && + format != GL_ABGR_EXT && + format != GL_LUMINANCE && + format != GL_LUMINANCE_ALPHA) { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinmax(format)"); + return; + } + + if (type != GL_UNSIGNED_BYTE && + type != GL_BYTE && + type != GL_UNSIGNED_SHORT && + type != GL_SHORT && + type != GL_UNSIGNED_INT && + type != GL_INT && + type != GL_FLOAT) { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinmax(type)"); + return; + } + + if (!values) + return; + + { + GLfloat minmax[2][4]; + minmax[0][RCOMP] = CLAMP(ctx->MinMax.Min[RCOMP], 0.0F, 1.0F); + minmax[0][GCOMP] = CLAMP(ctx->MinMax.Min[GCOMP], 0.0F, 1.0F); + minmax[0][BCOMP] = CLAMP(ctx->MinMax.Min[BCOMP], 0.0F, 1.0F); + minmax[0][ACOMP] = CLAMP(ctx->MinMax.Min[ACOMP], 0.0F, 1.0F); + minmax[1][RCOMP] = CLAMP(ctx->MinMax.Max[RCOMP], 0.0F, 1.0F); + minmax[1][GCOMP] = CLAMP(ctx->MinMax.Max[GCOMP], 0.0F, 1.0F); + minmax[1][BCOMP] = CLAMP(ctx->MinMax.Max[BCOMP], 0.0F, 1.0F); + minmax[1][ACOMP] = CLAMP(ctx->MinMax.Max[ACOMP], 0.0F, 1.0F); + pack_minmax(ctx, (CONST GLfloat (*)[4]) minmax, + format, type, values, &ctx->Pack); + } + + if (reset) { + _mesa_ResetMinmax(GL_MINMAX); + } } -void _mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) +void +_mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) { - (void) target; - (void) internalformat; - (void) width; - (void) format; - (void) type; - (void) image; - WARNING("glConvolutionFilter1D"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetHistogram"); + + if (target != GL_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogram(target)"); + return; + } + + if (format != GL_RED && + format != GL_GREEN && + format != GL_BLUE && + format != GL_ALPHA && + format != GL_RGB && + format != GL_RGBA && + format != GL_ABGR_EXT && + format != GL_LUMINANCE && + format != GL_LUMINANCE_ALPHA) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogram(format)"); + return; + } + + if (type != GL_UNSIGNED_BYTE && + type != GL_BYTE && + type != GL_UNSIGNED_SHORT && + type != GL_SHORT && + type != GL_UNSIGNED_INT && + type != GL_INT && + type != GL_FLOAT) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogram(type)"); + return; + } + + if (!values) + return; + + pack_histogram(ctx, ctx->Histogram.Width, + (CONST GLuint (*)[4]) ctx->Histogram.Count, + format, type, values, &ctx->Pack); + + if (reset) { + GLuint i; + for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { + ctx->Histogram.Count[i][0] = 0; + ctx->Histogram.Count[i][1] = 0; + ctx->Histogram.Count[i][2] = 0; + ctx->Histogram.Count[i][3] = 0; + } + } } -void _mesa_ConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) + +void +_mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) { - (void) target; - (void) internalformat; - (void) width; - (void) height; - (void) format; - (void) type; - (void) image; - WARNING("glConvolutionFilter2D"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetHistogramParameterfv"); + + if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(target)"); + return; + } + + switch (pname) { + case GL_HISTOGRAM_WIDTH: + *params = (GLfloat) ctx->Histogram.Width; + break; + case GL_HISTOGRAM_FORMAT: + *params = (GLfloat) ctx->Histogram.Format; + break; + case GL_HISTOGRAM_RED_SIZE: + *params = (GLfloat) ctx->Histogram.RedSize; + break; + case GL_HISTOGRAM_GREEN_SIZE: + *params = (GLfloat) ctx->Histogram.GreenSize; + break; + case GL_HISTOGRAM_BLUE_SIZE: + *params = (GLfloat) ctx->Histogram.BlueSize; + break; + case GL_HISTOGRAM_ALPHA_SIZE: + *params = (GLfloat) ctx->Histogram.AlphaSize; + break; + case GL_HISTOGRAM_LUMINANCE_SIZE: + *params = (GLfloat) ctx->Histogram.LuminanceSize; + break; + case GL_HISTOGRAM_SINK: + *params = (GLfloat) ctx->Histogram.Sink; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameterfv(pname)"); + } } -void _mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat params) + +void +_mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) { - (void) target; - (void) pname; - (void) params; - WARNING("glConvolutionParameterf"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetHistogramParameteriv"); + + if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(target)"); + return; + } + + switch (pname) { + case GL_HISTOGRAM_WIDTH: + *params = (GLint) ctx->Histogram.Width; + break; + case GL_HISTOGRAM_FORMAT: + *params = (GLint) ctx->Histogram.Format; + break; + case GL_HISTOGRAM_RED_SIZE: + *params = (GLint) ctx->Histogram.RedSize; + break; + case GL_HISTOGRAM_GREEN_SIZE: + *params = (GLint) ctx->Histogram.GreenSize; + break; + case GL_HISTOGRAM_BLUE_SIZE: + *params = (GLint) ctx->Histogram.BlueSize; + break; + case GL_HISTOGRAM_ALPHA_SIZE: + *params = (GLint) ctx->Histogram.AlphaSize; + break; + case GL_HISTOGRAM_LUMINANCE_SIZE: + *params = (GLint) ctx->Histogram.LuminanceSize; + break; + case GL_HISTOGRAM_SINK: + *params = (GLint) ctx->Histogram.Sink; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetHistogramParameteriv(pname)"); + } } -void _mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) + +void +_mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) { - (void) target; - (void) pname; - (void) params; - WARNING("glConvolutionParameterfv"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetMinmaxParameterfv"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinmaxParameterfv(target)"); + return; + } + if (pname == GL_MINMAX_FORMAT) { + *params = (GLfloat) ctx->MinMax.Format; + } + else if (pname == GL_MINMAX_SINK) { + *params = (GLfloat) ctx->MinMax.Sink; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameterfv(pname)"); + } } -void _mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint params) + +void +_mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) { - (void) target; - (void) pname; - (void) params; - WARNING("glConvolutionParameteri"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetMinmaxParameteriv"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinmaxParameteriv(target)"); + return; + } + if (pname == GL_MINMAX_FORMAT) { + *params = (GLint) ctx->MinMax.Format; + } + else if (pname == GL_MINMAX_SINK) { + *params = (GLint) ctx->MinMax.Sink; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetMinMaxParameteriv(pname)"); + } } -void _mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) + +void +_mesa_Histogram(GLenum target, GLsizei width, GLenum internalFormat, GLboolean sink) { - (void) target; - (void) pname; - (void) params; - WARNING("glConvolutionParameteriv"); + GLuint i; + GLboolean error = GL_FALSE; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glHistogram"); + + if (target != GL_HISTOGRAM && target != GL_PROXY_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glHistogram(target)"); + return; + } + + if (width < 0 || width > HISTOGRAM_TABLE_SIZE) { + if (target == GL_PROXY_HISTOGRAM) { + error = GL_TRUE; + } + else { + if (width < 0) + gl_error(ctx, GL_INVALID_VALUE, "glHistogram(width)"); + else + gl_error(ctx, GL_TABLE_TOO_LARGE, "glHistogram(width)"); + return; + } + } + + if (width != 0 && _mesa_bitcount(width) != 1) { + if (target == GL_PROXY_HISTOGRAM) { + error = GL_TRUE; + } + else { + gl_error(ctx, GL_INVALID_VALUE, "glHistogram(width)"); + return; + } + } + + if (base_histogram_format(internalFormat) < 0) { + if (target == GL_PROXY_HISTOGRAM) { + error = GL_TRUE; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glHistogram(internalFormat)"); + return; + } + } + + /* reset histograms */ + for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { + ctx->Histogram.Count[i][0] = 0; + ctx->Histogram.Count[i][1] = 0; + ctx->Histogram.Count[i][2] = 0; + ctx->Histogram.Count[i][3] = 0; + } + + if (error) { + ctx->Histogram.Width = 0; + ctx->Histogram.Format = 0; + ctx->Histogram.RedSize = 0; + ctx->Histogram.GreenSize = 0; + ctx->Histogram.BlueSize = 0; + ctx->Histogram.AlphaSize = 0; + ctx->Histogram.LuminanceSize = 0; + } + else { + ctx->Histogram.Width = width; + ctx->Histogram.Format = internalFormat; + ctx->Histogram.Sink = sink; + ctx->Histogram.RedSize = 0xffffffff; + ctx->Histogram.GreenSize = 0xffffffff; + ctx->Histogram.BlueSize = 0xffffffff; + ctx->Histogram.AlphaSize = 0xffffffff; + ctx->Histogram.LuminanceSize = 0xffffffff; + } } -void _mesa_CopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width) + +void +_mesa_Minmax(GLenum target, GLenum internalFormat, GLboolean sink) { - (void) target; - (void) start; - (void) x; - (void) y; - (void) width; - WARNING("glCopyColorSubTable"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glMinmax"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glMinMax(target)"); + return; + } + + if (base_histogram_format(internalFormat) < 0) { + gl_error(ctx, GL_INVALID_ENUM, "glMinMax(internalFormat)"); + return; + } + + ctx->MinMax.Sink = sink; } -void _mesa_CopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) + +void +_mesa_ResetHistogram(GLenum target) { - (void) target; - (void) internalformat; - (void) x; - (void) y; - (void) width; - WARNING("glCopyColorTable"); + GLuint i; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glResetHistogram"); + + if (target != GL_HISTOGRAM) { + gl_error(ctx, GL_INVALID_ENUM, "glResetHistogram(target)"); + return; + } + + for (i = 0; i < HISTOGRAM_TABLE_SIZE; i++) { + ctx->Histogram.Count[i][0] = 0; + ctx->Histogram.Count[i][1] = 0; + ctx->Histogram.Count[i][2] = 0; + ctx->Histogram.Count[i][3] = 0; + } } -void _mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width) + +void +_mesa_ResetMinmax(GLenum target) { - (void) target; - (void) internalformat; - (void) x; - (void) y; - (void) width; - WARNING("glCopyConvolutionFilter1D"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glResetMinmax"); + + if (target != GL_MINMAX) { + gl_error(ctx, GL_INVALID_ENUM, "glResetMinMax(target)"); + return; + } + + ctx->MinMax.Min[RCOMP] = 1000; ctx->MinMax.Max[RCOMP] = -1000; + ctx->MinMax.Min[GCOMP] = 1000; ctx->MinMax.Max[GCOMP] = -1000; + ctx->MinMax.Min[BCOMP] = 1000; ctx->MinMax.Max[BCOMP] = -1000; + ctx->MinMax.Min[ACOMP] = 1000; ctx->MinMax.Max[ACOMP] = -1000; } -void _mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height) + + +/* + * Update the min/max values from an array of fragment colors. + */ +void +_mesa_update_minmax(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]) { - (void) target; - (void) internalformat; - (void) x; - (void) y; - (void) width; - (void) height; - WARNING("glCopyConvolutionFilter2D"); + GLuint i; + for (i = 0; i < n; i++) { + /* update mins */ + if (rgba[i][RCOMP] < ctx->MinMax.Min[RCOMP]) + ctx->MinMax.Min[RCOMP] = rgba[i][RCOMP]; + if (rgba[i][GCOMP] < ctx->MinMax.Min[GCOMP]) + ctx->MinMax.Min[GCOMP] = rgba[i][GCOMP]; + if (rgba[i][BCOMP] < ctx->MinMax.Min[BCOMP]) + ctx->MinMax.Min[BCOMP] = rgba[i][BCOMP]; + if (rgba[i][ACOMP] < ctx->MinMax.Min[ACOMP]) + ctx->MinMax.Min[ACOMP] = rgba[i][ACOMP]; + + /* update maxs */ + if (rgba[i][RCOMP] > ctx->MinMax.Max[RCOMP]) + ctx->MinMax.Max[RCOMP] = rgba[i][RCOMP]; + if (rgba[i][GCOMP] > ctx->MinMax.Max[GCOMP]) + ctx->MinMax.Max[GCOMP] = rgba[i][GCOMP]; + if (rgba[i][BCOMP] > ctx->MinMax.Max[BCOMP]) + ctx->MinMax.Max[BCOMP] = rgba[i][BCOMP]; + if (rgba[i][ACOMP] > ctx->MinMax.Max[ACOMP]) + ctx->MinMax.Max[ACOMP] = rgba[i][ACOMP]; + } } -#if 0 -void _mesa_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid *table) + +/* + * Update the histogram values from an array of fragment colors. + */ +void +_mesa_update_histogram(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]) { - (void) target; - (void) format; - (void) type; - (void) table; - WARNING("glGetColorTable"); + const GLint max = ctx->Histogram.Width - 1; + GLfloat w = (GLfloat) max; + GLuint i; + + if (ctx->Histogram.Width == 0) + return; + + for (i = 0; i < n; i++) { + GLint ri = (GLint) (rgba[i][RCOMP] * w + 0.5F); + GLint gi = (GLint) (rgba[i][GCOMP] * w + 0.5F); + GLint bi = (GLint) (rgba[i][BCOMP] * w + 0.5F); + GLint ai = (GLint) (rgba[i][ACOMP] * w + 0.5F); + ri = CLAMP(ri, 0, max); + gi = CLAMP(gi, 0, max); + bi = CLAMP(bi, 0, max); + ai = CLAMP(ai, 0, max); + ctx->Histogram.Count[ri][RCOMP]++; + ctx->Histogram.Count[gi][GCOMP]++; + ctx->Histogram.Count[bi][BCOMP]++; + ctx->Histogram.Count[ai][ACOMP]++; + } } -void _mesa_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params) + + +/**********************************************************************/ +/**** Convolution *****/ +/**********************************************************************/ + +void +_mesa_ConvolutionFilter1D(GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *image) { - (void) target; - (void) pname; - (void) params; - WARNING("glGetColorTableParameterfv"); + GLenum baseFormat; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glConvolutionFilter1D"); + + if (target != GL_CONVOLUTION_1D) { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(target)"); + return; + } + + baseFormat = base_filter_format(internalFormat); + if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(internalFormat)"); + return; + } + + if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { + gl_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter1D(width)"); + return; + } + + if (!_mesa_is_legal_format_and_type(format, type) || + format == GL_COLOR_INDEX || + format == GL_STENCIL_INDEX || + format == GL_DEPTH_COMPONENT || + type == GL_BITMAP) { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter1D(format or type)"); + return; + } + + ctx->Convolution1D.Format = format; + ctx->Convolution1D.InternalFormat = internalFormat; + ctx->Convolution1D.Width = width; + ctx->Convolution1D.Height = 1; + + /* unpack filter image and apply scale and bias */ + _mesa_unpack_float_color_span(ctx, width, GL_RGBA, + ctx->Convolution1D.Filter, + format, type, image, &ctx->Unpack, + GL_FALSE, GL_FALSE); + { + const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[0]; + const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[0]; + GLint i; + for (i = 0; i < width; i++) { + GLfloat r = ctx->Convolution1D.Filter[i * 4 + 0]; + GLfloat g = ctx->Convolution1D.Filter[i * 4 + 1]; + GLfloat b = ctx->Convolution1D.Filter[i * 4 + 2]; + GLfloat a = ctx->Convolution1D.Filter[i * 4 + 3]; + r = r * scale[0] + bias[0]; + g = g * scale[1] + bias[1]; + b = b * scale[2] + bias[2]; + a = a * scale[3] + bias[3]; + ctx->Convolution1D.Filter[i * 4 + 0] = r; + ctx->Convolution1D.Filter[i * 4 + 1] = g; + ctx->Convolution1D.Filter[i * 4 + 2] = b; + ctx->Convolution1D.Filter[i * 4 + 3] = a; + } + } } -void _mesa_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params) + +void +_mesa_ConvolutionFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image) { - (void) target; - (void) pname; - (void) params; - WARNING("glGetColorTableParameteriv"); + GLenum baseFormat; + GLint i, components; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glConvolutionFilter2D"); + + if (target != GL_CONVOLUTION_2D) { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(target)"); + return; + } + + baseFormat = base_filter_format(internalFormat); + if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(internalFormat)"); + return; + } + + if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { + gl_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter2D(width)"); + return; + } + if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { + gl_error(ctx, GL_INVALID_VALUE, "glConvolutionFilter2D(height)"); + return; + } + + if (!_mesa_is_legal_format_and_type(format, type) || + format == GL_COLOR_INDEX || + format == GL_STENCIL_INDEX || + format == GL_DEPTH_COMPONENT || + type == GL_BITMAP) { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionFilter2D(format or type)"); + return; + } + + components = _mesa_components_in_format(format); + assert(components > 0); /* this should have been caught earlier */ + + ctx->Convolution2D.Format = format; + ctx->Convolution2D.InternalFormat = internalFormat; + ctx->Convolution2D.Width = width; + ctx->Convolution2D.Height = height; + + /* unpack filter image and apply scale and bias */ + for (i = 0; i < height; i++) { + const GLvoid *src = _mesa_image_address(&ctx->Unpack, image, width, + height, format, type, 0, i, 0); + GLfloat *dst = ctx->Convolution2D.Filter + i * width * components; + _mesa_unpack_float_color_span(ctx, width, GL_RGBA, dst, + format, type, src, &ctx->Unpack, + GL_FALSE, GL_FALSE); + } + + { + const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[1]; + const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[1]; + for (i = 0; i < width * height * 4; i++) { + GLfloat r = ctx->Convolution2D.Filter[i * 4 + 0]; + GLfloat g = ctx->Convolution2D.Filter[i * 4 + 1]; + GLfloat b = ctx->Convolution2D.Filter[i * 4 + 2]; + GLfloat a = ctx->Convolution2D.Filter[i * 4 + 3]; + r = r * scale[0] + bias[0]; + g = g * scale[1] + bias[1]; + b = b * scale[2] + bias[2]; + a = a * scale[3] + bias[3]; + ctx->Convolution2D.Filter[i * 4 + 0] = r; + ctx->Convolution2D.Filter[i * 4 + 1] = g; + ctx->Convolution2D.Filter[i * 4 + 2] = b; + ctx->Convolution2D.Filter[i * 4 + 3] = a; + } + } } -#endif -void _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image) + +void +_mesa_ConvolutionParameterf(GLenum target, GLenum pname, GLfloat param) { - (void) target; - (void) format; - (void) type; - (void) image; - WARNING("glGetConvolutionFilter"); + GET_CURRENT_CONTEXT(ctx); + GLuint c; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glConvolutionParameterf"); + + switch (target) { + case GL_CONVOLUTION_1D: + c = 0; + break; + case GL_CONVOLUTION_2D: + c = 1; + break; + case GL_SEPARABLE_2D: + c = 2; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(target)"); + return; + } + + switch (pname) { + case GL_CONVOLUTION_BORDER_MODE: + if (param == (GLfloat) GL_REDUCE || + param == (GLfloat) GL_CONSTANT_BORDER || + param == (GLfloat) GL_REPLICATE_BORDER) { + ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) param; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(params)"); + return; + } + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterf(pname)"); + return; + } } -void _mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) + +void +_mesa_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params) { - (void) target; - (void) pname; - (void) params; - WARNING("glGetConvolutionParameterfv"); + GET_CURRENT_CONTEXT(ctx); + struct gl_convolution_attrib *conv; + GLuint c; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glConvolutionParameterfv"); + + switch (target) { + case GL_CONVOLUTION_1D: + c = 0; + conv = &ctx->Convolution1D; + break; + case GL_CONVOLUTION_2D: + c = 1; + conv = &ctx->Convolution2D; + break; + case GL_SEPARABLE_2D: + c = 2; + conv = &ctx->Separable2D; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(target)"); + return; + } + + switch (pname) { + case GL_CONVOLUTION_BORDER_COLOR: + COPY_4V(ctx->Pixel.ConvolutionBorderColor[c], params); + break; + case GL_CONVOLUTION_BORDER_MODE: + if (params[0] == (GLfloat) GL_REDUCE || + params[0] == (GLfloat) GL_CONSTANT_BORDER || + params[0] == (GLfloat) GL_REPLICATE_BORDER) { + ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) params[0]; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(params)"); + return; + } + break; + case GL_CONVOLUTION_FILTER_SCALE: + COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); + break; + case GL_CONVOLUTION_FILTER_BIAS: + COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameterfv(pname)"); + return; + } } -void _mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) + +void +_mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param) { - (void) target; - (void) pname; - (void) params; - WARNING("glGetConvolutionParameteriv"); + GET_CURRENT_CONTEXT(ctx); + GLuint c; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glConvolutionParameteri"); + + switch (target) { + case GL_CONVOLUTION_1D: + c = 0; + break; + case GL_CONVOLUTION_2D: + c = 1; + break; + case GL_SEPARABLE_2D: + c = 2; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(target)"); + return; + } + + switch (pname) { + case GL_CONVOLUTION_BORDER_MODE: + if (param == (GLint) GL_REDUCE || + param == (GLint) GL_CONSTANT_BORDER || + param == (GLint) GL_REPLICATE_BORDER) { + ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) param; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(params)"); + return; + } + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteri(pname)"); + return; + } } -void _mesa_GetMinmax(GLenum target, GLboolean reset, GLenum format, GLenum types, GLvoid *values) + +void +_mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params) { - (void) target; - (void) reset; - (void) format; - (void) types; - (void) values; - WARNING("glGetMinmax"); + GET_CURRENT_CONTEXT(ctx); + struct gl_convolution_attrib *conv; + GLuint c; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glConvolutionParameteriv"); + + switch (target) { + case GL_CONVOLUTION_1D: + c = 0; + conv = &ctx->Convolution1D; + break; + case GL_CONVOLUTION_2D: + c = 1; + conv = &ctx->Convolution2D; + break; + case GL_SEPARABLE_2D: + c = 2; + conv = &ctx->Separable2D; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(target)"); + return; + } + + switch (pname) { + case GL_CONVOLUTION_BORDER_COLOR: + ctx->Pixel.ConvolutionBorderColor[c][0] = INT_TO_FLOAT(params[0]); + ctx->Pixel.ConvolutionBorderColor[c][1] = INT_TO_FLOAT(params[1]); + ctx->Pixel.ConvolutionBorderColor[c][2] = INT_TO_FLOAT(params[2]); + ctx->Pixel.ConvolutionBorderColor[c][3] = INT_TO_FLOAT(params[3]); + break; + case GL_CONVOLUTION_BORDER_MODE: + if (params[0] == (GLint) GL_REDUCE || + params[0] == (GLint) GL_CONSTANT_BORDER || + params[0] == (GLint) GL_REPLICATE_BORDER) { + ctx->Pixel.ConvolutionBorderMode[c] = (GLenum) params[0]; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(params)"); + return; + } + break; + case GL_CONVOLUTION_FILTER_SCALE: + COPY_4V(ctx->Pixel.ConvolutionFilterScale[c], params); + break; + case GL_CONVOLUTION_FILTER_BIAS: + COPY_4V(ctx->Pixel.ConvolutionFilterBias[c], params); + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glConvolutionParameteriv(pname)"); + return; + } } -void _mesa_GetHistogram(GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values) + +void +_mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width) { - (void) target; - (void) reset; - (void) format; - (void) type; - (void) values; - WARNING("glGetHistogram"); + GLenum baseFormat; + GLfloat rgba[MAX_CONVOLUTION_WIDTH][4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyConvolutionFilter1D"); + + if (target != GL_CONVOLUTION_1D) { + gl_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D(target)"); + return; + } + + baseFormat = base_filter_format(internalFormat); + if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { + gl_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter1D(internalFormat)"); + return; + } + + if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { + gl_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter1D(width)"); + return; + } + + /* read pixels from framebuffer */ + gl_read_rgba_span(ctx, ctx->ReadBuffer, width, x, y, (GLubyte (*)[4]) rgba); + + /* store as convolution filter */ + _mesa_ConvolutionFilter1D(target, internalFormat, width, + GL_RGBA, GL_UNSIGNED_BYTE, rgba); } -void _mesa_GetHistogramParameterfv(GLenum target, GLenum pname, GLfloat *params) + +void +_mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height) { - (void) target; - (void) pname; - (void) params; - WARNING("glGetHistogramParameterfv"); + GLenum baseFormat; + GLint i; + struct gl_pixelstore_attrib packSave; + GLfloat rgba[MAX_CONVOLUTION_HEIGHT][MAX_CONVOLUTION_WIDTH][4]; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyConvolutionFilter2D"); + + if (target != GL_CONVOLUTION_2D) { + gl_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D(target)"); + return; + } + + baseFormat = base_filter_format(internalFormat); + if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { + gl_error(ctx, GL_INVALID_ENUM, "glCopyConvolutionFilter2D(internalFormat)"); + return; + } + + if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { + gl_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter2D(width)"); + return; + } + if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { + gl_error(ctx, GL_INVALID_VALUE, "glCopyConvolutionFilter2D(height)"); + return; + } + + /* read pixels from framebuffer */ + for (i = 0; i < height; i++) { + gl_read_rgba_span(ctx, ctx->ReadBuffer, width, x, y + i, + (GLubyte (*)[4]) rgba[i]); + } + + /* + * store as convolution filter + */ + packSave = ctx->Unpack; /* save pixel packing params */ + + ctx->Unpack.Alignment = 1; + ctx->Unpack.RowLength = MAX_CONVOLUTION_WIDTH; + ctx->Unpack.SkipPixels = 0; + ctx->Unpack.SkipRows = 0; + ctx->Unpack.ImageHeight = 0; + ctx->Unpack.SkipImages = 0; + ctx->Unpack.SwapBytes = GL_FALSE; + ctx->Unpack.LsbFirst = GL_FALSE; + + _mesa_ConvolutionFilter2D(target, internalFormat, width, height, + GL_RGBA, GL_UNSIGNED_BYTE, rgba); + + ctx->Unpack = packSave; /* restore pixel packing params */ } -void _mesa_GetHistogramParameteriv(GLenum target, GLenum pname, GLint *params) + +void +_mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image) { - (void) target; - (void) pname; - (void) params; - WARNING("glGetHistogramParameteriv"); + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetConvolutionFilter"); + + if (target != GL_CONVOLUTION_1D && target != GL_CONVOLUTION_2D) { + gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(target)"); + return; + } + + if (!_mesa_is_legal_format_and_type(format, type) || + format == GL_COLOR_INDEX || + format == GL_STENCIL_INDEX || + format == GL_DEPTH_COMPONENT || + type == GL_BITMAP) { + gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)"); + return; + } + + (void) image; + /* XXX store image */ } -void _mesa_GetMinmaxParameterfv(GLenum target, GLenum pname, GLfloat *params) + +void +_mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params) { - (void) target; - (void) pname; - (void) params; - WARNING("glGetMinmaxParameterfv"); + GET_CURRENT_CONTEXT(ctx); + const struct gl_convolution_attrib *conv; + GLuint c; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetConvolutionParameterfv"); + + switch (target) { + case GL_CONVOLUTION_1D: + c = 0; + conv = &ctx->Convolution1D; + break; + case GL_CONVOLUTION_2D: + c = 1; + conv = &ctx->Convolution2D; + break; + case GL_SEPARABLE_2D: + c = 2; + conv = &ctx->Separable2D; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(target)"); + return; + } + + switch (pname) { + case GL_CONVOLUTION_BORDER_COLOR: + COPY_4V(params, ctx->Pixel.ConvolutionBorderColor[c]); + break; + case GL_CONVOLUTION_BORDER_MODE: + *params = (GLfloat) ctx->Pixel.ConvolutionBorderMode[c]; + break; + case GL_CONVOLUTION_FILTER_SCALE: + COPY_4V(params, ctx->Pixel.ConvolutionFilterScale[c]); + break; + case GL_CONVOLUTION_FILTER_BIAS: + COPY_4V(params, ctx->Pixel.ConvolutionFilterBias[c]); + break; + case GL_CONVOLUTION_FORMAT: + *params = (GLfloat) conv->Format; + break; + case GL_CONVOLUTION_WIDTH: + *params = (GLfloat) conv->Width; + break; + case GL_CONVOLUTION_HEIGHT: + *params = (GLfloat) conv->Height; + break; + case GL_MAX_CONVOLUTION_WIDTH: + *params = (GLfloat) ctx->Const.MaxConvolutionWidth; + break; + case GL_MAX_CONVOLUTION_HEIGHT: + *params = (GLfloat) ctx->Const.MaxConvolutionHeight; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameterfv(pname)"); + return; + } } -void _mesa_GetMinmaxParameteriv(GLenum target, GLenum pname, GLint *params) + +void +_mesa_GetConvolutionParameteriv(GLenum target, GLenum pname, GLint *params) { - (void) target; - (void) pname; - (void) params; - WARNING("glGetMinmaxParameteriv"); + GET_CURRENT_CONTEXT(ctx); + const struct gl_convolution_attrib *conv; + GLuint c; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetConvolutionParameteriv"); + + switch (target) { + case GL_CONVOLUTION_1D: + c = 0; + conv = &ctx->Convolution1D; + break; + case GL_CONVOLUTION_2D: + c = 1; + conv = &ctx->Convolution2D; + break; + case GL_SEPARABLE_2D: + c = 2; + conv = &ctx->Separable2D; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv(target)"); + return; + } + + switch (pname) { + case GL_CONVOLUTION_BORDER_COLOR: + params[0] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][0]); + params[1] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][1]); + params[2] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][2]); + params[3] = FLOAT_TO_INT(ctx->Pixel.ConvolutionBorderColor[c][3]); + break; + case GL_CONVOLUTION_BORDER_MODE: + *params = (GLint) ctx->Pixel.ConvolutionBorderMode; + break; + case GL_CONVOLUTION_FILTER_SCALE: + params[0] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][0]; + params[1] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][1]; + params[2] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][2]; + params[3] = (GLint) ctx->Pixel.ConvolutionFilterScale[c][3]; + break; + case GL_CONVOLUTION_FILTER_BIAS: + params[0] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][0]; + params[1] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][1]; + params[2] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][2]; + params[3] = (GLint) ctx->Pixel.ConvolutionFilterBias[c][3]; + break; + case GL_CONVOLUTION_FORMAT: + *params = (GLint) conv->Format; + break; + case GL_CONVOLUTION_WIDTH: + *params = (GLint) conv->Width; + break; + case GL_CONVOLUTION_HEIGHT: + *params = (GLint) conv->Height; + break; + case GL_MAX_CONVOLUTION_WIDTH: + *params = (GLint) ctx->Const.MaxConvolutionWidth; + break; + case GL_MAX_CONVOLUTION_HEIGHT: + *params = (GLint) ctx->Const.MaxConvolutionHeight; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionParameteriv(pname)"); + return; + } } -void _mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span) + +void +_mesa_GetSeparableFilter(GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span) { - (void) target; - (void) format; - (void) type; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetSeparableFilter"); + + if (target != GL_SEPARABLE_2D) { + gl_error(ctx, GL_INVALID_ENUM, "glGetSeparableFilter(target)"); + return; + } + + if (!_mesa_is_legal_format_and_type(format, type) || + format == GL_COLOR_INDEX || + format == GL_STENCIL_INDEX || + format == GL_DEPTH_COMPONENT || + type == GL_BITMAP) { + gl_error(ctx, GL_INVALID_ENUM, "glGetConvolutionFilter(format or type)"); + return; + } + (void) row; (void) column; (void) span; - WARNING("glGetSeperableFilter"); } -void _mesa_Histogram(GLenum target, GLsizei width, GLenum internalformat, GLboolean sink) -{ - (void) target; - (void) width; - (void) internalformat; - (void) sink; - WARNING("glHistogram"); -} -void _mesa_Minmax(GLenum target, GLenum internalformat, GLboolean sink) +void +_mesa_SeparableFilter2D(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) { - (void) target; - (void) internalformat; - (void) sink; - WARNING("glMinmax"); -} + const GLint colStart = MAX_CONVOLUTION_WIDTH * 4; + GLenum baseFormat; + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glSeparableFilter2D"); -void _mesa_ResetHistogram(GLenum target) -{ - (void) target; - WARNING("glResetHistogram"); -} + if (target != GL_SEPARABLE_2D) { + gl_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(target)"); + return; + } -void _mesa_ResetMinmax(GLenum target) -{ - (void) target; - WARNING("glResetMinmax"); -} + baseFormat = base_filter_format(internalFormat); + if (baseFormat < 0 || baseFormat == GL_COLOR_INDEX) { + gl_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(internalFormat)"); + return; + } -void _mesa_SeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column) -{ - (void) target; - (void) internalformat; - (void) width; - (void) height; - (void) format; - (void) type; - (void) row; - (void) column; - WARNING("glSeparableFilter2D"); + if (width < 0 || width > MAX_CONVOLUTION_WIDTH) { + gl_error(ctx, GL_INVALID_VALUE, "glSeparableFilter2D(width)"); + return; + } + if (height < 0 || height > MAX_CONVOLUTION_HEIGHT) { + gl_error(ctx, GL_INVALID_VALUE, "glSeparableFilter2D(height)"); + return; + } + + if (!_mesa_is_legal_format_and_type(format, type) || + format == GL_COLOR_INDEX || + format == GL_STENCIL_INDEX || + format == GL_DEPTH_COMPONENT || + type == GL_BITMAP) { + gl_error(ctx, GL_INVALID_ENUM, "glSeparableFilter2D(format or type)"); + return; + } + + ctx->Separable2D.Format = format; + ctx->Separable2D.InternalFormat = internalFormat; + ctx->Separable2D.Width = width; + ctx->Separable2D.Height = height; + + /* unpack row filter */ + _mesa_unpack_float_color_span(ctx, width, GL_RGBA, + ctx->Separable2D.Filter, + format, type, row, &ctx->Unpack, + GL_FALSE, GL_FALSE); + { + const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[2]; + const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[2]; + GLint i; + for (i = 0; i < width; i++) { + GLfloat r = ctx->Separable2D.Filter[i * 4 + 0]; + GLfloat g = ctx->Separable2D.Filter[i * 4 + 1]; + GLfloat b = ctx->Separable2D.Filter[i * 4 + 2]; + GLfloat a = ctx->Separable2D.Filter[i * 4 + 3]; + r = r * scale[0] + bias[0]; + g = g * scale[1] + bias[1]; + b = b * scale[2] + bias[2]; + a = a * scale[3] + bias[3]; + ctx->Separable2D.Filter[i * 4 + 0] = r; + ctx->Separable2D.Filter[i * 4 + 1] = g; + ctx->Separable2D.Filter[i * 4 + 2] = b; + ctx->Separable2D.Filter[i * 4 + 3] = a; + } + } + + /* unpack column filter */ + _mesa_unpack_float_color_span(ctx, width, GL_RGBA, + &ctx->Separable2D.Filter[colStart], + format, type, column, &ctx->Unpack, + GL_FALSE, GL_FALSE); + { + const GLfloat *scale = ctx->Pixel.ConvolutionFilterScale[2]; + const GLfloat *bias = ctx->Pixel.ConvolutionFilterBias[2]; + GLint i; + for (i = 0; i < width; i++) { + GLfloat r = ctx->Separable2D.Filter[i * 4 + 0 + colStart]; + GLfloat g = ctx->Separable2D.Filter[i * 4 + 1 + colStart]; + GLfloat b = ctx->Separable2D.Filter[i * 4 + 2 + colStart]; + GLfloat a = ctx->Separable2D.Filter[i * 4 + 3 + colStart]; + r = r * scale[0] + bias[0]; + g = g * scale[1] + bias[1]; + b = b * scale[2] + bias[2]; + a = a * scale[3] + bias[3]; + ctx->Separable2D.Filter[i * 4 + 0 + colStart] = r; + ctx->Separable2D.Filter[i * 4 + 1 + colStart] = g; + ctx->Separable2D.Filter[i * 4 + 2 + colStart] = b; + ctx->Separable2D.Filter[i * 4 + 3 + colStart] = a; + } + } } + diff --git a/xc/extras/Mesa/src/imaging.h b/xc/extras/Mesa/src/imaging.h index f376be5f6..1a4b9ccc6 100644 --- a/xc/extras/Mesa/src/imaging.h +++ b/xc/extras/Mesa/src/imaging.h @@ -32,25 +32,11 @@ #include "all.h" #else #include "glheader.h" +#include "types.h" #endif -#if 0 -extern void _mesa_BlendColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a); - -extern void _mesa_BlendEquation(GLenum eq); - -extern void _mesa_ColorSubTable(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data); - -extern void _mesa_ColorTable(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table); -#endif - -extern void _mesa_ColorTableParameterfv(GLenum target, GLenum pname, const GLfloat *params); - -extern void _mesa_ColorTableParameteriv(GLenum target, GLenum pname, const GLint *params); - - extern void _mesa_ConvolutionFilter1D(GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image); extern void _mesa_ConvolutionFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image); @@ -63,22 +49,10 @@ extern void _mesa_ConvolutionParameteri(GLenum target, GLenum pname, GLint param extern void _mesa_ConvolutionParameteriv(GLenum target, GLenum pname, const GLint *params); -extern void _mesa_CopyColorSubTable(GLenum target, GLsizei start, GLint x, GLint y, GLsizei width); - -extern void _mesa_CopyColorTable(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); - extern void _mesa_CopyConvolutionFilter1D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width); extern void _mesa_CopyConvolutionFilter2D(GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height); -#if 0 -extern void _mesa_GetColorTable(GLenum target, GLenum format, GLenum type, GLvoid *table); - -extern void _mesa_GetColorTableParameterfv(GLenum target, GLenum pname, GLfloat *params); - -extern void _mesa_GetColorTableParameteriv(GLenum target, GLenum pname, GLint *params); -#endif - extern void _mesa_GetConvolutionFilter(GLenum target, GLenum format, GLenum type, GLvoid *image); extern void _mesa_GetConvolutionParameterfv(GLenum target, GLenum pname, GLfloat *params); @@ -109,4 +83,12 @@ extern void _mesa_ResetMinmax(GLenum target); extern void _mesa_SeparableFilter2D(GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column); + +extern void +_mesa_update_minmax(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]); + +extern void +_mesa_update_histogram(GLcontext *ctx, GLuint n, const GLfloat rgba[][4]); + + #endif diff --git a/xc/extras/Mesa/src/lines.c b/xc/extras/Mesa/src/lines.c index 1b075e25f..dd0649ba0 100644 --- a/xc/extras/Mesa/src/lines.c +++ b/xc/extras/Mesa/src/lines.c @@ -57,6 +57,8 @@ _mesa_LineWidth( GLfloat width ) ctx->TriangleCaps &= ~DD_LINE_WIDTH; if (width != 1.0) ctx->TriangleCaps |= DD_LINE_WIDTH; ctx->NewState |= NEW_RASTER_OPS; + if (ctx->Driver.LineWidth) + (*ctx->Driver.LineWidth)(ctx, width); } } @@ -70,6 +72,9 @@ _mesa_LineStipple( GLint factor, GLushort pattern ) ctx->Line.StippleFactor = CLAMP( factor, 1, 256 ); ctx->Line.StipplePattern = pattern; ctx->NewState |= NEW_RASTER_OPS; + + if (ctx->Driver.LineStipple) + ctx->Driver.LineStipple( ctx, factor, pattern ); } @@ -110,22 +115,13 @@ _mesa_LineStipple( GLint factor, GLushort pattern ) static void flat_ci_line( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert ) { - GLint count; - GLint *pbx = ctx->PB->x; - GLint *pby = ctx->PB->y; - PB_SET_INDEX( ctx, ctx->PB, ctx->VB->IndexPtr->data[pvert] ); - count = ctx->PB->count; + PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] ); #define INTERP_XY 1 - -#define PLOT(X,Y) \ - pbx[count] = X; \ - pby[count] = Y; \ - count++; +#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0); #include "linetemp.h" - ctx->PB->count = count; gl_flush_pb(ctx); } @@ -135,25 +131,14 @@ static void flat_ci_line( GLcontext *ctx, static void flat_ci_z_line( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert ) { - GLint count; - GLint *pbx = ctx->PB->x; - GLint *pby = ctx->PB->y; - GLdepth *pbz = ctx->PB->z; - PB_SET_INDEX( ctx, ctx->PB, ctx->VB->IndexPtr->data[pvert] ); - count = ctx->PB->count; + PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] ); #define INTERP_XY 1 #define INTERP_Z 1 - -#define PLOT(X,Y) \ - pbx[count] = X; \ - pby[count] = Y; \ - pbz[count] = Z; \ - count++; +#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z); #include "linetemp.h" - ctx->PB->count = count; gl_flush_pb(ctx); } @@ -163,23 +148,14 @@ static void flat_ci_z_line( GLcontext *ctx, static void flat_rgba_line( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert ) { - GLint count; - GLint *pbx = ctx->PB->x; - GLint *pby = ctx->PB->y; - GLubyte *color = ctx->VB->ColorPtr->data[pvert]; - PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] ); - count = ctx->PB->count; + const GLubyte *color = ctx->VB->ColorPtr->data[pvert]; + PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] ); #define INTERP_XY 1 - -#define PLOT(X,Y) \ - pbx[count] = X; \ - pby[count] = Y; \ - count++; +#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, 0); #include "linetemp.h" - ctx->PB->count = count; gl_flush_pb(ctx); } @@ -189,26 +165,15 @@ static void flat_rgba_line( GLcontext *ctx, static void flat_rgba_z_line( GLcontext *ctx, GLuint vert0, GLuint vert1, GLuint pvert ) { - GLint count; - GLint *pbx = ctx->PB->x; - GLint *pby = ctx->PB->y; - GLdepth *pbz = ctx->PB->z; - GLubyte *color = ctx->VB->ColorPtr->data[pvert]; - PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] ); - count = ctx->PB->count; + const GLubyte *color = ctx->VB->ColorPtr->data[pvert]; + PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] ); #define INTERP_XY 1 #define INTERP_Z 1 - -#define PLOT(X,Y) \ - pbx[count] = X; \ - pby[count] = Y; \ - pbz[count] = Z; \ - count++; +#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z); #include "linetemp.h" - ctx->PB->count = count; gl_flush_pb(ctx); } @@ -221,9 +186,11 @@ static void smooth_ci_line( GLcontext *ctx, GLint count = ctx->PB->count; GLint *pbx = ctx->PB->x; GLint *pby = ctx->PB->y; - GLuint *pbi = ctx->PB->i; + GLuint *pbi = ctx->PB->index; (void) pvert; + ctx->PB->mono = GL_FALSE; + #define INTERP_XY 1 #define INTERP_INDEX 1 @@ -249,9 +216,11 @@ static void smooth_ci_z_line( GLcontext *ctx, GLint *pbx = ctx->PB->x; GLint *pby = ctx->PB->y; GLdepth *pbz = ctx->PB->z; - GLuint *pbi = ctx->PB->i; + GLuint *pbi = ctx->PB->index; (void) pvert; + ctx->PB->mono = GL_FALSE; + #define INTERP_XY 1 #define INTERP_Z 1 #define INTERP_INDEX 1 @@ -281,6 +250,8 @@ static void smooth_rgba_line( GLcontext *ctx, GLubyte (*pbrgba)[4] = ctx->PB->rgba; (void) pvert; + ctx->PB->mono = GL_FALSE; + #define INTERP_XY 1 #define INTERP_RGB 1 #define INTERP_ALPHA 1 @@ -313,6 +284,8 @@ static void smooth_rgba_z_line( GLcontext *ctx, GLubyte (*pbrgba)[4] = ctx->PB->rgba; (void) pvert; + ctx->PB->mono = GL_FALSE; + #define INTERP_XY 1 #define INTERP_Z 1 #define INTERP_RGB 1 @@ -352,9 +325,11 @@ static void general_smooth_ci_line( GLcontext *ctx, GLint *pbx = ctx->PB->x; GLint *pby = ctx->PB->y; GLdepth *pbz = ctx->PB->z; - GLuint *pbi = ctx->PB->i; + GLuint *pbi = ctx->PB->index; (void) pvert; + ctx->PB->mono = GL_FALSE; + if (ctx->Line.StippleFlag) { /* stippled */ #define INTERP_XY 1 @@ -424,7 +399,7 @@ static void general_flat_ci_line( GLcontext *ctx, GLint *pbx = ctx->PB->x; GLint *pby = ctx->PB->y; GLdepth *pbz = ctx->PB->z; - PB_SET_INDEX( ctx, ctx->PB, ctx->VB->IndexPtr->data[pvert] ); + PB_SET_INDEX( ctx->PB, ctx->VB->IndexPtr->data[pvert] ); count = ctx->PB->count; if (ctx->Line.StippleFlag) { @@ -492,6 +467,8 @@ static void general_smooth_rgba_line( GLcontext *ctx, GLubyte (*pbrgba)[4] = ctx->PB->rgba; (void) pvert; + ctx->PB->mono = GL_FALSE; + if (ctx->Line.StippleFlag) { /* stippled */ #define INTERP_XY 1 @@ -584,7 +561,7 @@ static void general_flat_rgba_line( GLcontext *ctx, GLint *pby = ctx->PB->y; GLdepth *pbz = ctx->PB->z; GLubyte *color = ctx->VB->ColorPtr->data[pvert]; - PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] ); + PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] ); count = ctx->PB->count; if (ctx->Line.StippleFlag) { @@ -653,7 +630,7 @@ static void flat_textured_line( GLcontext *ctx, GLfloat *pbt = ctx->PB->t[0]; GLfloat *pbu = ctx->PB->u[0]; GLubyte *color = ctx->VB->ColorPtr->data[pv]; - PB_SET_COLOR( ctx, ctx->PB, color[0], color[1], color[2], color[3] ); + PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] ); count = ctx->PB->count; if (ctx->Line.StippleFlag) { @@ -716,6 +693,8 @@ static void smooth_textured_line( GLcontext *ctx, GLubyte (*pbrgba)[4] = ctx->PB->rgba; (void) pvert; + ctx->PB->mono = GL_FALSE; + if (ctx->Line.StippleFlag) { /* stippled */ #define INTERP_XY 1 @@ -793,6 +772,8 @@ static void smooth_multitextured_line( GLcontext *ctx, GLubyte (*pbspec)[3] = ctx->PB->spec; (void) pvert; + ctx->PB->mono = GL_FALSE; + if (ctx->Line.StippleFlag) { /* stippled */ #define INTERP_XY 1 @@ -1023,8 +1004,7 @@ void gl_set_line_function( GLcontext *ctx ) else { if (ctx->Light.ShadeModel==GL_SMOOTH) { /* Width==1, non-stippled, smooth-shaded */ - if (ctx->Depth.Test - || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) { + if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) { if (rgbmode) ctx->Driver.LineFunc = smooth_rgba_z_line; else @@ -1039,8 +1019,7 @@ void gl_set_line_function( GLcontext *ctx ) } else { /* Width==1, non-stippled, flat-shaded */ - if (ctx->Depth.Test - || (ctx->Fog.Enabled && ctx->Hint.Fog==GL_NICEST)) { + if (ctx->Depth.Test || ctx->FogMode == FOG_FRAGMENT) { if (rgbmode) ctx->Driver.LineFunc = flat_rgba_z_line; else diff --git a/xc/extras/Mesa/src/lnaatemp.h b/xc/extras/Mesa/src/lnaatemp.h index 43923e851..926ee49c3 100644 --- a/xc/extras/Mesa/src/lnaatemp.h +++ b/xc/extras/Mesa/src/lnaatemp.h @@ -22,7 +22,7 @@ * 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. */ -/* $XFree86: xc/extras/Mesa/src/lnaatemp.h,v 1.7 2000/02/18 12:18:45 tsi Exp $ */ + /* * Antialiased Line Rasterizer Template @@ -61,22 +61,25 @@ GLint dy = y1 - y0; GLint xStep, yStep; GLint z0, z1; -#ifdef INTERP_RGBA + const GLint depthBits = ctx->Visual->DepthBits; + const GLint fixedToDepthShift = depthBits <= 16 ? FIXED_SHIFT : 0; +#define FixedToDepth(F) ((F) >> fixedToDepthShift) +#if INTERP_RGBA GLfixed fr, fg, fb, fa; /* fixed-pt RGBA */ GLfixed dfr, dfg, dfb, dfa; /* fixed-pt RGBA deltas */ #endif -#ifdef INTERP_SPEC +#if INTERP_SPEC GLfixed fsr, fsg, fsb; /* fixed-pt specular RGBA */ GLfixed dfsr, dfsg, dfsb; /* fixed-pt specular RGBA deltas */ #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX GLfixed fi, dfi; #endif -#if defined(INTERP_STUV0) || defined(INTERP_STUV1) +#if INTERP_STUV0 || INTERP_STUV1 GLfloat invw0 = VB->Win.data[vert0][3]; GLfloat invw1 = VB->Win.data[vert1][3]; #endif -#ifdef INTERP_STUV0 +#if INTERP_STUV0 /* h denotes hyperbolic */ GLfloat hs0 = invw0 * VB->TexCoordPtr[0]->data[vert0][0]; GLfloat dhs = invw1 * VB->TexCoordPtr[0]->data[vert1][0] - hs0; @@ -85,7 +88,7 @@ GLfloat hu0 = 0, dhu = 0; GLfloat hv0 = invw0, dhv = invw1 - invw0; #endif -#ifdef INTERP_STUV1 +#if INTERP_STUV1 GLfloat hs01 = invw0 * VB->TexCoordPtr[1]->data[vert0][0]; GLfloat dhs1 = invw1 * VB->TexCoordPtr[1]->data[vert1][0] - hs01; GLfloat ht01 = invw0 * VB->TexCoordPtr[1]->data[vert0][1]; @@ -97,15 +100,18 @@ if (dx == 0 && dy == 0) return; -#if DEPTH_BITS==16 - z0 = FloatToFixed(VB->Win.data[vert0][2]); - z1 = FloatToFixed(VB->Win.data[vert1][2]); -#else - z0 = (int) VB->Win.data[vert0][2]; - z1 = (int) VB->Win.data[vert1][2]; -#endif + ctx->PB->mono = GL_FALSE; + + if (depthBits <= 16) { + z0 = FloatToFixed(VB->Win.data[vert0][2]); + z1 = FloatToFixed(VB->Win.data[vert1][2]); + } + else { + z0 = (int) VB->Win.data[vert0][2]; + z1 = (int) VB->Win.data[vert1][2]; + } -#ifdef INTERP_STUV0 +#if INTERP_STUV0 if (VB->TexCoordPtr[0]->size > 2) { hu0 = invw0 * VB->TexCoordPtr[0]->data[vert0][2]; dhu = invw1 * VB->TexCoordPtr[0]->data[vert1][2] - hu0; @@ -116,7 +122,7 @@ } #endif -#ifdef INTERP_STUV1 +#if INTERP_STUV1 if (VB->TexCoordPtr[1]->size > 2) { hu01 = invw0 * VB->TexCoordPtr[1]->data[vert0][2]; dhu1 = invw1 * VB->TexCoordPtr[1]->data[vert1][2] - hu01; @@ -127,7 +133,7 @@ } #endif -#ifdef INTERP_RGBA +#if INTERP_RGBA if (ctx->Light.ShadeModel == GL_SMOOTH) { fr = IntToFixed(VB->ColorPtr->data[vert0][0]); fg = IntToFixed(VB->ColorPtr->data[vert0][1]); @@ -142,7 +148,7 @@ dfr = dfg = dfb = dfa = 0; } #endif -#ifdef INTERP_SPEC +#if INTERP_SPEC if (ctx->Light.ShadeModel == GL_SMOOTH) { fsr = IntToFixed(VB->Specular[vert0][0]); fsg = IntToFixed(VB->Specular[vert0][1]); @@ -155,7 +161,7 @@ dfsr = dfsg = dfsb = 0; } #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX if (ctx->Light.ShadeModel == GL_SMOOTH) { fi = IntToFixed(VB->IndexPtr->data[vert0]); } @@ -193,11 +199,10 @@ GLint i; GLint x = x0; GLfloat y = VB->Win.data[vert0][1]; - GLfloat yStep = (VB->Win.data[vert1][1] - y) / (GLfloat) dx; - GLint dz = (z1 - z0) / dx; - GLfloat invDx = 1.0F / dx; - (void) invDx; -#ifdef INTERP_RGBA + const GLfloat invDx = 1.0F / dx; + GLfloat yStep = (VB->Win.data[vert1][1] - y) * invDx; + GLint dz = (GLint) ((z1 - z0) * invDx); +#if INTERP_RGBA if (ctx->Light.ShadeModel == GL_SMOOTH) { dfr = (IntToFixed(VB->ColorPtr->data[vert1][0]) - fr) * invDx; dfg = (IntToFixed(VB->ColorPtr->data[vert1][1]) - fg) * invDx; @@ -205,25 +210,31 @@ dfa = (IntToFixed(VB->ColorPtr->data[vert1][3]) - fa) * invDx; } #endif -#ifdef INTERP_SPEC +#if INTERP_SPEC if (ctx->Light.ShadeModel == GL_SMOOTH) { dfsr = (IntToFixed(VB->Specular[vert1][0]) - fsr) * invDx; dfsg = (IntToFixed(VB->Specular[vert1][1]) - fsg) * invDx; dfsb = (IntToFixed(VB->Specular[vert1][2]) - fsb) * invDx; } #endif -#ifdef INTERP_STUV0 +#if INTERP_STUV0 dhs *= invDx; dht *= invDx; dhu *= invDx; dhv *= invDx; #endif -#ifdef INTERP_STUV1 +#if INTERP_STUV1 dhs1 *= invDx; dht1 *= invDx; dhu1 *= invDx; dhv1 *= invDx; #endif +#if INTERP_INDEX + if (ctx->Light.ShadeModel == GL_SMOOTH) { + dfi = (IntToFixed(VB->IndexPtr->data[vert1]) - fi) * invDx; + } +#endif + for (i = 0; i < dx; i++) { if (solid || (ctx->Line.StipplePattern & (1 << ((ctx->StippleCounter/ctx->Line.StippleFactor) & 0xf)))) { @@ -232,37 +243,33 @@ GLint yTopi = (GLint) yTop; GLint yBoti = (GLint) yBot; GLint iy; -#ifdef INTERP_RGBA +#if INTERP_RGBA GLubyte red = FixedToInt(fr); GLubyte green = FixedToInt(fg); GLubyte blue = FixedToInt(fb); GLubyte alpha = FixedToInt(fa); GLint coverage; #endif -#ifdef INTERP_SPEC +#if INTERP_SPEC GLubyte specRed = FixedToInt(fsr); GLubyte specGreen = FixedToInt(fsg); GLubyte specBlue = FixedToInt(fsb); #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX GLuint index = FixedToInt(fi) & 0xfffffff0; GLuint coverage; #endif -#if DEPTH_BITS==16 - GLdepth z = FixedToInt(z0); -#else - GLdepth z = z0; -#endif + GLdepth z = FixedToDepth(z0); ASSERT(yBoti <= yTopi); { -#ifdef INTERP_STUV0 +#if INTERP_STUV0 GLfloat invQ = 1.0F / hv0; GLfloat s = hs0 * invQ; GLfloat t = ht0 * invQ; GLfloat u = hu0 * invQ; #endif -#ifdef INTERP_STUV1 +#if INTERP_STUV1 GLfloat invQ1 = 1.0F / hv01; GLfloat s1 = hs01 * invQ1; GLfloat t1 = ht01 * invQ1; @@ -270,30 +277,30 @@ #endif /* bottom pixel of swipe */ -#ifdef INTERP_RGBA +#if INTERP_RGBA coverage = (GLint) (alpha * (1.0F - (yBot - yBoti))); #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX coverage = (GLuint) (15.0F * (1.0F - (yBot - yBoti))); #endif PLOT(x, yBoti); yBoti++; /* top pixel of swipe */ -#ifdef INTERP_RGBA +#if INTERP_RGBA coverage = (GLint) (alpha * (yTop - yTopi)); #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX coverage = (GLuint) (15.0F * (yTop - yTopi)); #endif PLOT(x, yTopi); yTopi--; /* pixels between top and bottom with 100% coverage */ -#ifdef INTERP_RGBA +#if INTERP_RGBA coverage = alpha; #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX coverage = 15; #endif for (iy = yBoti; iy <= yTopi; iy++) { @@ -307,30 +314,30 @@ x += xStep; y += yStep; z0 += dz; -#ifdef INTERP_RGBA +#if INTERP_RGBA fr += dfr; fg += dfg; fb += dfb; fa += dfa; #endif -#ifdef INTERP_SPEC +#if INTERP_SPEC fsr += dfsr; fsg += dfsg; fsb += dfsb; #endif -#ifdef INTERP_STUV0 +#if INTERP_STUV0 hs0 += dhs; ht0 += dht; hu0 += dhu; hv0 += dhv; #endif -#ifdef INTERP_STUV1 +#if INTERP_STUV1 hs01 += dhs1; ht01 += dht1; hu01 += dhu1; hv01 += dhv1; #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX fi += dfi; #endif @@ -343,11 +350,10 @@ GLint i; GLint y = y0; GLfloat x = VB->Win.data[vert0][0]; - GLfloat xStep = (VB->Win.data[vert1][0] - x) / (GLfloat) dy; - GLint dz = (z1 - z0) / dy; - GLfloat invDy = 1.0F / dy; - (void) invDy; -#ifdef INTERP_RGBA + const GLfloat invDy = 1.0F / dy; + GLfloat xStep = (VB->Win.data[vert1][0] - x) * invDy; + GLint dz = (GLint) ((z1 - z0) * invDy); +#if INTERP_RGBA if (ctx->Light.ShadeModel == GL_SMOOTH) { dfr = (IntToFixed(VB->ColorPtr->data[vert1][0]) - fr) * invDy; dfg = (IntToFixed(VB->ColorPtr->data[vert1][1]) - fg) * invDy; @@ -355,28 +361,28 @@ dfa = (IntToFixed(VB->ColorPtr->data[vert1][3]) - fa) * invDy; } #endif -#ifdef INTERP_SPEC +#if INTERP_SPEC if (ctx->Light.ShadeModel == GL_SMOOTH) { dfsr = (IntToFixed(VB->Specular[vert1][0]) - fsr) * invDy; dfsg = (IntToFixed(VB->Specular[vert1][1]) - fsg) * invDy; dfsb = (IntToFixed(VB->Specular[vert1][2]) - fsb) * invDy; } #endif -#ifdef INTERP_STUV0 +#if INTERP_STUV0 dhs *= invDy; dht *= invDy; dhu *= invDy; dhv *= invDy; #endif -#ifdef INTERP_STUV1 +#if INTERP_STUV1 dhs1 *= invDy; dht1 *= invDy; dhu1 *= invDy; dhv1 *= invDy; #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX if (ctx->Light.ShadeModel == GL_SMOOTH) { - dfi = (IntToFixed(VB->IndexPtr->data[vert1]) - fi) / dy; + dfi = (IntToFixed(VB->IndexPtr->data[vert1]) - fi) * invDy; } #endif for (i = 0; i < dy; i++) { @@ -386,38 +392,34 @@ GLint xRighti = (GLint) xRight; GLint xLefti = (GLint) xLeft; GLint ix; -#ifdef INTERP_RGBA +#if INTERP_RGBA GLubyte red = FixedToInt(fr); GLubyte green = FixedToInt(fg); GLubyte blue = FixedToInt(fb); GLubyte alpha = FixedToInt(fa); GLint coverage; #endif -#ifdef INTERP_SPEC +#if INTERP_SPEC GLubyte specRed = FixedToInt(fsr); GLubyte specGreen = FixedToInt(fsg); GLubyte specBlue = FixedToInt(fsb); #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX GLuint index = FixedToInt(fi) & 0xfffffff0; GLuint coverage; #endif -#if DEPTH_BITS==16 - GLdepth z = FixedToInt(z0); -#else - GLdepth z = z0; -#endif + GLdepth z = FixedToDepth(z0); ASSERT(xLefti < xRight); { -#ifdef INTERP_STUV0 +#if INTERP_STUV0 GLfloat invQ = 1.0F / hv0; GLfloat s = hs0 * invQ; GLfloat t = ht0 * invQ; GLfloat u = hu0 * invQ; #endif -#ifdef INTERP_STUV1 +#if INTERP_STUV1 GLfloat invQ1 = 1.0F / hv01; GLfloat s1 = hs01 * invQ1; GLfloat t1 = ht01 * invQ1; @@ -425,30 +427,30 @@ #endif /* left pixel of swipe */ -#ifdef INTERP_RGBA +#if INTERP_RGBA coverage = (GLint) (alpha * (1.0F - (xLeft - xLefti))); #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX coverage = (GLuint) (15.0F * (1.0F - (xLeft - xLefti))); #endif PLOT(xLefti, y); xLefti++; /* right pixel of swipe */ -#ifdef INTERP_RGBA +#if INTERP_RGBA coverage = (GLint) (alpha * (xRight - xRighti)); #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX coverage = (GLuint) (15.0F * (xRight - xRighti)); #endif PLOT(xRighti, y) xRighti--; /* pixels between top and bottom with 100% coverage */ -#ifdef INTERP_RGBA +#if INTERP_RGBA coverage = alpha; #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX coverage = 15; #endif for (ix = xLefti; ix <= xRighti; ix++) { @@ -461,30 +463,30 @@ x += xStep; y += yStep; z0 += dz; -#ifdef INTERP_RGBA +#if INTERP_RGBA fr += dfr; fg += dfg; fb += dfb; fa += dfa; #endif -#ifdef INTERP_SPEC +#if INTERP_SPEC fsr += dfsr; fsg += dfsg; fsb += dfsb; #endif -#ifdef INTERP_STUV0 +#if INTERP_STUV0 hs0 += dhs; ht0 += dht; hu0 += dhu; hv0 += dhv; #endif -#ifdef INTERP_STUV1 +#if INTERP_STUV1 hs01 += dhs1; ht01 += dht1; hu01 += dhu1; hv01 += dhv1; #endif -#ifdef INTERP_INDEX +#if INTERP_INDEX fi += dfi; #endif if (!solid) diff --git a/xc/extras/Mesa/src/mem.h b/xc/extras/Mesa/src/mem.h index c0203c7c4..794aa13ef 100644 --- a/xc/extras/Mesa/src/mem.h +++ b/xc/extras/Mesa/src/mem.h @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -34,12 +34,14 @@ /* * Memory allocation */ -#ifdef DEBUG - -/* call Mesa memory functions */ extern void *_mesa_malloc(size_t bytes); extern void *_mesa_calloc(size_t bytes); extern void _mesa_free(void *ptr); + + +#ifdef DEBUG + +/* call Mesa memory functions */ #define MALLOC(BYTES) _mesa_malloc(BYTES) #define CALLOC(BYTES) _mesa_calloc(BYTES) #define MALLOC_STRUCT(T) (struct T *) _mesa_malloc(sizeof(struct T)) @@ -78,6 +80,15 @@ extern void _mesa_free(void *ptr); #endif +/* On some systems we might want to use bzero() (but is bzero portable?) */ +#if defined(__FreeBSD__) +#define BZERO( ADDR, N ) \ + bzero( (void *) (ADDR), (size_t) (N) ) +#else +#define BZERO( ADDR, N ) \ + memset( (void *) (ADDR), 0, (size_t) (N) ) +#endif + /* MACs and BeOS don't support static larger than 32kb, so... */ #if defined(macintosh) && !defined(__MRC__) diff --git a/xc/extras/Mesa/src/pb.c b/xc/extras/Mesa/src/pb.c index 1e5ac03e2..78ff5d07e 100644 --- a/xc/extras/Mesa/src/pb.c +++ b/xc/extras/Mesa/src/pb.c @@ -69,10 +69,11 @@ struct pixel_buffer *gl_alloc_pb(void) int i, j; /* set non-zero fields */ pb->primitive = GL_BITMAP; + pb->mono = GL_TRUE; + /* Set all lambda values to 0.0 since we don't do mipmapping for * points or lines and want to use the level 0 texture image. */ - for (j=0;j<MAX_TEXTURE_UNITS;j++) { for (i=0; i<PB_SIZE; i++) { pb->lambda[j][i] = 0.0; @@ -115,10 +116,10 @@ static void multi_write_index_pixels( GLcontext *ctx, GLuint n, /* make copy of incoming indexes */ MEMCPY( indexTmp, indexes, n * sizeof(GLuint) ); if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_pixels( ctx, n, x, y, indexTmp, mask ); + _mesa_logicop_ci_pixels( ctx, n, x, y, indexTmp, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_pixels( ctx, n, x, y, indexTmp, mask ); + _mesa_mask_index_pixels( ctx, n, x, y, indexTmp, mask ); } (*ctx->Driver.WriteCI32Pixels)( ctx, n, x, y, indexTmp, mask ); } @@ -170,20 +171,20 @@ static void multi_write_rgba_pixels( GLcontext *ctx, GLuint n, MEMCPY( rgbaTmp, rgba, 4 * n * sizeof(GLubyte) ); if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_pixels( ctx, n, x, y, rgbaTmp, mask ); + _mesa_logicop_rgba_pixels( ctx, n, x, y, rgbaTmp, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_pixels( ctx, n, x, y, rgbaTmp, mask ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_pixels( ctx, n, x, y, rgbaTmp, mask ); + _mesa_mask_rgba_pixels( ctx, n, x, y, rgbaTmp, mask ); } (*ctx->Driver.WriteRGBAPixels)( ctx, n, x, y, (const GLubyte (*)[4])rgbaTmp, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_pixels( ctx, n, x, y, - (const GLubyte (*)[4])rgbaTmp, mask ); + _mesa_write_alpha_pixels( ctx, n, x, y, + (const GLubyte (*)[4])rgbaTmp, mask ); } } } @@ -221,10 +222,13 @@ static void add_colors( GLuint n, GLubyte rgba[][4], CONST GLubyte spec[][3] ) */ void gl_flush_pb( GLcontext *ctx ) { - struct pixel_buffer* PB = ctx->PB; + /* Pixel colors may be changed if any of these raster ops enabled */ + const GLuint modBits = FOG_BIT | TEXTURE_BIT | BLEND_BIT | + MASKING_BIT | LOGIC_OP_BIT; + struct pixel_buffer *PB = ctx->PB; GLubyte mask[PB_SIZE]; - if (PB->count==0) + if (PB->count == 0) goto CleanUp; /* initialize mask array and clip pixels simultaneously */ @@ -245,19 +249,9 @@ void gl_flush_pb( GLcontext *ctx ) /* * RGBA COLOR PIXELS */ - if (PB->mono && ctx->MutablePixels) { - /* Copy mono color to all pixels */ - GLuint i; - for (i=0; i<PB->count; i++) { - PB->rgba[i][RCOMP] = PB->color[RCOMP]; - PB->rgba[i][GCOMP] = PB->color[GCOMP]; - PB->rgba[i][BCOMP] = PB->color[BCOMP]; - PB->rgba[i][ACOMP] = PB->color[ACOMP]; - } - } /* If each pixel can be of a different color... */ - if (ctx->MutablePixels || !PB->mono) { + if ((ctx->RasterMask & modBits) || !PB->mono) { if (ctx->Texture.ReallyEnabled) { int texUnit; @@ -292,7 +286,7 @@ void gl_flush_pb( GLcontext *ctx ) if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_pixels(ctx, PB->count, + if (_mesa_stencil_and_ztest_pixels(ctx, PB->count, PB->x, PB->y, PB->z, mask) == 0) { goto CleanUp; } @@ -311,21 +305,21 @@ void gl_flush_pb( GLcontext *ctx ) /* normal case: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_pixels( ctx, PB->count, PB->x, PB->y, - PB->rgba, mask); + _mesa_logicop_rgba_pixels( ctx, PB->count, PB->x, PB->y, + PB->rgba, mask); } else if (ctx->Color.BlendEnabled) { _mesa_blend_pixels( ctx, PB->count, PB->x, PB->y, PB->rgba, mask); } if (ctx->Color.SWmasking) { - gl_mask_rgba_pixels(ctx, PB->count, PB->x, PB->y, PB->rgba, mask); + _mesa_mask_rgba_pixels(ctx, PB->count, PB->x, PB->y, PB->rgba, mask); } (*ctx->Driver.WriteRGBAPixels)( ctx, PB->count, PB->x, PB->y, (const GLubyte (*)[4]) PB->rgba, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_pixels( ctx, PB->count, PB->x, PB->y, + _mesa_write_alpha_pixels( ctx, PB->count, PB->x, PB->y, (const GLubyte (*)[4]) PB->rgba, mask ); } } @@ -344,7 +338,7 @@ void gl_flush_pb( GLcontext *ctx ) if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_pixels(ctx, PB->count, + if (_mesa_stencil_and_ztest_pixels(ctx, PB->count, PB->x, PB->y, PB->z, mask) == 0) { goto CleanUp; } @@ -360,30 +354,21 @@ void gl_flush_pb( GLcontext *ctx ) if (ctx->RasterMask & MULTI_DRAW_BIT) { /* Copy mono color to all pixels */ - GLuint i; - for (i=0; i<PB->count; i++) { - PB->rgba[i][RCOMP] = PB->color[RCOMP]; - PB->rgba[i][GCOMP] = PB->color[GCOMP]; - PB->rgba[i][BCOMP] = PB->color[BCOMP]; - PB->rgba[i][ACOMP] = PB->color[ACOMP]; - } multi_write_rgba_pixels( ctx, PB->count, PB->x, PB->y, (const GLubyte (*)[4]) PB->rgba, mask ); } else { /* normal case: write to exactly one buffer */ - - GLubyte red, green, blue, alpha; - red = PB->color[RCOMP]; - green = PB->color[GCOMP]; - blue = PB->color[BCOMP]; - alpha = PB->color[ACOMP]; + GLubyte red = PB->currentColor[RCOMP]; + GLubyte green = PB->currentColor[GCOMP]; + GLubyte blue = PB->currentColor[BCOMP]; + GLubyte alpha = PB->currentColor[ACOMP]; (*ctx->Driver.Color)( ctx, red, green, blue, alpha ); (*ctx->Driver.WriteMonoRGBAPixels)( ctx, PB->count, PB->x, PB->y, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_mono_alpha_pixels( ctx, PB->count, PB->x, PB->y, - PB->color[ACOMP], mask ); + _mesa_write_mono_alpha_pixels( ctx, PB->count, PB->x, PB->y, + PB->currentColor[ACOMP], mask ); } } /*** ALL DONE ***/ @@ -395,28 +380,18 @@ void gl_flush_pb( GLcontext *ctx ) */ /* If we may be writting pixels with different indexes... */ - if (PB->mono && ctx->MutablePixels) { - /* copy index to all pixels */ - GLuint n = PB->count, indx = PB->index; - GLuint *pbindex = PB->i; - do { - *pbindex++ = indx; - n--; - } while (n); - } - - if (ctx->MutablePixels || !PB->mono) { + if ((ctx->RasterMask & modBits) || !PB->mono) { if (ctx->Fog.Enabled && (ctx->Hint.Fog==GL_NICEST || PB->primitive==GL_BITMAP)) { - _mesa_fog_ci_pixels( ctx, PB->count, PB->z, PB->i ); + _mesa_fog_ci_pixels( ctx, PB->count, PB->z, PB->index ); } /* Scissoring already done above */ if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_pixels(ctx, PB->count, + if (_mesa_stencil_and_ztest_pixels(ctx, PB->count, PB->x, PB->y, PB->z, mask) == 0) { goto CleanUp; } @@ -427,20 +402,20 @@ void gl_flush_pb( GLcontext *ctx ) } if (ctx->RasterMask & MULTI_DRAW_BIT) { - multi_write_index_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + multi_write_index_pixels( ctx, PB->count, PB->x, PB->y, PB->index, mask ); } else { /* normal case: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + _mesa_logicop_ci_pixels( ctx, PB->count, PB->x, PB->y, PB->index, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + _mesa_mask_index_pixels( ctx, PB->count, PB->x, PB->y, PB->index, mask ); } (*ctx->Driver.WriteCI32Pixels)( ctx, PB->count, PB->x, PB->y, - PB->i, mask ); + PB->index, mask ); } /*** ALL DONE ***/ @@ -452,7 +427,7 @@ void gl_flush_pb( GLcontext *ctx ) if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_pixels(ctx, PB->count, + if (_mesa_stencil_and_ztest_pixels(ctx, PB->count, PB->x, PB->y, PB->z, mask) == 0) { goto CleanUp; } @@ -463,19 +438,12 @@ void gl_flush_pb( GLcontext *ctx ) } if (ctx->RasterMask & MULTI_DRAW_BIT) { - GLuint n = PB->count, indx = PB->index; - GLuint *pbindex = PB->i; - do { - *pbindex++ = indx; - n--; - } while (n); - - multi_write_index_pixels( ctx, PB->count, PB->x, PB->y, PB->i, mask ); + multi_write_index_pixels( ctx, PB->count, PB->x, PB->y, PB->index, mask ); } else { /* normal case: write to exactly one buffer */ - (*ctx->Driver.Index)( ctx, PB->index ); + (*ctx->Driver.Index)( ctx, PB->currentIndex ); (*ctx->Driver.WriteMonoCIPixels)( ctx, PB->count, PB->x, PB->y, mask ); } } @@ -483,6 +451,7 @@ void gl_flush_pb( GLcontext *ctx ) CleanUp: PB->count = 0; + PB->mono = GL_TRUE; } diff --git a/xc/extras/Mesa/src/pb.h b/xc/extras/Mesa/src/pb.h index 54fad8388..cf5fecc4b 100644 --- a/xc/extras/Mesa/src/pb.h +++ b/xc/extras/Mesa/src/pb.h @@ -1,9 +1,9 @@ /* * Mesa 3-D graphics library - * Version: 3.1 + * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -24,9 +24,6 @@ */ - - - #ifndef PB_H #define PB_H @@ -34,7 +31,6 @@ #include "types.h" - /* * Pixel buffer size, must be larger than MAX_WIDTH. */ @@ -42,160 +38,197 @@ struct pixel_buffer { - GLint x[PB_SIZE]; /* X window coord in [0,MAX_WIDTH) */ - GLint y[PB_SIZE]; /* Y window coord in [0,MAX_HEIGHT) */ - GLdepth z[PB_SIZE]; /* Z window coord in [0,MAX_DEPTH] */ - GLubyte rgba[PB_SIZE][4]; /* Colors */ - GLubyte spec[PB_SIZE][3]; /* Separate specular colors */ - GLuint i[PB_SIZE]; /* Index */ - GLfloat s[MAX_TEXTURE_UNITS][PB_SIZE]; /* Texture S coordinates */ - GLfloat t[MAX_TEXTURE_UNITS][PB_SIZE]; /* Texture T coordinates */ - GLfloat u[MAX_TEXTURE_UNITS][PB_SIZE]; /* Texture R coordinates */ - GLfloat lambda[MAX_TEXTURE_UNITS][PB_SIZE];/* Texture lambda values */ - GLint color[4]; /* Mono color, integers! */ - GLuint index; /* Mono index */ - GLuint count; /* Number of pixels in buffer */ - GLboolean mono; /* Same color or index for all pixels? */ - GLenum primitive; /* GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP*/ + GLenum primitive; /* GL_POINT, GL_LINE, GL_POLYGON or GL_BITMAP */ + GLubyte currentColor[4]; /* Current color, for subsequent pixels */ + GLuint currentIndex; /* Current index, for subsequent pixels */ + GLuint count; /* Number of pixels in buffer */ + GLboolean mono; /* Same color or index for all pixels? */ + + GLint x[PB_SIZE]; /* X window coord in [0,MAX_WIDTH) */ + GLint y[PB_SIZE]; /* Y window coord in [0,MAX_HEIGHT) */ + GLdepth z[PB_SIZE]; /* Z window coord in [0,Visual.MaxDepth] */ + GLubyte rgba[PB_SIZE][4]; /* Colors */ + GLubyte spec[PB_SIZE][3]; /* Separate specular colors */ + GLuint index[PB_SIZE]; /* Color indexes */ + GLfloat s[MAX_TEXTURE_UNITS][PB_SIZE]; /* Texture S coordinates */ + GLfloat t[MAX_TEXTURE_UNITS][PB_SIZE]; /* Texture T coordinates */ + GLfloat u[MAX_TEXTURE_UNITS][PB_SIZE]; /* Texture R coordinates */ + GLfloat lambda[MAX_TEXTURE_UNITS][PB_SIZE]; /* Texture lambda values */ }; - - /* * Set the color used for all subsequent pixels in the buffer. */ -#define PB_SET_COLOR( CTX, PB, R, G, B, A ) \ - if ((PB)->color[RCOMP]!=(R) || (PB)->color[GCOMP]!=(G) \ - || (PB)->color[BCOMP]!=(B) || (PB)->color[ACOMP]!=(A) \ - || !(PB)->mono) { \ - gl_flush_pb( ctx ); \ - } \ - (PB)->color[RCOMP] = R; \ - (PB)->color[GCOMP] = G; \ - (PB)->color[BCOMP] = B; \ - (PB)->color[ACOMP] = A; \ - (PB)->mono = GL_TRUE; +#define PB_SET_COLOR( PB, R, G, B, A ) \ +do { \ + if ((PB)->count > 0) \ + (PB)->mono = GL_FALSE; \ + (PB)->currentColor[RCOMP] = (R); \ + (PB)->currentColor[GCOMP] = (G); \ + (PB)->currentColor[BCOMP] = (B); \ + (PB)->currentColor[ACOMP] = (A); \ +} while (0) /* * Set the color index used for all subsequent pixels in the buffer. */ -#define PB_SET_INDEX( CTX, PB, I ) \ - if ((PB)->index!=(I) || !(PB)->mono) { \ - gl_flush_pb( CTX ); \ - } \ - (PB)->index = I; \ - (PB)->mono = GL_TRUE; +#define PB_SET_INDEX( PB, I ) \ +do { \ + if ((PB)->count > 0) \ + (PB)->mono = GL_FALSE; \ + (PB)->currentIndex = (I); \ +} while (0) /* * "write" a pixel using current color or index */ -#define PB_WRITE_PIXEL( PB, X, Y, Z ) \ - (PB)->x[(PB)->count] = X; \ - (PB)->y[(PB)->count] = Y; \ - (PB)->z[(PB)->count] = Z; \ - (PB)->count++; +#define PB_WRITE_PIXEL( PB, X, Y, Z ) \ +do { \ + GLuint count = (PB)->count; \ + (PB)->x[count] = X; \ + (PB)->y[count] = Y; \ + (PB)->z[count] = Z; \ + COPY_4UBV((PB)->rgba[count], (PB)->currentColor); \ + (PB)->index[count] = (PB)->currentIndex; \ + (PB)->count++; \ +} while (0) + + +/* + (PB)->rgba[count][0] = (PB)->currentColor[0]; \ + (PB)->rgba[count][1] = (PB)->currentColor[1]; \ + (PB)->rgba[count][2] = (PB)->currentColor[2]; \ + (PB)->rgba[count][3] = (PB)->currentColor[3]; \ + +*/ /* * "write" an RGBA pixel */ #define PB_WRITE_RGBA_PIXEL( PB, X, Y, Z, R, G, B, A ) \ - (PB)->x[(PB)->count] = X; \ - (PB)->y[(PB)->count] = Y; \ - (PB)->z[(PB)->count] = Z; \ - (PB)->rgba[(PB)->count][RCOMP] = R; \ - (PB)->rgba[(PB)->count][GCOMP] = G; \ - (PB)->rgba[(PB)->count][BCOMP] = B; \ - (PB)->rgba[(PB)->count][ACOMP] = A; \ - (PB)->count++; +do { \ + GLuint count = (PB)->count; \ + (PB)->x[count] = X; \ + (PB)->y[count] = Y; \ + (PB)->z[count] = Z; \ + (PB)->rgba[count][RCOMP] = R; \ + (PB)->rgba[count][GCOMP] = G; \ + (PB)->rgba[count][BCOMP] = B; \ + (PB)->rgba[count][ACOMP] = A; \ + (PB)->mono = GL_FALSE; \ + (PB)->count++; \ +} while (0) + /* * "write" a color-index pixel */ #define PB_WRITE_CI_PIXEL( PB, X, Y, Z, I ) \ - (PB)->x[(PB)->count] = X; \ - (PB)->y[(PB)->count] = Y; \ - (PB)->z[(PB)->count] = Z; \ - (PB)->i[(PB)->count] = I; \ - (PB)->count++; +do { \ + GLuint count = (PB)->count; \ + (PB)->x[count] = X; \ + (PB)->y[count] = Y; \ + (PB)->z[count] = Z; \ + (PB)->index[count] = I; \ + (PB)->mono = GL_FALSE; \ + (PB)->count++; \ +} while (0) + /* * "write" an RGBA pixel with texture coordinates */ #define PB_WRITE_TEX_PIXEL( PB, X, Y, Z, R, G, B, A, S, T, U ) \ - (PB)->x[(PB)->count] = X; \ - (PB)->y[(PB)->count] = Y; \ - (PB)->z[(PB)->count] = Z; \ - (PB)->rgba[(PB)->count][RCOMP] = R; \ - (PB)->rgba[(PB)->count][GCOMP] = G; \ - (PB)->rgba[(PB)->count][BCOMP] = B; \ - (PB)->rgba[(PB)->count][ACOMP] = A; \ - (PB)->s[0][(PB)->count] = S; \ - (PB)->t[0][(PB)->count] = T; \ - (PB)->u[0][(PB)->count] = U; \ - (PB)->count++; +do { \ + GLuint count = (PB)->count; \ + (PB)->x[count] = X; \ + (PB)->y[count] = Y; \ + (PB)->z[count] = Z; \ + (PB)->rgba[count][RCOMP] = R; \ + (PB)->rgba[count][GCOMP] = G; \ + (PB)->rgba[count][BCOMP] = B; \ + (PB)->rgba[count][ACOMP] = A; \ + (PB)->s[0][count] = S; \ + (PB)->t[0][count] = T; \ + (PB)->u[0][count] = U; \ + (PB)->mono = GL_FALSE; \ + (PB)->count++; \ +} while (0) + /* * "write" an RGBA pixel with multiple texture coordinates */ -#define PB_WRITE_MULTITEX_PIXEL( PB, X, Y, Z, R, G, B, A, S, T, U, S1, T1, U1 ) \ - (PB)->x[(PB)->count] = X; \ - (PB)->y[(PB)->count] = Y; \ - (PB)->z[(PB)->count] = Z; \ - (PB)->rgba[(PB)->count][RCOMP] = R; \ - (PB)->rgba[(PB)->count][GCOMP] = G; \ - (PB)->rgba[(PB)->count][BCOMP] = B; \ - (PB)->rgba[(PB)->count][ACOMP] = A; \ - (PB)->s[0][(PB)->count] = S; \ - (PB)->t[0][(PB)->count] = T; \ - (PB)->u[0][(PB)->count] = U; \ - (PB)->s[1][(PB)->count] = S1; \ - (PB)->t[1][(PB)->count] = T1; \ - (PB)->u[1][(PB)->count] = U1; \ - (PB)->count++; +#define PB_WRITE_MULTITEX_PIXEL( PB, X, Y, Z, R, G, B, A, S0, T0, U0, S1, T1, U1 ) \ +do { \ + GLuint count = (PB)->count; \ + (PB)->x[count] = X; \ + (PB)->y[count] = Y; \ + (PB)->z[count] = Z; \ + (PB)->rgba[count][RCOMP] = R; \ + (PB)->rgba[count][GCOMP] = G; \ + (PB)->rgba[count][BCOMP] = B; \ + (PB)->rgba[count][ACOMP] = A; \ + (PB)->s[0][count] = S0; \ + (PB)->t[0][count] = T0; \ + (PB)->u[0][count] = U0; \ + (PB)->s[1][count] = S1; \ + (PB)->t[1][count] = T1; \ + (PB)->u[1][count] = U1; \ + (PB)->mono = GL_FALSE; \ + (PB)->count++; \ +} while (0) + /* * "write" an RGBA pixel with multiple texture coordinates and specular color */ #define PB_WRITE_MULTITEX_SPEC_PIXEL( PB, X, Y, Z, R, G, B, A, \ - SR, SG, SB, S, T, U, S1, T1, U1 ) \ - (PB)->x[(PB)->count] = X; \ - (PB)->y[(PB)->count] = Y; \ - (PB)->z[(PB)->count] = Z; \ - (PB)->rgba[(PB)->count][RCOMP] = R; \ - (PB)->rgba[(PB)->count][GCOMP] = G; \ - (PB)->rgba[(PB)->count][BCOMP] = B; \ - (PB)->rgba[(PB)->count][ACOMP] = A; \ - (PB)->spec[(PB)->count][RCOMP] = SR; \ - (PB)->spec[(PB)->count][GCOMP] = SG; \ - (PB)->spec[(PB)->count][BCOMP] = SB; \ - (PB)->s[0][(PB)->count] = S; \ - (PB)->t[0][(PB)->count] = T; \ - (PB)->u[0][(PB)->count] = U; \ - (PB)->s[1][(PB)->count] = S1; \ - (PB)->t[1][(PB)->count] = T1; \ - (PB)->u[1][(PB)->count] = U1; \ - (PB)->count++; + SR, SG, SB, S0, T0, U0, S1, T1, U1 ) \ +do { \ + GLuint count = (PB)->count; \ + (PB)->x[count] = X; \ + (PB)->y[count] = Y; \ + (PB)->z[count] = Z; \ + (PB)->rgba[count][RCOMP] = R; \ + (PB)->rgba[count][GCOMP] = G; \ + (PB)->rgba[count][BCOMP] = B; \ + (PB)->rgba[count][ACOMP] = A; \ + (PB)->spec[count][RCOMP] = SR; \ + (PB)->spec[count][GCOMP] = SG; \ + (PB)->spec[count][BCOMP] = SB; \ + (PB)->s[0][count] = S0; \ + (PB)->t[0][count] = T0; \ + (PB)->u[0][count] = U0; \ + (PB)->s[1][count] = S1; \ + (PB)->t[1][count] = T1; \ + (PB)->u[1][count] = U1; \ + (PB)->mono = GL_FALSE; \ + (PB)->count++; \ +} while (0) /* * Call this function at least every MAX_WIDTH pixels: */ -#define PB_CHECK_FLUSH( CTX, PB ) \ -do { \ - if ((PB)->count>=PB_SIZE-MAX_WIDTH) { \ - gl_flush_pb( CTX ); \ - } \ +#define PB_CHECK_FLUSH( CTX, PB ) \ +do { \ + if ((PB)->count >= PB_SIZE - MAX_WIDTH) { \ + gl_flush_pb( CTX ); \ + } \ } while(0) + extern struct pixel_buffer *gl_alloc_pb(void); extern void gl_flush_pb( GLcontext *ctx ); + #endif diff --git a/xc/extras/Mesa/src/pixel.c b/xc/extras/Mesa/src/pixel.c index fd42ba3a9..17c6eb6bb 100644 --- a/xc/extras/Mesa/src/pixel.c +++ b/xc/extras/Mesa/src/pixel.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -24,11 +24,6 @@ */ -/* - * glPixelStore, glPixelTransfer, glPixelMap, glPixelZoom, etc. - */ - - #ifdef PC_HEADER #include "all.h" #else @@ -561,6 +556,54 @@ _mesa_PixelTransferf( GLenum pname, GLfloat param ) case GL_DEPTH_BIAS: ctx->Pixel.DepthBias = param; break; + case GL_POST_COLOR_MATRIX_RED_SCALE: + ctx->Pixel.PostColorMatrixScale[0] = param; + break; + case GL_POST_COLOR_MATRIX_RED_BIAS: + ctx->Pixel.PostColorMatrixBias[0] = param; + break; + case GL_POST_COLOR_MATRIX_GREEN_SCALE: + ctx->Pixel.PostColorMatrixScale[1] = param; + break; + case GL_POST_COLOR_MATRIX_GREEN_BIAS: + ctx->Pixel.PostColorMatrixBias[1] = param; + break; + case GL_POST_COLOR_MATRIX_BLUE_SCALE: + ctx->Pixel.PostColorMatrixScale[2] = param; + break; + case GL_POST_COLOR_MATRIX_BLUE_BIAS: + ctx->Pixel.PostColorMatrixBias[2] = param; + break; + case GL_POST_COLOR_MATRIX_ALPHA_SCALE: + ctx->Pixel.PostColorMatrixScale[3] = param; + break; + case GL_POST_COLOR_MATRIX_ALPHA_BIAS: + ctx->Pixel.PostColorMatrixBias[3] = param; + break; + case GL_POST_CONVOLUTION_RED_SCALE: + ctx->Pixel.PostConvolutionScale[0] = param; + break; + case GL_POST_CONVOLUTION_RED_BIAS: + ctx->Pixel.PostConvolutionBias[0] = param; + break; + case GL_POST_CONVOLUTION_GREEN_SCALE: + ctx->Pixel.PostConvolutionScale[1] = param; + break; + case GL_POST_CONVOLUTION_GREEN_BIAS: + ctx->Pixel.PostConvolutionBias[1] = param; + break; + case GL_POST_CONVOLUTION_BLUE_SCALE: + ctx->Pixel.PostConvolutionScale[2] = param; + break; + case GL_POST_CONVOLUTION_BLUE_BIAS: + ctx->Pixel.PostConvolutionBias[2] = param; + break; + case GL_POST_CONVOLUTION_ALPHA_SCALE: + ctx->Pixel.PostConvolutionScale[2] = param; + break; + case GL_POST_CONVOLUTION_ALPHA_BIAS: + ctx->Pixel.PostConvolutionBias[2] = param; + break; default: gl_error( ctx, GL_INVALID_ENUM, "glPixelTransfer(pname)" ); return; @@ -575,6 +618,20 @@ _mesa_PixelTransferf( GLenum pname, GLfloat param ) else { ctx->Pixel.ScaleOrBiasRGBA = GL_FALSE; } + + if (ctx->Pixel.PostColorMatrixScale[0] != 1.0F || + ctx->Pixel.PostColorMatrixBias[0] != 0.0F || + ctx->Pixel.PostColorMatrixScale[1] != 1.0F || + ctx->Pixel.PostColorMatrixBias[1] != 0.0F || + ctx->Pixel.PostColorMatrixScale[2] != 1.0F || + ctx->Pixel.PostColorMatrixBias[2] != 0.0F || + ctx->Pixel.PostColorMatrixScale[3] != 1.0F || + ctx->Pixel.PostColorMatrixBias[3] != 0.0F) { + ctx->Pixel.ScaleOrBiasRGBApcm = GL_TRUE; + } + else { + ctx->Pixel.ScaleOrBiasRGBApcm = GL_FALSE; + } } @@ -586,60 +643,16 @@ _mesa_PixelTransferi( GLenum pname, GLint param ) - -/* - * Pixel processing functions - */ - - -/* - * Apply scale and bias factors to an array of RGBA pixels. - */ -void gl_scale_and_bias_color( const GLcontext *ctx, GLuint n, - GLfloat red[], GLfloat green[], - GLfloat blue[], GLfloat alpha[] ) -{ - GLuint i; - for (i=0;i<n;i++) { - GLfloat r = red[i] * ctx->Pixel.RedScale + ctx->Pixel.RedBias; - GLfloat g = green[i] * ctx->Pixel.GreenScale + ctx->Pixel.GreenBias; - GLfloat b = blue[i] * ctx->Pixel.BlueScale + ctx->Pixel.BlueBias; - GLfloat a = alpha[i] * ctx->Pixel.AlphaScale + ctx->Pixel.AlphaBias; - red[i] = CLAMP( r, 0.0F, 1.0F ); - green[i] = CLAMP( g, 0.0F, 1.0F ); - blue[i] = CLAMP( b, 0.0F, 1.0F ); - alpha[i] = CLAMP( a, 0.0F, 1.0F ); - } -} - - -/* - * Apply scale and bias factors to an array of RGBA pixels. - */ -void gl_scale_and_bias_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] ) -{ - GLfloat rbias = ctx->Pixel.RedBias * 255.0F; - GLfloat gbias = ctx->Pixel.GreenBias * 255.0F; - GLfloat bbias = ctx->Pixel.BlueBias * 255.0F; - GLfloat abias = ctx->Pixel.AlphaBias * 255.0F; - GLuint i; - for (i=0;i<n;i++) { - GLint r = (GLint) (rgba[i][RCOMP] * ctx->Pixel.RedScale + rbias); - GLint g = (GLint) (rgba[i][GCOMP] * ctx->Pixel.GreenScale + gbias); - GLint b = (GLint) (rgba[i][BCOMP] * ctx->Pixel.BlueScale + bbias); - GLint a = (GLint) (rgba[i][ACOMP] * ctx->Pixel.AlphaScale + abias); - rgba[i][RCOMP] = CLAMP( r, 0, 255 ); - rgba[i][GCOMP] = CLAMP( g, 0, 255 ); - rgba[i][BCOMP] = CLAMP( b, 0, 255 ); - rgba[i][ACOMP] = CLAMP( a, 0, 255 ); - } -} +/**********************************************************************/ +/***** Pixel processing functions ******/ +/**********************************************************************/ /* * Apply scale and bias factors to an array of RGBA pixels. */ -void gl_scale_and_bias_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) +void +_mesa_scale_and_bias_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]) { if (ctx->Pixel.RedScale != 1.0 || ctx->Pixel.RedBias != 0.0) { const GLfloat scale = ctx->Pixel.RedScale; @@ -677,32 +690,10 @@ void gl_scale_and_bias_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[ /* - * Apply pixel mapping to an array of RGBA pixels. - */ -void gl_map_rgba( const GLcontext *ctx, GLuint n, GLubyte rgba[][4] ) -{ - GLfloat rscale = (ctx->Pixel.MapRtoRsize - 1) / 255.0F; - GLfloat gscale = (ctx->Pixel.MapGtoGsize - 1) / 255.0F; - GLfloat bscale = (ctx->Pixel.MapBtoBsize - 1) / 255.0F; - GLfloat ascale = (ctx->Pixel.MapAtoAsize - 1) / 255.0F; - GLuint i; - for (i=0;i<n;i++) { - GLint ir = (GLint) (rgba[i][RCOMP] * rscale); - GLint ig = (GLint) (rgba[i][GCOMP] * gscale); - GLint ib = (GLint) (rgba[i][BCOMP] * bscale); - GLint ia = (GLint) (rgba[i][ACOMP] * ascale); - rgba[i][RCOMP] = (GLint) (ctx->Pixel.MapRtoR[ir] * 255.0F); - rgba[i][GCOMP] = (GLint) (ctx->Pixel.MapGtoG[ig] * 255.0F); - rgba[i][BCOMP] = (GLint) (ctx->Pixel.MapBtoB[ib] * 255.0F); - rgba[i][ACOMP] = (GLint) (ctx->Pixel.MapAtoA[ia] * 255.0F); - } -} - - -/* * Apply pixel mapping to an array of floating point RGBA pixels. */ -void gl_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) +void +_mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) { const GLfloat rscale = ctx->Pixel.MapRtoRsize - 1; const GLfloat gscale = ctx->Pixel.MapGtoGsize - 1; @@ -723,22 +714,210 @@ void gl_map_rgba_float( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] ) /* - * Apply pixel mapping to an array of RGBA pixels. + * Apply the color matrix and post color matrix scaling and biasing. */ -void gl_map_color( const GLcontext *ctx, GLuint n, - GLfloat red[], GLfloat green[], - GLfloat blue[], GLfloat alpha[] ) +void +_mesa_transform_rgba(const GLcontext *ctx, GLuint n, GLfloat rgba[][4]) { - GLfloat rscale = ctx->Pixel.MapRtoRsize - 1; - GLfloat gscale = ctx->Pixel.MapGtoGsize - 1; - GLfloat bscale = ctx->Pixel.MapBtoBsize - 1; - GLfloat ascale = ctx->Pixel.MapAtoAsize - 1; + const GLfloat rs = ctx->Pixel.PostColorMatrixScale[0]; + const GLfloat rb = ctx->Pixel.PostColorMatrixBias[0]; + const GLfloat gs = ctx->Pixel.PostColorMatrixScale[1]; + const GLfloat gb = ctx->Pixel.PostColorMatrixBias[1]; + const GLfloat bs = ctx->Pixel.PostColorMatrixScale[2]; + const GLfloat bb = ctx->Pixel.PostColorMatrixBias[2]; + const GLfloat as = ctx->Pixel.PostColorMatrixScale[3]; + const GLfloat ab = ctx->Pixel.PostColorMatrixBias[3]; + const GLfloat *m = ctx->ColorMatrix.m; GLuint i; - for (i=0;i<n;i++) { - red[i] = ctx->Pixel.MapRtoR[ (GLint) (red[i] * rscale + 0.5F) ]; - green[i] = ctx->Pixel.MapGtoG[ (GLint) (green[i] * gscale + 0.5F) ]; - blue[i] = ctx->Pixel.MapBtoB[ (GLint) (blue[i] * bscale + 0.5F) ]; - alpha[i] = ctx->Pixel.MapAtoA[ (GLint) (alpha[i] * ascale + 0.5F) ]; + for (i = 0; i < n; i++) { + const GLfloat r = rgba[i][RCOMP]; + const GLfloat g = rgba[i][GCOMP]; + const GLfloat b = rgba[i][BCOMP]; + const GLfloat a = rgba[i][ACOMP]; + rgba[i][RCOMP] = (m[0] * r + m[4] * g + m[ 8] * b + m[12] * a) * rs + rb; + rgba[i][GCOMP] = (m[1] * r + m[5] * g + m[ 9] * b + m[13] * a) * gs + gb; + rgba[i][BCOMP] = (m[2] * r + m[6] * g + m[10] * b + m[14] * a) * bs + bb; + rgba[i][ACOMP] = (m[3] * r + m[7] * g + m[11] * b + m[15] * a) * as + ab; + } +} + + +/* + * Apply a color table lookup to an array of colors. + */ +void +_mesa_lookup_rgba(const struct gl_color_table *table, + GLuint n, GLfloat rgba[][4]) +{ + ASSERT(table->TableType == GL_FLOAT); + if (!table->Table) + return; + + switch (table->Format) { + case GL_INTENSITY: + /* replace RGBA with I */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLfloat c = lut[j] * (1.0F / 255.0F); + rgba[i][RCOMP] = rgba[i][GCOMP] = + rgba[i][BCOMP] = rgba[i][ACOMP] = c; + } + + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLfloat c = lut[j]; + rgba[i][RCOMP] = rgba[i][GCOMP] = + rgba[i][BCOMP] = rgba[i][ACOMP] = c; + } + } + break; + case GL_LUMINANCE: + /* replace RGB with L */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLfloat c = lut[j] * (1.0F / 255.0F); + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLfloat c = lut[j]; + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c; + } + } + break; + case GL_ALPHA: + /* replace A with A */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + rgba[i][ACOMP] = lut[j] * (1.0F / 255.0F); + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + rgba[i][ACOMP] = lut[j]; + } + } + break; + case GL_LUMINANCE_ALPHA: + /* replace RGBA with LLLA */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + GLfloat luminance = lut[jL * 2 + 0] * (1.0F / 255.0F); + GLfloat alpha = lut[jA * 2 + 1] * (1.0F / 255.0F); + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; + rgba[i][ACOMP] = alpha;; + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + GLfloat luminance = lut[jL * 2 + 0]; + GLfloat alpha = lut[jA * 2 + 1]; + rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance; + rgba[i][ACOMP] = alpha;; + } + } + break; + case GL_RGB: + /* replace RGB with RGB */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); + GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); + rgba[i][RCOMP] = lut[jR * 3 + 0] * (1.0F / 255.0F); + rgba[i][GCOMP] = lut[jG * 3 + 1] * (1.0F / 255.0F); + rgba[i][BCOMP] = lut[jB * 3 + 2] * (1.0F / 255.0F); + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); + GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); + rgba[i][RCOMP] = lut[jR * 3 + 0]; + rgba[i][GCOMP] = lut[jG * 3 + 1]; + rgba[i][BCOMP] = lut[jB * 3 + 2]; + } + } + break; + case GL_RGBA: + /* replace RGBA with RGBA */ + if (table->TableType == GL_UNSIGNED_BYTE) { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLubyte *lut = (const GLubyte *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); + GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); + GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + rgba[i][RCOMP] = lut[jR * 4 + 0] * (1.0F / 255.0F); + rgba[i][GCOMP] = lut[jG * 4 + 1] * (1.0F / 255.0F); + rgba[i][BCOMP] = lut[jB * 4 + 2] * (1.0F / 255.0F); + rgba[i][ACOMP] = lut[jA * 4 + 3] * (1.0F / 255.0F); + } + } + else { + const GLfloat scale = (GLfloat) (table->Size - 1); + const GLfloat *lut = (const GLfloat *) table->Table; + GLuint i; + for (i = 0; i < n; i++) { + GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F); + GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F); + GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F); + GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F); + rgba[i][RCOMP] = lut[jR * 4 + 0]; + rgba[i][GCOMP] = lut[jG * 4 + 1]; + rgba[i][BCOMP] = lut[jB * 4 + 2]; + rgba[i][ACOMP] = lut[jA * 4 + 3]; + } + } + break; + default: + gl_problem(NULL, "Bad format in _mesa_lookup_rgba"); + return; } } @@ -747,7 +926,8 @@ void gl_map_color( const GLcontext *ctx, GLuint n, /* * Apply color index shift and offset to an array of pixels. */ -void gl_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] ) +void +_mesa_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] ) { GLint shift = ctx->Pixel.IndexShift; GLint offset = ctx->Pixel.IndexOffset; @@ -774,7 +954,8 @@ void gl_shift_and_offset_ci( const GLcontext *ctx, GLuint n, GLuint indexes[] ) /* * Apply color index mapping to color indexes. */ -void gl_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ) +void +_mesa_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ) { GLuint mask = ctx->Pixel.MapItoIsize - 1; GLuint i; @@ -787,8 +968,9 @@ void gl_map_ci( const GLcontext *ctx, GLuint n, GLuint index[] ) /* * Map color indexes to rgba values. */ -void gl_map_ci_to_rgba( const GLcontext *ctx, GLuint n, const GLuint index[], - GLubyte rgba[][4] ) +void +_mesa_map_ci_to_rgba_ubyte( const GLcontext *ctx, GLuint n, + const GLuint index[], GLubyte rgba[][4] ) { GLuint rmask = ctx->Pixel.MapItoRsize - 1; GLuint gmask = ctx->Pixel.MapItoGsize - 1; @@ -811,8 +993,9 @@ void gl_map_ci_to_rgba( const GLcontext *ctx, GLuint n, const GLuint index[], /* * Map color indexes to float rgba values. */ -void gl_map_ci_to_rgba_float( const GLcontext *ctx, GLuint n, const GLuint index[], - GLfloat rgba[][4] ) +void +_mesa_map_ci_to_rgba( const GLcontext *ctx, GLuint n, + const GLuint index[], GLfloat rgba[][4] ) { GLuint rmask = ctx->Pixel.MapItoRsize - 1; GLuint gmask = ctx->Pixel.MapItoGsize - 1; @@ -835,8 +1018,9 @@ void gl_map_ci_to_rgba_float( const GLcontext *ctx, GLuint n, const GLuint index /* * Map 8-bit color indexes to rgb values. */ -void gl_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[], - GLubyte rgba[][4] ) +void +_mesa_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[], + GLubyte rgba[][4] ) { GLuint rmask = ctx->Pixel.MapItoRsize - 1; GLuint gmask = ctx->Pixel.MapItoGsize - 1; @@ -856,27 +1040,9 @@ void gl_map_ci8_to_rgba( const GLcontext *ctx, GLuint n, const GLubyte index[], } -void gl_map_ci_to_color( const GLcontext *ctx, GLuint n, const GLuint index[], - GLfloat r[], GLfloat g[], - GLfloat b[], GLfloat a[] ) -{ - GLuint rmask = ctx->Pixel.MapItoRsize - 1; - GLuint gmask = ctx->Pixel.MapItoGsize - 1; - GLuint bmask = ctx->Pixel.MapItoBsize - 1; - GLuint amask = ctx->Pixel.MapItoAsize - 1; - GLuint i; - for (i=0;i<n;i++) { - r[i] = ctx->Pixel.MapItoR[index[i] & rmask]; - g[i] = ctx->Pixel.MapItoG[index[i] & gmask]; - b[i] = ctx->Pixel.MapItoB[index[i] & bmask]; - a[i] = ctx->Pixel.MapItoA[index[i] & amask]; - } -} - - - -void gl_shift_and_offset_stencil( const GLcontext *ctx, GLuint n, - GLstencil stencil[] ) +void +_mesa_shift_and_offset_stencil( const GLcontext *ctx, GLuint n, + GLstencil stencil[] ) { GLuint i; GLint shift = ctx->Pixel.IndexShift; @@ -901,8 +1067,8 @@ void gl_shift_and_offset_stencil( const GLcontext *ctx, GLuint n, } - -void gl_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] ) +void +_mesa_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] ) { GLuint mask = ctx->Pixel.MapStoSsize - 1; GLuint i; @@ -910,4 +1076,3 @@ void gl_map_stencil( const GLcontext *ctx, GLuint n, GLstencil stencil[] ) stencil[i] = ctx->Pixel.MapStoS[ stencil[i] & mask ]; } } - diff --git a/xc/extras/Mesa/src/points.c b/xc/extras/Mesa/src/points.c index 48866230f..77d1e0de0 100644 --- a/xc/extras/Mesa/src/points.c +++ b/xc/extras/Mesa/src/points.c @@ -3,7 +3,7 @@ * Mesa 3-D graphics library * Version: 3.3 * - * Copyright (C) 1999 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2000 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"), @@ -53,10 +53,12 @@ _mesa_PointSize( GLfloat size ) return; } - if (ctx->Point.Size != size) { - ctx->Point.Size = size; + if (ctx->Point.UserSize != size) { + ctx->Point.UserSize = size; + ctx->Point.Size = CLAMP(size, ctx->Const.MinPointSize, ctx->Const.MaxPointSize); ctx->TriangleCaps &= ~DD_POINT_SIZE; - if (size != 1.0) ctx->TriangleCaps |= DD_POINT_SIZE; + if (size != 1.0) + ctx->TriangleCaps |= DD_POINT_SIZE; ctx->NewState |= NEW_RASTER_OPS; } } @@ -145,20 +147,21 @@ _mesa_PointParameterfvEXT( GLenum pname, const GLfloat *params) /* * CI points with size == 1.0 */ -static void size1_ci_points( GLcontext *ctx, GLuint first, GLuint last ) +static void +size1_ci_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; GLfloat *win; GLint *pbx = PB->x, *pby = PB->y; GLdepth *pbz = PB->z; - GLuint *pbi = PB->i; + GLuint *pbi = PB->index; GLuint pbcount = PB->count; GLuint i; win = &VB->Win.data[first][0]; - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { + for (i = first; i <= last; i++) { + if (VB->ClipMask[i] == 0) { pbx[pbcount] = (GLint) win[0]; pby[pbcount] = (GLint) win[1]; pbz[pbcount] = (GLint) (win[2] + ctx->PointZoffset); @@ -176,14 +179,15 @@ static void size1_ci_points( GLcontext *ctx, GLuint first, GLuint last ) /* * RGBA points with size == 1.0 */ -static void size1_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +static void +size1_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; GLuint i; - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { + for (i = first; i <= last; i++) { + if (VB->ClipMask[i] == 0) { GLint x, y, z; GLint red, green, blue, alpha; @@ -199,7 +203,7 @@ static void size1_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) PB_WRITE_RGBA_PIXEL( PB, x, y, z, red, green, blue, alpha ); } } - PB_CHECK_FLUSH(ctx,PB); + PB_CHECK_FLUSH(ctx, PB); } @@ -207,23 +211,23 @@ static void size1_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) /* * General CI points. */ -static void general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) +static void +general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; - GLuint i; - GLint isize = (GLint) (CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE) + 0.5F); + const GLint isize = (GLint) (ctx->Point.Size + 0.5F); GLint radius = isize >> 1; + GLuint i; - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - GLint x, y, z; + for (i = first; i <= last; i++) { + if (VB->ClipMask[i] == 0) { GLint x0, x1, y0, y1; GLint ix, iy; - x = (GLint) VB->Win.data[i][0]; - y = (GLint) VB->Win.data[i][1]; - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint x = (GLint) VB->Win.data[i][0]; + GLint y = (GLint) VB->Win.data[i][1]; + GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); if (isize & 1) { /* odd size */ @@ -240,10 +244,10 @@ static void general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) y1 = y0 + isize - 1; } - PB_SET_INDEX( ctx, PB, VB->IndexPtr->data[i] ); + PB_SET_INDEX( PB, VB->IndexPtr->data[i] ); - for (iy=y0;iy<=y1;iy++) { - for (ix=x0;ix<=x1;ix++) { + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { PB_WRITE_PIXEL( PB, ix, iy, z ); } } @@ -256,23 +260,23 @@ static void general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) /* * General RGBA points. */ -static void general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +static void +general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; - GLuint i; - GLint isize = (GLint) (CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE) + 0.5F); + GLint isize = (GLint) (ctx->Point.Size + 0.5F); GLint radius = isize >> 1; + GLuint i; - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - GLint x, y, z; + for (i = first; i <= last; i++) { + if (VB->ClipMask[i] == 0) { GLint x0, x1, y0, y1; GLint ix, iy; - x = (GLint) VB->Win.data[i][0]; - y = (GLint) VB->Win.data[i][1]; - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint x = (GLint) VB->Win.data[i][0]; + GLint y = (GLint) VB->Win.data[i][1]; + GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); if (isize & 1) { /* odd size */ @@ -289,14 +293,14 @@ static void general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) y1 = y0 + isize - 1; } - PB_SET_COLOR( ctx, PB, + PB_SET_COLOR( PB, VB->ColorPtr->data[i][0], VB->ColorPtr->data[i][1], VB->ColorPtr->data[i][2], VB->ColorPtr->data[i][3] ); - for (iy=y0;iy<=y1;iy++) { - for (ix=x0;ix<=x1;ix++) { + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { PB_WRITE_PIXEL( PB, ix, iy, z ); } } @@ -311,28 +315,26 @@ static void general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) /* * Textured RGBA points. */ -static void textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +static void +textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; GLuint i; - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - GLint x, y, z; + for (i = first; i <= last; i++) { + if (VB->ClipMask[i] == 0) { GLint x0, x1, y0, y1; - GLint ix, iy; - GLint isize, radius; + GLint ix, iy, radius; GLint red, green, blue, alpha; GLfloat s, t, u; - x = (GLint) VB->Win.data[i][0]; - y = (GLint) VB->Win.data[i][1]; - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint x = (GLint) VB->Win.data[i][0]; + GLint y = (GLint) VB->Win.data[i][1]; + GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint isize = (GLint) (ctx->Point.Size + 0.5F); - isize = (GLint) - (CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE) + 0.5F); - if (isize<1) { + if (isize < 1) { isize = 1; } radius = isize >> 1; @@ -388,12 +390,12 @@ static void textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) PB_SET_COLOR( red, green, blue, alpha ); */ - for (iy=y0;iy<=y1;iy++) { - for (ix=x0;ix<=x1;ix++) { + for (iy = y0; iy <= y1; iy++) { + for (ix = x0; ix <= x1; ix++) { PB_WRITE_TEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha, s, t, u ); } } - PB_CHECK_FLUSH(ctx,PB); + PB_CHECK_FLUSH(ctx, PB); } } } @@ -402,29 +404,28 @@ static void textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) /* * Multitextured RGBA points. */ -static void multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) +static void +multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; GLuint i; - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - GLint x, y, z; + for (i = first; i <= last; i++) { + if (VB->ClipMask[i] == 0) { GLint x0, x1, y0, y1; GLint ix, iy; - GLint isize, radius; + GLint radius; GLint red, green, blue, alpha; GLfloat s, t, u; GLfloat s1, t1, u1; - x = (GLint) VB->Win.data[i][0]; - y = (GLint) VB->Win.data[i][1]; - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint x = (GLint) VB->Win.data[i][0]; + GLint y = (GLint) VB->Win.data[i][1]; + GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint isize = (GLint) (ctx->Point.Size + 0.5F); - isize = (GLint) - (CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE) + 0.5F); - if (isize<1) { + if (isize < 1) { isize = 1; } radius = isize >> 1; @@ -505,10 +506,11 @@ static void multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last for (iy=y0;iy<=y1;iy++) { for (ix=x0;ix<=x1;ix++) { - PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha, s, t, u, s1, t1, u1 ); + PB_WRITE_MULTITEX_PIXEL( PB, ix, iy, z, red, green, blue, alpha, + s, t, u, s1, t1, u1 ); } } - PB_CHECK_FLUSH(ctx,PB); + PB_CHECK_FLUSH(ctx, PB); } } } @@ -519,35 +521,32 @@ static void multitextured_rgba_points( GLcontext *ctx, GLuint first, GLuint last /* * Antialiased points with or without texture mapping. */ -static void antialiased_rgba_points( GLcontext *ctx, - GLuint first, GLuint last ) +static void +antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; + const GLfloat radius = ctx->Point.Size * 0.5F; + const GLfloat rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ + const GLfloat rmax = radius + 0.7071F; + const GLfloat rmin2 = rmin * rmin; + const GLfloat rmax2 = rmax * rmax; + const GLfloat cscale = 256.0F / (rmax2 - rmin2); GLuint i; - GLfloat radius, rmin, rmax, rmin2, rmax2, cscale; - - radius = CLAMP( ctx->Point.Size, MIN_POINT_SIZE, MAX_POINT_SIZE ) * 0.5F; - rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ - rmax = radius + 0.7071F; - rmin2 = rmin*rmin; - rmax2 = rmax*rmax; - cscale = 256.0F / (rmax2-rmin2); if (ctx->Texture.ReallyEnabled) { - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { - GLint xmin, ymin, xmax, ymax; - GLint x, y, z; + for (i = first; i <= last; i++) { + if (VB->ClipMask[i] == 0) { + GLint x, y; GLint red, green, blue, alpha; GLfloat s, t, u; GLfloat s1, t1, u1; - xmin = (GLint) (VB->Win.data[i][0] - radius); - xmax = (GLint) (VB->Win.data[i][0] + radius); - ymin = (GLint) (VB->Win.data[i][1] - radius); - ymax = (GLint) (VB->Win.data[i][1] + radius); - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint xmin = (GLint) (VB->Win.data[i][0] - radius); + GLint xmax = (GLint) (VB->Win.data[i][0] + radius); + GLint ymin = (GLint) (VB->Win.data[i][1] - radius); + GLint ymax = (GLint) (VB->Win.data[i][1] + radius); + GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); red = VB->ColorPtr->data[i][0]; green = VB->ColorPtr->data[i][1]; @@ -690,7 +689,8 @@ static void antialiased_rgba_points( GLcontext *ctx, /* * Null rasterizer for measuring transformation speed. */ -static void null_points( GLcontext *ctx, GLuint first, GLuint last ) +static void +null_points( GLcontext *ctx, GLuint first, GLuint last ) { (void) ctx; (void) first; @@ -704,35 +704,36 @@ static void null_points( GLcontext *ctx, GLuint first, GLuint last ) /* Calculates the distance attenuation formula of a vector of points in * eye space coordinates */ -static void dist3(GLfloat *out, GLuint first, GLuint last, - const GLcontext *ctx, const GLvector4f *v) +static void +dist3(GLfloat *out, GLuint first, GLuint last, + const GLcontext *ctx, const GLvector4f *v) { GLuint stride = v->stride; - GLfloat *p = VEC_ELT(v, GLfloat, first); + const GLfloat *p = VEC_ELT(v, GLfloat, first); GLuint i; - for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) - { + for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) { GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]); - out[i] = 1/(ctx->Point.Params[0]+ - dist * (ctx->Point.Params[1] + - dist * ctx->Point.Params[2])); + out[i] = 1.0F / (ctx->Point.Params[0] + + dist * (ctx->Point.Params[1] + + dist * ctx->Point.Params[2])); } } -static void dist2(GLfloat *out, GLuint first, GLuint last, - const GLcontext *ctx, const GLvector4f *v) + +static void +dist2(GLfloat *out, GLuint first, GLuint last, + const GLcontext *ctx, const GLvector4f *v) { GLuint stride = v->stride; - GLfloat *p = VEC_ELT(v, GLfloat, first); + const GLfloat *p = VEC_ELT(v, GLfloat, first); GLuint i; - for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) - { + for (i = first ; i <= last ; i++, STRIDE_F(p, stride) ) { GLfloat dist = GL_SQRT(p[0]*p[0]+p[1]*p[1]); - out[i] = 1/(ctx->Point.Params[0]+ - dist * (ctx->Point.Params[1] + - dist * ctx->Point.Params[2])); + out[i] = 1.0F / (ctx->Point.Params[0] + + dist * (ctx->Point.Params[1] + + dist * ctx->Point.Params[2])); } } @@ -750,8 +751,9 @@ static dist_func eye_dist_tab[5] = { }; -static void clip_dist(GLfloat *out, GLuint first, GLuint last, - const GLcontext *ctx, GLvector4f *clip) +static void +clip_dist(GLfloat *out, GLuint first, GLuint last, + const GLcontext *ctx, GLvector4f *clip) { /* this is never called */ gl_problem(NULL, "clip_dist() called - dead code!\n"); @@ -782,15 +784,14 @@ static void clip_dist(GLfloat *out, GLuint first, GLuint last, /* * Distance Attenuated General CI points. */ -static void dist_atten_general_ci_points( GLcontext *ctx, GLuint first, - GLuint last ) +static void +dist_atten_general_ci_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; - GLuint i; - GLfloat psize,dsize; GLfloat dist[VB_SIZE]; - psize=CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE); + const GLfloat psize = ctx->Point.Size; + GLuint i; if (ctx->NeedEyeCoords) (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr ); @@ -799,20 +800,19 @@ static void dist_atten_general_ci_points( GLcontext *ctx, GLuint first, for (i=first;i<=last;i++) { if (VB->ClipMask[i]==0) { - GLint x, y, z; GLint x0, x1, y0, y1; GLint ix, iy; GLint isize, radius; + GLint x = (GLint) VB->Win.data[i][0]; + GLint y = (GLint) VB->Win.data[i][1]; + GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLfloat dsize = psize * dist[i]; - x = (GLint) VB->Win.data[i][0]; - y = (GLint) VB->Win.data[i][1]; - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - - dsize=psize*dist[i]; - if(dsize>=ctx->Point.Threshold) { - isize=(GLint) (MIN2(dsize,ctx->Point.MaxSize)+0.5F); - } else { - isize=(GLint) (MAX2(ctx->Point.Threshold,ctx->Point.MinSize)+0.5F); + if (dsize >= ctx->Point.Threshold) { + isize = (GLint) (MIN2(dsize, ctx->Point.MaxSize) + 0.5F); + } + else { + isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F); } radius = isize >> 1; @@ -831,7 +831,7 @@ static void dist_atten_general_ci_points( GLcontext *ctx, GLuint first, y1 = y0 + isize - 1; } - PB_SET_INDEX( ctx, PB, VB->IndexPtr->data[i] ); + PB_SET_INDEX( PB, VB->IndexPtr->data[i] ); for (iy=y0;iy<=y1;iy++) { for (ix=x0;ix<=x1;ix++) { @@ -846,16 +846,14 @@ static void dist_atten_general_ci_points( GLcontext *ctx, GLuint first, /* * Distance Attenuated General RGBA points. */ -static void dist_atten_general_rgba_points( GLcontext *ctx, GLuint first, - GLuint last ) +static void +dist_atten_general_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; - GLuint i; - GLubyte alpha; - GLfloat psize,dsize; GLfloat dist[VB_SIZE]; - psize=CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE); + const GLfloat psize = ctx->Point.Size; + GLuint i; if (ctx->NeedEyeCoords) (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr ); @@ -864,15 +862,15 @@ static void dist_atten_general_rgba_points( GLcontext *ctx, GLuint first, for (i=first;i<=last;i++) { if (VB->ClipMask[i]==0) { - GLint x, y, z; GLint x0, x1, y0, y1; GLint ix, iy; GLint isize, radius; + GLint x = (GLint) VB->Win.data[i][0]; + GLint y = (GLint) VB->Win.data[i][1]; + GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLfloat dsize=psize*dist[i]; + GLubyte alpha; - x = (GLint) VB->Win.data[i][0]; - y = (GLint) VB->Win.data[i][1]; - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - dsize=psize*dist[i]; if (dsize >= ctx->Point.Threshold) { isize = (GLint) (MIN2(dsize,ctx->Point.MaxSize)+0.5F); alpha = VB->ColorPtr->data[i][3]; @@ -899,7 +897,7 @@ static void dist_atten_general_rgba_points( GLcontext *ctx, GLuint first, y1 = y0 + isize - 1; } - PB_SET_COLOR( ctx, PB, + PB_SET_COLOR( PB, VB->ColorPtr->data[i][0], VB->ColorPtr->data[i][1], VB->ColorPtr->data[i][2], @@ -918,15 +916,14 @@ static void dist_atten_general_rgba_points( GLcontext *ctx, GLuint first, /* * Distance Attenuated Textured RGBA points. */ -static void dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, - GLuint last ) +static void +dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; - GLuint i; - GLfloat psize,dsize; GLfloat dist[VB_SIZE]; - psize=CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE); + const GLfloat psize = ctx->Point.Size; + GLuint i; if (ctx->NeedEyeCoords) (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr ); @@ -935,7 +932,6 @@ static void dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, for (i=first;i<=last;i++) { if (VB->ClipMask[i]==0) { - GLint x, y, z; GLint x0, x1, y0, y1; GLint ix, iy; GLint isize, radius; @@ -943,21 +939,22 @@ static void dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, GLfloat s, t, u; GLfloat s1, t1, u1; - x = (GLint) VB->Win.data[i][0]; - y = (GLint) VB->Win.data[i][1]; - z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); + GLint x = (GLint) VB->Win.data[i][0]; + GLint y = (GLint) VB->Win.data[i][1]; + GLint z = (GLint) (VB->Win.data[i][2] + ctx->PointZoffset); - dsize=psize*dist[i]; - if(dsize>=ctx->Point.Threshold) { - isize=(GLint) (MIN2(dsize,ctx->Point.MaxSize)+0.5F); - alpha=VB->ColorPtr->data[i][3]; - } else { - isize=(GLint) (MAX2(ctx->Point.Threshold,ctx->Point.MinSize)+0.5F); - dsize/=ctx->Point.Threshold; - alpha = (GLint) (VB->ColorPtr->data[i][3]* (dsize*dsize)); + GLfloat dsize = psize*dist[i]; + if(dsize >= ctx->Point.Threshold) { + isize = (GLint) (MIN2(dsize, ctx->Point.MaxSize) + 0.5F); + alpha = VB->ColorPtr->data[i][3]; + } + else { + isize = (GLint) (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) + 0.5F); + dsize /= ctx->Point.Threshold; + alpha = (GLint) (VB->ColorPtr->data[i][3] * (dsize * dsize)); } - if (isize<1) { + if (isize < 1) { isize = 1; } radius = isize >> 1; @@ -1066,16 +1063,14 @@ static void dist_atten_textured_rgba_points( GLcontext *ctx, GLuint first, /* * Distance Attenuated Antialiased points with or without texture mapping. */ -static void dist_atten_antialiased_rgba_points( GLcontext *ctx, - GLuint first, GLuint last ) +static void +dist_atten_antialiased_rgba_points( GLcontext *ctx, GLuint first, GLuint last ) { struct vertex_buffer *VB = ctx->VB; struct pixel_buffer *PB = ctx->PB; - GLuint i; - GLfloat radius, rmin, rmax, rmin2, rmax2, cscale; - GLfloat psize,dsize,alphaf; GLfloat dist[VB_SIZE]; - psize=CLAMP(ctx->Point.Size,MIN_POINT_SIZE,MAX_POINT_SIZE); + const GLfloat psize = ctx->Point.Size; + GLuint i; if (ctx->NeedEyeCoords) (eye_dist_tab[VB->EyePtr->size])( dist, first, last, ctx, VB->EyePtr ); @@ -1085,20 +1080,22 @@ static void dist_atten_antialiased_rgba_points( GLcontext *ctx, if (ctx->Texture.ReallyEnabled) { for (i=first;i<=last;i++) { if (VB->ClipMask[i]==0) { + GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf; GLint xmin, ymin, xmax, ymax; GLint x, y, z; GLint red, green, blue, alpha; GLfloat s, t, u; GLfloat s1, t1, u1; + GLfloat dsize = psize * dist[i]; - dsize=psize*dist[i]; - if(dsize>=ctx->Point.Threshold) { - radius=(MIN2(dsize,ctx->Point.MaxSize)*0.5F); - alphaf=1.0; - } else { - radius=(MAX2(ctx->Point.Threshold,ctx->Point.MinSize)*0.5F); - dsize/=ctx->Point.Threshold; - alphaf=(dsize*dsize); + if (dsize >= ctx->Point.Threshold) { + radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F; + alphaf = 1.0F; + } + else { + radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F); + dsize /= ctx->Point.Threshold; + alphaf = (dsize*dsize); } rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ rmax = radius + 0.7071F; @@ -1180,23 +1177,25 @@ static void dist_atten_antialiased_rgba_points( GLcontext *ctx, } } - for (y=ymin;y<=ymax;y++) { - for (x=xmin;x<=xmax;x++) { + for (y = ymin; y <= ymax; y++) { + for (x = xmin; x <= xmax; x++) { GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0]; GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1]; GLfloat dist2 = dx*dx + dy*dy; - if (dist2<rmax2) { + if (dist2 < rmax2) { alpha = VB->ColorPtr->data[i][3]; - if (dist2>=rmin2) { - GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale); + if (dist2 >= rmin2) { + GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); /* coverage is in [0,256] */ alpha = (alpha * coverage) >> 8; } alpha = (GLint) (alpha * alphaf); if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) { - PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, red, green, blue, alpha, s, t, u, s1, t1, u1 ); + PB_WRITE_MULTITEX_PIXEL( PB, x,y,z, red, green, blue, + alpha, s, t, u, s1, t1, u1 ); } else { - PB_WRITE_TEX_PIXEL( PB, x,y,z, red, green, blue, alpha, s, t, u ); + PB_WRITE_TEX_PIXEL( PB, x,y,z, red, green, blue, alpha, + s, t, u ); } } } @@ -1207,26 +1206,28 @@ static void dist_atten_antialiased_rgba_points( GLcontext *ctx, } else { /* Not texture mapped */ - for (i=first;i<=last;i++) { - if (VB->ClipMask[i]==0) { + for (i = first; i <= last; i++) { + if (VB->ClipMask[i] == 0) { + GLfloat radius, rmin, rmax, rmin2, rmax2, cscale, alphaf; GLint xmin, ymin, xmax, ymax; GLint x, y, z; GLint red, green, blue, alpha; + GLfloat dsize = psize * dist[i]; - dsize=psize*dist[i]; - if(dsize>=ctx->Point.Threshold) { - radius=(MIN2(dsize,ctx->Point.MaxSize)*0.5F); - alphaf=1.0; - } else { - radius=(MAX2(ctx->Point.Threshold,ctx->Point.MinSize)*0.5F); - dsize/=ctx->Point.Threshold; - alphaf=(dsize*dsize); + if (dsize >= ctx->Point.Threshold) { + radius = MIN2(dsize, ctx->Point.MaxSize) * 0.5F; + alphaf = 1.0F; + } + else { + radius = (MAX2(ctx->Point.Threshold, ctx->Point.MinSize) * 0.5F); + dsize /= ctx->Point.Threshold; + alphaf = dsize * dsize; } rmin = radius - 0.7071F; /* 0.7071 = sqrt(2)/2 */ rmax = radius + 0.7071F; - rmin2 = rmin*rmin; - rmax2 = rmax*rmax; - cscale = 256.0F / (rmax2-rmin2); + rmin2 = rmin * rmin; + rmax2 = rmax * rmax; + cscale = 256.0F / (rmax2 - rmin2); xmin = (GLint) (VB->Win.data[i][0] - radius); xmax = (GLint) (VB->Win.data[i][0] + radius); @@ -1238,21 +1239,20 @@ static void dist_atten_antialiased_rgba_points( GLcontext *ctx, green = VB->ColorPtr->data[i][1]; blue = VB->ColorPtr->data[i][2]; - for (y=ymin;y<=ymax;y++) { - for (x=xmin;x<=xmax;x++) { + for (y = ymin; y <= ymax; y++) { + for (x = xmin; x <= xmax; x++) { GLfloat dx = x/*+0.5F*/ - VB->Win.data[i][0]; GLfloat dy = y/*+0.5F*/ - VB->Win.data[i][1]; - GLfloat dist2 = dx*dx + dy*dy; - if (dist2<rmax2) { + GLfloat dist2 = dx * dx + dy * dy; + if (dist2 < rmax2) { alpha = VB->ColorPtr->data[i][3]; - if (dist2>=rmin2) { - GLint coverage = (GLint) (256.0F-(dist2-rmin2)*cscale); + if (dist2 >= rmin2) { + GLint coverage = (GLint) (256.0F - (dist2 - rmin2) * cscale); /* coverage is in [0,256] */ alpha = (alpha * coverage) >> 8; } alpha = (GLint) (alpha * alphaf); - PB_WRITE_RGBA_PIXEL( PB, x, y, z, red, green, blue, alpha ) - ; + PB_WRITE_RGBA_PIXEL(PB, x, y, z, red, green, blue, alpha); } } } @@ -1263,6 +1263,43 @@ static void dist_atten_antialiased_rgba_points( GLcontext *ctx, } +#ifdef DEBUG +void +_mesa_print_points_function(GLcontext *ctx) +{ + printf("Point Func == "); + if (ctx->Driver.PointsFunc == size1_ci_points) + printf("size1_ci_points\n"); + else if (ctx->Driver.PointsFunc == size1_rgba_points) + printf("size1_rgba_points\n"); + else if (ctx->Driver.PointsFunc == general_ci_points) + printf("general_ci_points\n"); + else if (ctx->Driver.PointsFunc == general_rgba_points) + printf("general_rgba_points\n"); + else if (ctx->Driver.PointsFunc == textured_rgba_points) + printf("textured_rgba_points\n"); + else if (ctx->Driver.PointsFunc == multitextured_rgba_points) + printf("multitextured_rgba_points\n"); + else if (ctx->Driver.PointsFunc == antialiased_rgba_points) + printf("antialiased_rgba_points\n"); + else if (ctx->Driver.PointsFunc == null_points) + printf("null_points\n"); + else if (ctx->Driver.PointsFunc == dist_atten_general_ci_points) + printf("dist_atten_general_ci_points\n"); + else if (ctx->Driver.PointsFunc == dist_atten_general_rgba_points) + printf("dist_atten_general_rgba_points\n"); + else if (ctx->Driver.PointsFunc == dist_atten_textured_rgba_points) + printf("dist_atten_textured_rgba_points\n"); + else if (ctx->Driver.PointsFunc == dist_atten_antialiased_rgba_points) + printf("dist_atten_antialiased_rgba_points\n"); + else if (!ctx->Driver.PointsFunc) + printf("NULL\n"); + else + printf("Driver func %p\n", ctx->Driver.PointsFunc); +} +#endif + + /* * Examine the current context to determine which point drawing function * should be used. @@ -1331,5 +1368,6 @@ void gl_set_point_function( GLcontext *ctx ) ctx->Driver.PointsFunc = gl_select_points; } + /*_mesa_print_points_function(ctx);*/ } diff --git a/xc/extras/Mesa/src/readpix.c b/xc/extras/Mesa/src/readpix.c index a1e01f0fd..4f4ad90a3 100644 --- a/xc/extras/Mesa/src/readpix.c +++ b/xc/extras/Mesa/src/readpix.c @@ -75,14 +75,14 @@ static void read_index_pixels( GLcontext *ctx, (*ctx->Driver.ReadCI32Span)( ctx, readWidth, x, y, index ); if (ctx->Pixel.IndexShift!=0 || ctx->Pixel.IndexOffset!=0) { - gl_shift_and_offset_ci( ctx, readWidth, index); + _mesa_shift_and_offset_ci( ctx, readWidth, index); } if (ctx->Pixel.MapColorFlag) { - gl_map_ci(ctx, readWidth, index); + _mesa_map_ci(ctx, readWidth, index); } - dest = gl_pixel_addr_in_image(packing, pixels, + dest = _mesa_image_address(packing, pixels, width, height, GL_COLOR_INDEX, type, 0, j, 0); switch (type) { @@ -109,7 +109,7 @@ static void read_index_pixels( GLcontext *ctx, dst[i] = (GLushort) index[i]; } if (packing->SwapBytes) { - gl_swap2( (GLushort *) dst, readWidth ); + _mesa_swap2( (GLushort *) dst, readWidth ); } } break; @@ -120,7 +120,7 @@ static void read_index_pixels( GLcontext *ctx, dst[i] = (GLshort) index[i]; } if (packing->SwapBytes) { - gl_swap2( (GLushort *) dst, readWidth ); + _mesa_swap2( (GLushort *) dst, readWidth ); } } break; @@ -131,7 +131,7 @@ static void read_index_pixels( GLcontext *ctx, dst[i] = (GLuint) index[i]; } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -142,7 +142,7 @@ static void read_index_pixels( GLcontext *ctx, dst[i] = (GLint) index[i]; } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -153,7 +153,7 @@ static void read_index_pixels( GLcontext *ctx, dst[i] = (GLfloat) index[i]; } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -199,36 +199,30 @@ static void read_depth_pixels( GLcontext *ctx, bias_or_scale = ctx->Pixel.DepthBias!=0.0 || ctx->Pixel.DepthScale!=1.0; - if (type==GL_UNSIGNED_SHORT && sizeof(GLdepth)==sizeof(GLushort) + if (type==GL_UNSIGNED_SHORT && ctx->Visual->DepthBits == 16 && !bias_or_scale && !packing->SwapBytes) { /* Special case: directly read 16-bit unsigned depth values. */ for (j=0;j<height;j++,y++) { - GLushort *dst = (GLushort*) gl_pixel_addr_in_image( packing, pixels, + GLdepth depth[MAX_WIDTH]; + GLushort *dst = (GLushort*) _mesa_image_address( packing, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 ); - (*ctx->Driver.ReadDepthSpan)( ctx, width, x, y, (GLdepth*) dst); + GLint i; + _mesa_read_depth_span(ctx, width, x, y, depth); + for (i = 0; i < width; i++) + dst[i] = depth[i]; } } - else if (type==GL_UNSIGNED_INT && sizeof(GLdepth)==sizeof(GLuint) + else if (type==GL_UNSIGNED_INT && ctx->Visual->DepthBits == 32 && !bias_or_scale && !packing->SwapBytes) { /* Special case: directly read 32-bit unsigned depth values. */ - /* Compute shift value to scale depth values up to 32-bit uints. */ - GLuint shift = 0; - GLuint max = MAX_DEPTH; - while ((max&0x80000000)==0) { - max = max << 1; - shift++; - } for (j=0;j<height;j++,y++) { - GLuint *dst = (GLuint *) gl_pixel_addr_in_image( packing, pixels, + GLdepth *dst = (GLdepth *) _mesa_image_address( packing, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, j, 0 ); - (*ctx->Driver.ReadDepthSpan)( ctx, width, x, y, (GLdepth*) dst); - for (i=0;i<width;i++) { - dst[i] = dst[i] << shift; - } + _mesa_read_depth_span(ctx, width, x, y, dst); } } else { - /* General case (slow) */ + /* General case (slower) */ for (j=0;j<height;j++,y++) { GLfloat depth[MAX_WIDTH]; GLvoid *dest; @@ -243,7 +237,7 @@ static void read_depth_pixels( GLcontext *ctx, } } - dest = gl_pixel_addr_in_image(packing, pixels, + dest = _mesa_image_address(packing, pixels, width, height, GL_DEPTH_COMPONENT, type, 0, j, 0); switch (type) { @@ -270,7 +264,7 @@ static void read_depth_pixels( GLcontext *ctx, dst[i] = FLOAT_TO_USHORT( depth[i] ); } if (packing->SwapBytes) { - gl_swap2( (GLushort *) dst, readWidth ); + _mesa_swap2( (GLushort *) dst, readWidth ); } } break; @@ -281,7 +275,7 @@ static void read_depth_pixels( GLcontext *ctx, dst[i] = FLOAT_TO_SHORT( depth[i] ); } if (packing->SwapBytes) { - gl_swap2( (GLushort *) dst, readWidth ); + _mesa_swap2( (GLushort *) dst, readWidth ); } } break; @@ -292,7 +286,7 @@ static void read_depth_pixels( GLcontext *ctx, dst[i] = FLOAT_TO_UINT( depth[i] ); } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -303,7 +297,7 @@ static void read_depth_pixels( GLcontext *ctx, dst[i] = FLOAT_TO_INT( depth[i] ); } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -314,7 +308,7 @@ static void read_depth_pixels( GLcontext *ctx, dst[i] = depth[i]; } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -364,17 +358,17 @@ static void read_stencil_pixels( GLcontext *ctx, GLvoid *dest; GLstencil stencil[MAX_WIDTH]; - gl_read_stencil_span( ctx, readWidth, x, y, stencil ); + _mesa_read_stencil_span( ctx, readWidth, x, y, stencil ); if (shift_or_offset) { - gl_shift_and_offset_stencil( ctx, readWidth, stencil ); + _mesa_shift_and_offset_stencil( ctx, readWidth, stencil ); } if (ctx->Pixel.MapStencilFlag) { - gl_map_stencil( ctx, readWidth, stencil ); + _mesa_map_stencil( ctx, readWidth, stencil ); } - dest = gl_pixel_addr_in_image( packing, pixels, + dest = _mesa_image_address( packing, pixels, width, height, GL_STENCIL_INDEX, type, 0, j, 0 ); switch (type) { @@ -407,7 +401,7 @@ static void read_stencil_pixels( GLcontext *ctx, dst[i] = (GLushort) stencil[i]; } if (packing->SwapBytes) { - gl_swap2( (GLushort *) dst, readWidth ); + _mesa_swap2( (GLushort *) dst, readWidth ); } } break; @@ -418,7 +412,7 @@ static void read_stencil_pixels( GLcontext *ctx, dst[i] = (GLshort) stencil[i]; } if (packing->SwapBytes) { - gl_swap2( (GLushort *) dst, readWidth ); + _mesa_swap2( (GLushort *) dst, readWidth ); } } break; @@ -429,7 +423,7 @@ static void read_stencil_pixels( GLcontext *ctx, dst[i] = (GLuint) stencil[i]; } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -440,7 +434,7 @@ static void read_stencil_pixels( GLcontext *ctx, *dst++ = (GLint) stencil[i]; } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -451,7 +445,7 @@ static void read_stencil_pixels( GLcontext *ctx, dst[i] = (GLfloat) stencil[i]; } if (packing->SwapBytes) { - gl_swap4( (GLuint *) dst, readWidth ); + _mesa_swap4( (GLuint *) dst, readWidth ); } } break; @@ -506,8 +500,19 @@ read_fast_rgba_pixels( GLcontext *ctx, GLvoid *pixels, const struct gl_pixelstore_attrib *packing ) { - /* can't do scale, bias or mapping */ - if (ctx->Pixel.ScaleOrBiasRGBA || ctx->Pixel.MapColorFlag) + GLboolean applyTransferOps; + + applyTransferOps = ctx->Pixel.ScaleOrBiasRGBA || + ctx->Pixel.MapColorFlag || + ctx->ColorMatrix.type != MATRIX_IDENTITY || + ctx->Pixel.ScaleOrBiasRGBApcm || + ctx->Pixel.ColorTableEnabled || + ctx->Pixel.PostColorMatrixColorTableEnabled || + ctx->Pixel.MinMaxEnabled || + ctx->Pixel.HistogramEnabled; + + /* can't do scale, bias, mapping, etc */ + if (applyTransferOps) return GL_FALSE; /* can't do fancy pixel packing */ @@ -564,9 +569,9 @@ read_fast_rgba_pixels( GLcontext *ctx, for (row=0; row<readHeight; row++) { (*ctx->Driver.ReadRGBASpan)(ctx, readWidth, srcX, srcY, (GLubyte (*)[4]) dest); - if (ctx->Visual->SoftwareAlpha) { - gl_read_alpha_span(ctx, readWidth, srcX, srcY, - (GLubyte (*)[4]) dest); + if (ctx->DrawBuffer->UseSoftwareAlphaBuffers) { + _mesa_read_alpha_span(ctx, readWidth, srcX, srcY, + (GLubyte (*)[4]) dest); } dest += rowLength * 4; srcY++; @@ -633,7 +638,7 @@ static void read_rgba_pixels( GLcontext *ctx, return; } - if (!gl_is_legal_format_and_type(format, type)) { + if (!_mesa_is_legal_format_and_type(format, type)) { gl_error(ctx, GL_INVALID_OPERATION, "glReadPixels(format or type)"); return; } @@ -646,14 +651,15 @@ static void read_rgba_pixels( GLcontext *ctx, gl_read_rgba_span( ctx, ctx->ReadBuffer, readWidth, x, y, rgba ); - dest = gl_pixel_addr_in_image( packing, pixels, width, height, - format, type, 0, j, 0); + dest = _mesa_image_address( packing, pixels, width, height, + format, type, 0, j, 0); - gl_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba, - format, type, dest, packing, GL_TRUE ); + _mesa_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba, + format, type, dest, packing, GL_TRUE ); } } else { + /* Convert color index pixels to RGBA */ GLint j; for (j=0;j<height;j++,y++) { GLubyte rgba[MAX_WIDTH][4]; @@ -663,16 +669,16 @@ static void read_rgba_pixels( GLcontext *ctx, (*ctx->Driver.ReadCI32Span)( ctx, readWidth, x, y, index ); if (ctx->Pixel.IndexShift!=0 || ctx->Pixel.IndexOffset!=0) { - gl_map_ci( ctx, readWidth, index ); + _mesa_map_ci( ctx, readWidth, index ); } - gl_map_ci_to_rgba(ctx, readWidth, index, rgba ); + _mesa_map_ci_to_rgba_ubyte(ctx, readWidth, index, rgba ); - dest = gl_pixel_addr_in_image( packing, pixels, width, height, - format, type, 0, j, 0); + dest = _mesa_image_address( packing, pixels, width, height, + format, type, 0, j, 0); - gl_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba, - format, type, dest, packing, GL_TRUE ); + _mesa_pack_rgba_span( ctx, readWidth, (const GLubyte (*)[4]) rgba, + format, type, dest, packing, GL_TRUE ); } } @@ -693,15 +699,20 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, return; } + if (ctx->Driver.ReadPixels && + (*ctx->Driver.ReadPixels)(ctx, x, y, width, height, + format, type, &ctx->Pack, pixels)) + return; + switch (format) { case GL_COLOR_INDEX: - read_index_pixels( ctx, x, y, width, height, type, pixels, &ctx->Pack ); + read_index_pixels(ctx, x, y, width, height, type, pixels, &ctx->Pack); break; case GL_STENCIL_INDEX: - read_stencil_pixels( ctx, x, y, width, height, type, pixels, &ctx->Pack ); + read_stencil_pixels(ctx, x,y, width,height, type, pixels, &ctx->Pack); break; case GL_DEPTH_COMPONENT: - read_depth_pixels( ctx, x, y, width, height, type, pixels, &ctx->Pack ); + read_depth_pixels(ctx, x, y, width, height, type, pixels, &ctx->Pack); break; case GL_RED: case GL_GREEN: @@ -714,7 +725,8 @@ _mesa_ReadPixels( GLint x, GLint y, GLsizei width, GLsizei height, case GL_BGR: case GL_BGRA: case GL_ABGR_EXT: - read_rgba_pixels( ctx, x, y, width, height, format, type, pixels, &ctx->Pack ); + read_rgba_pixels(ctx, x, y, width, height, + format, type, pixels, &ctx->Pack); break; default: gl_error( ctx, GL_INVALID_ENUM, "glReadPixels(format)" ); diff --git a/xc/extras/Mesa/src/span.c b/xc/extras/Mesa/src/span.c index 38f4449f1..598834047 100644 --- a/xc/extras/Mesa/src/span.c +++ b/xc/extras/Mesa/src/span.c @@ -148,10 +148,10 @@ static void multi_write_index_span( GLcontext *ctx, GLuint n, /* make copy of incoming indexes */ MEMCPY( indexTmp, indexes, n * sizeof(GLuint) ); if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_span( ctx, n, x, y, indexTmp, mask ); + _mesa_logicop_ci_span( ctx, n, x, y, indexTmp, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_span( ctx, n, x, y, indexTmp ); + _mesa_mask_index_span( ctx, n, x, y, indexTmp ); } (*ctx->Driver.WriteCI32Span)( ctx, n, x, y, indexTmp, mask ); } @@ -176,6 +176,7 @@ void gl_write_index_span( GLcontext *ctx, GLuint n, GLint x, GLint y, const GLdepth z[], GLuint indexIn[], GLenum primitive ) { + const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | LOGIC_OP_BIT; GLubyte mask[MAX_WIDTH]; GLuint indexBackup[MAX_WIDTH]; GLuint *index; /* points to indexIn or indexBackup */ @@ -189,7 +190,7 @@ void gl_write_index_span( GLcontext *ctx, } } - if ((primitive==GL_BITMAP && ctx->MutablePixels) + if ((primitive==GL_BITMAP && (ctx->RasterMask & modBits)) || (ctx->RasterMask & MULTI_DRAW_BIT)) { /* Make copy of color indexes */ MEMCPY( indexBackup, indexIn, n * sizeof(GLuint) ); @@ -218,7 +219,7 @@ void gl_write_index_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } } @@ -227,6 +228,9 @@ void gl_write_index_span( GLcontext *ctx, if (_mesa_depth_test_span( ctx, n, x, y, z, mask )==0) return; } + /* if we get here, something passed the depth test */ + ctx->OcclusionResult = GL_TRUE; + if (ctx->RasterMask & MULTI_DRAW_BIT) { /* draw to zero or two or more buffers */ multi_write_index_span( ctx, n, x, y, index, mask ); @@ -234,10 +238,10 @@ void gl_write_index_span( GLcontext *ctx, else { /* normal situation: draw to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_span( ctx, n, x, y, index, mask ); + _mesa_logicop_ci_span( ctx, n, x, y, index, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_span( ctx, n, x, y, index ); + _mesa_mask_index_span( ctx, n, x, y, index ); } /* write pixels */ @@ -278,7 +282,7 @@ void gl_write_monoindex_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } } @@ -287,6 +291,9 @@ void gl_write_monoindex_span( GLcontext *ctx, if (_mesa_depth_test_span( ctx, n, x, y, z, mask )==0) return; } + /* if we get here, something passed the depth test */ + ctx->OcclusionResult = GL_TRUE; + if (ctx->Color.DrawBuffer == GL_NONE) { /* write no pixels */ return; @@ -305,11 +312,11 @@ void gl_write_monoindex_span( GLcontext *ctx, } if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_span( ctx, n, x, y, indexes, mask ); + _mesa_logicop_ci_span( ctx, n, x, y, indexes, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_span( ctx, n, x, y, indexes ); + _mesa_mask_index_span( ctx, n, x, y, indexes ); } if (ctx->RasterMask & MULTI_DRAW_BIT) { @@ -319,10 +326,10 @@ void gl_write_monoindex_span( GLcontext *ctx, else { /* normal situation: draw to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_ci_span( ctx, n, x, y, indexes, mask ); + _mesa_logicop_ci_span( ctx, n, x, y, indexes, mask ); } if (ctx->Color.SWmasking) { - gl_mask_index_span( ctx, n, x, y, indexes ); + _mesa_mask_index_span( ctx, n, x, y, indexes ); } (*ctx->Driver.WriteCI32Span)( ctx, n, x, y, indexes, mask ); } @@ -386,20 +393,20 @@ static void multi_write_rgba_span( GLcontext *ctx, GLuint n, MEMCPY( rgbaTmp, rgba, 4 * n * sizeof(GLubyte) ); if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgbaTmp, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgbaTmp, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgbaTmp, mask ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgbaTmp ); + _mesa_mask_rgba_span( ctx, n, x, y, rgbaTmp ); } (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLubyte (*)[4]) rgbaTmp, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, - (const GLubyte (*)[4])rgbaTmp, mask ); + _mesa_write_alpha_span( ctx, n, x, y, + (const GLubyte (*)[4])rgbaTmp, mask ); } } } @@ -415,6 +422,8 @@ void gl_write_rgba_span( GLcontext *ctx, GLubyte rgbaIn[][4], GLenum primitive ) { + const GLuint modBits = FOG_BIT | BLEND_BIT | MASKING_BIT | + LOGIC_OP_BIT | TEXTURE_BIT; GLubyte mask[MAX_WIDTH]; GLboolean write_all = GL_TRUE; GLubyte rgbaBackup[MAX_WIDTH][4]; @@ -431,7 +440,7 @@ void gl_write_rgba_span( GLcontext *ctx, write_all = GL_FALSE; } - if ((primitive==GL_BITMAP && ctx->MutablePixels) + if ((primitive==GL_BITMAP && (ctx->RasterMask & modBits)) || (ctx->RasterMask & MULTI_DRAW_BIT)) { /* must make a copy of the colors since they may be modified */ MEMCPY( rgbaBackup, rgbaIn, 4 * n * sizeof(GLubyte) ); @@ -470,7 +479,7 @@ void gl_write_rgba_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } write_all = GL_FALSE; @@ -486,6 +495,9 @@ void gl_write_rgba_span( GLcontext *ctx, } } + /* if we get here, something passed the depth test */ + ctx->OcclusionResult = GL_TRUE; + if (ctx->RasterMask & MULTI_DRAW_BIT) { multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, @@ -495,7 +507,7 @@ void gl_write_rgba_span( GLcontext *ctx, /* normal: write to exactly one buffer */ /* logic op or blending */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgba, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgba, mask ); @@ -503,7 +515,7 @@ void gl_write_rgba_span( GLcontext *ctx, /* Color component masking */ if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgba ); + _mesa_mask_rgba_span( ctx, n, x, y, rgba ); } /* write pixels */ @@ -512,9 +524,9 @@ void gl_write_rgba_span( GLcontext *ctx, write_all ? Null : mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, - (const GLubyte (*)[4]) rgba, - write_all ? Null : mask ); + _mesa_write_alpha_span( ctx, n, x, y, + (const GLubyte (*)[4]) rgba, + write_all ? Null : mask ); } } @@ -580,7 +592,7 @@ void gl_write_monocolor_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } write_all = GL_FALSE; @@ -596,6 +608,9 @@ void gl_write_monocolor_span( GLcontext *ctx, } } + /* if we get here, something passed the depth test */ + ctx->OcclusionResult = GL_TRUE; + if (ctx->Color.DrawBuffer == GL_NONE) { /* write no pixels */ return; @@ -617,7 +632,7 @@ void gl_write_monocolor_span( GLcontext *ctx, else { /* normal: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgba, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgba, mask ); @@ -625,7 +640,7 @@ void gl_write_monocolor_span( GLcontext *ctx, /* Color component masking */ if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgba ); + _mesa_mask_rgba_span( ctx, n, x, y, rgba ); } /* write pixels */ @@ -633,9 +648,9 @@ void gl_write_monocolor_span( GLcontext *ctx, (const GLubyte (*)[4]) rgba, write_all ? Null : mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, - (const GLubyte (*)[4]) rgba, - write_all ? Null : mask ); + _mesa_write_alpha_span( ctx, n, x, y, + (const GLubyte (*)[4]) rgba, + write_all ? Null : mask ); } } } @@ -658,8 +673,8 @@ void gl_write_monocolor_span( GLcontext *ctx, else { (*ctx->Driver.WriteMonoRGBASpan)( ctx, n, x, y, mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_mono_alpha_span( ctx, n, x, y, (GLubyte) color[ACOMP], - write_all ? Null : mask ); + _mesa_write_mono_alpha_span( ctx, n, x, y, (GLubyte) color[ACOMP], + write_all ? Null : mask ); } } } @@ -724,7 +739,7 @@ void gl_write_texture_span( GLcontext *ctx, if (primitive==GL_BITMAP || (ctx->RasterMask & MULTI_DRAW_BIT)) { /* must make a copy of the colors since they may be modified */ - MEMCPY(rgbaBackup, rgbaIn, 4 * sizeof(GLubyte)); + MEMCPY(rgbaBackup, rgbaIn, 4 * n * sizeof(GLubyte)); rgba = rgbaBackup; } else { @@ -732,7 +747,7 @@ void gl_write_texture_span( GLcontext *ctx, } /* Texture */ - ASSERT(ctx->Texture.Enabled); + ASSERT(ctx->Texture.ReallyEnabled); gl_texture_pixels( ctx, 0, n, s, t, u, lambda, rgba ); /* Add base and specular colors */ @@ -769,7 +784,7 @@ void gl_write_texture_span( GLcontext *ctx, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } write_all = GL_FALSE; @@ -785,6 +800,9 @@ void gl_write_texture_span( GLcontext *ctx, } } + /* if we get here, something passed the depth test */ + ctx->OcclusionResult = GL_TRUE; + if (ctx->RasterMask & MULTI_DRAW_BIT) { multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4])rgba, write_all ? Null : mask ); @@ -792,20 +810,20 @@ void gl_write_texture_span( GLcontext *ctx, else { /* normal: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgba, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgba, mask ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgba ); + _mesa_mask_rgba_span( ctx, n, x, y, rgba ); } (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLubyte (*)[4])rgba, write_all ? Null : mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, - write_all ? Null : mask ); + _mesa_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, + write_all ? Null : mask ); } } } @@ -848,7 +866,7 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits, if (primitive==GL_BITMAP || (ctx->RasterMask & MULTI_DRAW_BIT)) { /* must make a copy of the colors since they may be modified */ - MEMCPY(rgbaBackup, rgbaIn, 4 * sizeof(GLubyte)); + MEMCPY(rgbaBackup, rgbaIn, 4 * n * sizeof(GLubyte)); rgba = rgbaBackup; } else { @@ -856,7 +874,7 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits, } /* Texture */ - ASSERT(ctx->Texture.Enabled); + ASSERT(ctx->Texture.ReallyEnabled); ASSERT(texUnits <= MAX_TEXTURE_UNITS); for (i=0;i<texUnits;i++) { gl_texture_pixels( ctx, i, n, s[i], t[i], u[i], lambda[i], rgba ); @@ -896,7 +914,7 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits, if (ctx->Stencil.Enabled) { /* first stencil test */ - if (gl_stencil_and_depth_test_span(ctx, n, x, y, z, mask) == GL_FALSE) { + if (_mesa_stencil_and_ztest_span(ctx, n, x, y, z, mask) == GL_FALSE) { return; } write_all = GL_FALSE; @@ -912,26 +930,30 @@ gl_write_multitexture_span( GLcontext *ctx, GLuint texUnits, } } + /* if we get here, something passed the depth test */ + ctx->OcclusionResult = GL_TRUE; + if (ctx->RasterMask & MULTI_DRAW_BIT) { - multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, write_all ? Null : mask ); + multi_write_rgba_span( ctx, n, x, y, (const GLubyte (*)[4]) rgba, + write_all ? Null : mask ); } else { /* normal: write to exactly one buffer */ if (ctx->Color.SWLogicOpEnabled) { - gl_logicop_rgba_span( ctx, n, x, y, rgba, mask ); + _mesa_logicop_rgba_span( ctx, n, x, y, rgba, mask ); } else if (ctx->Color.BlendEnabled) { _mesa_blend_span( ctx, n, x, y, rgba, mask ); } if (ctx->Color.SWmasking) { - gl_mask_rgba_span( ctx, n, x, y, rgba ); + _mesa_mask_rgba_span( ctx, n, x, y, rgba ); } (*ctx->Driver.WriteRGBASpan)( ctx, n, x, y, (const GLubyte (*)[4])rgba, write_all ? Null : mask ); if (ctx->RasterMask & ALPHABUF_BIT) { - gl_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4])rgba, - write_all ? Null : mask ); + _mesa_write_alpha_span( ctx, n, x, y, (const GLubyte (*)[4])rgba, + write_all ? Null : mask ); } } } @@ -950,7 +972,7 @@ void gl_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, || x + (GLint) n < 0 || x >= buffer->Width) { /* completely above, below, or right */ /* XXX maybe leave undefined? */ - MEMSET( rgba, 0, 4 * n * sizeof(GLubyte)); + BZERO(rgba, 4 * n * sizeof(GLubyte)); } else { GLint skip, length; @@ -982,8 +1004,8 @@ void gl_read_rgba_span( GLcontext *ctx, GLframebuffer *buffer, } (*ctx->Driver.ReadRGBASpan)( ctx, length, x + skip, y, rgba + skip ); - if (ctx->Visual->SoftwareAlpha) { - gl_read_alpha_span( ctx, length, x + skip, y, rgba + skip ); + if (buffer->UseSoftwareAlphaBuffers) { + _mesa_read_alpha_span( ctx, length, x + skip, y, rgba + skip ); } } } @@ -1001,7 +1023,7 @@ void gl_read_index_span( GLcontext *ctx, GLframebuffer *buffer, if (y < 0 || y >= buffer->Height || x + (GLint) n < 0 || x >= buffer->Width) { /* completely above, below, or right */ - MEMSET(indx, 0, n * sizeof(GLuint)); + BZERO(indx, n * sizeof(GLuint)); } else { GLint skip, length; diff --git a/xc/extras/Mesa/src/state.c b/xc/extras/Mesa/src/state.c index b135a3df0..b678f1e91 100644 --- a/xc/extras/Mesa/src/state.c +++ b/xc/extras/Mesa/src/state.c @@ -63,6 +63,7 @@ #include "mmath.h" #include "pipeline.h" #include "pixel.h" +#include "pixeltex.h" #include "points.h" #include "polygon.h" #include "quads.h" @@ -97,20 +98,17 @@ generic_noop(void) } +/* + * Set all pointers in the given dispatch table to point to a + * generic no-op function. + */ void -_mesa_init_no_op_table(struct _glapi_table *table) +_mesa_init_no_op_table(struct _glapi_table *table, GLuint tableSize) { - /* Check to be sure the dispatcher's table is at least as big as Mesa's. */ - const GLuint size = sizeof(struct _glapi_table) / sizeof(void *); - assert(_glapi_get_dispatch_table_size() >= size); - - { - const GLuint n = _glapi_get_dispatch_table_size(); - GLuint i; - void **dispatch = (void **) table; - for (i = 0; i < n; i++) { - dispatch[i] = (void *) generic_noop; - } + GLuint i; + void **dispatch = (void **) table; + for (i = 0; i < tableSize; i++) { + dispatch[i] = (void *) generic_noop; } } @@ -120,10 +118,10 @@ _mesa_init_no_op_table(struct _glapi_table *table) * immediate-mode commands. */ void -_mesa_init_exec_table(struct _glapi_table *exec) +_mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize) { /* first initialize all dispatch slots to no-op */ - _mesa_init_no_op_table(exec); + _mesa_init_no_op_table(exec, tableSize); /* load the dispatch slots we understand */ exec->Accum = _mesa_Accum; @@ -471,7 +469,6 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->TexImage3D = _mesa_TexImage3D; exec->TexSubImage3D = _mesa_TexSubImage3D; - /* OpenGL 1.2 GL_ARB_imaging */ exec->BlendColor = _mesa_BlendColor; exec->BlendEquation = _mesa_BlendEquation; @@ -508,14 +505,53 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->ResetMinmax = _mesa_ResetMinmax; exec->SeparableFilter2D = _mesa_SeparableFilter2D; - /* GL_EXT_texture3d */ + /* 2. GL_EXT_blend_color */ +#if 0 + exec->BlendColorEXT = _mesa_BlendColorEXT; +#endif + + /* 3. GL_EXT_polygon_offset */ + exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT; + + /* 6. GL_EXT_texture3d */ #if 0 exec->CopyTexSubImage3DEXT = _mesa_CopyTexSubImage3D; exec->TexImage3DEXT = _mesa_TexImage3DEXT; exec->TexSubImage3DEXT = _mesa_TexSubImage3D; #endif - /* GL_EXT_paletted_texture */ + /* 11. GL_EXT_histogram */ + exec->GetHistogramEXT = _mesa_GetHistogram; + exec->GetHistogramParameterfvEXT = _mesa_GetHistogramParameterfv; + exec->GetHistogramParameterivEXT = _mesa_GetHistogramParameteriv; + exec->GetMinmaxEXT = _mesa_GetMinmax; + exec->GetMinmaxParameterfvEXT = _mesa_GetMinmaxParameterfv; + exec->GetMinmaxParameterivEXT = _mesa_GetMinmaxParameteriv; + + /* ?. GL_SGIX_pixel_texture */ + exec->PixelTexGenSGIX = _mesa_PixelTexGenSGIX; + + /* 15. GL_SGIS_pixel_texture */ + exec->PixelTexGenParameteriSGIS = _mesa_PixelTexGenParameteriSGIS; + exec->PixelTexGenParameterivSGIS = _mesa_PixelTexGenParameterivSGIS; + exec->PixelTexGenParameterfSGIS = _mesa_PixelTexGenParameterfSGIS; + exec->PixelTexGenParameterfvSGIS = _mesa_PixelTexGenParameterfvSGIS; + exec->GetPixelTexGenParameterivSGIS = _mesa_GetPixelTexGenParameterivSGIS; + exec->GetPixelTexGenParameterfvSGIS = _mesa_GetPixelTexGenParameterfvSGIS; + + /* 37. GL_EXT_blend_minmax */ +#if 0 + exec->BlendEquationEXT = _mesa_BlendEquationEXT; +#endif + + /* 54. GL_EXT_point_parameters */ + exec->PointParameterfEXT = _mesa_PointParameterfEXT; + exec->PointParameterfvEXT = _mesa_PointParameterfvEXT; + + /* 77. GL_PGI_misc_hints */ + exec->HintPGI = _mesa_HintPGI; + + /* 78. GL_EXT_paletted_texture */ #if 0 exec->ColorTableEXT = _mesa_ColorTableEXT; exec->ColorSubTableEXT = _mesa_ColorSubTableEXT; @@ -524,31 +560,43 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->GetColorTableParameterfvEXT = _mesa_GetColorTableParameterfv; exec->GetColorTableParameterivEXT = _mesa_GetColorTableParameteriv; - /* GL_EXT_compiled_vertex_array */ + /* 97. GL_EXT_compiled_vertex_array */ exec->LockArraysEXT = _mesa_LockArraysEXT; exec->UnlockArraysEXT = _mesa_UnlockArraysEXT; - /* GL_EXT_point_parameters */ - exec->PointParameterfEXT = _mesa_PointParameterfEXT; - exec->PointParameterfvEXT = _mesa_PointParameterfvEXT; - - /* GL_PGI_misc_hints */ - exec->HintPGI = _mesa_HintPGI; - - /* GL_EXT_polygon_offset */ - exec->PolygonOffsetEXT = _mesa_PolygonOffsetEXT; + /* 173. GL_INGR_blend_func_separate */ + exec->BlendFuncSeparateEXT = _mesa_BlendFuncSeparateEXT; - /* GL_EXT_blend_minmax */ -#if 0 - exec->BlendEquationEXT = _mesa_BlendEquationEXT; -#endif + /* 196. GL_MESA_resize_buffers */ + exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; - /* GL_EXT_blend_color */ -#if 0 - exec->BlendColorEXT = _mesa_BlendColorEXT; -#endif + /* 197. GL_MESA_window_pos */ + exec->WindowPos2dMESA = _mesa_WindowPos2dMESA; + exec->WindowPos2dvMESA = _mesa_WindowPos2dvMESA; + exec->WindowPos2fMESA = _mesa_WindowPos2fMESA; + exec->WindowPos2fvMESA = _mesa_WindowPos2fvMESA; + exec->WindowPos2iMESA = _mesa_WindowPos2iMESA; + exec->WindowPos2ivMESA = _mesa_WindowPos2ivMESA; + exec->WindowPos2sMESA = _mesa_WindowPos2sMESA; + exec->WindowPos2svMESA = _mesa_WindowPos2svMESA; + exec->WindowPos3dMESA = _mesa_WindowPos3dMESA; + exec->WindowPos3dvMESA = _mesa_WindowPos3dvMESA; + exec->WindowPos3fMESA = _mesa_WindowPos3fMESA; + exec->WindowPos3fvMESA = _mesa_WindowPos3fvMESA; + exec->WindowPos3iMESA = _mesa_WindowPos3iMESA; + exec->WindowPos3ivMESA = _mesa_WindowPos3ivMESA; + exec->WindowPos3sMESA = _mesa_WindowPos3sMESA; + exec->WindowPos3svMESA = _mesa_WindowPos3svMESA; + exec->WindowPos4dMESA = _mesa_WindowPos4dMESA; + exec->WindowPos4dvMESA = _mesa_WindowPos4dvMESA; + exec->WindowPos4fMESA = _mesa_WindowPos4fMESA; + exec->WindowPos4fvMESA = _mesa_WindowPos4fvMESA; + exec->WindowPos4iMESA = _mesa_WindowPos4iMESA; + exec->WindowPos4ivMESA = _mesa_WindowPos4ivMESA; + exec->WindowPos4sMESA = _mesa_WindowPos4sMESA; + exec->WindowPos4svMESA = _mesa_WindowPos4svMESA; - /* GL_ARB_multitexture */ + /* ARB 1. GL_ARB_multitexture */ exec->ActiveTextureARB = _mesa_ActiveTextureARB; exec->ClientActiveTextureARB = _mesa_ClientActiveTextureARB; exec->MultiTexCoord1dARB = _mesa_MultiTexCoord1dARB; @@ -584,46 +632,25 @@ _mesa_init_exec_table(struct _glapi_table *exec) exec->MultiTexCoord4sARB = _mesa_MultiTexCoord4sARB; exec->MultiTexCoord4svARB = _mesa_MultiTexCoord4svARB; - /* GL_INGR_blend_func_separate */ - exec->BlendFuncSeparateEXT = _mesa_BlendFuncSeparateEXT; - - /* GL_MESA_window_pos */ - exec->WindowPos2dMESA = _mesa_WindowPos2dMESA; - exec->WindowPos2dvMESA = _mesa_WindowPos2dvMESA; - exec->WindowPos2fMESA = _mesa_WindowPos2fMESA; - exec->WindowPos2fvMESA = _mesa_WindowPos2fvMESA; - exec->WindowPos2iMESA = _mesa_WindowPos2iMESA; - exec->WindowPos2ivMESA = _mesa_WindowPos2ivMESA; - exec->WindowPos2sMESA = _mesa_WindowPos2sMESA; - exec->WindowPos2svMESA = _mesa_WindowPos2svMESA; - exec->WindowPos3dMESA = _mesa_WindowPos3dMESA; - exec->WindowPos3dvMESA = _mesa_WindowPos3dvMESA; - exec->WindowPos3fMESA = _mesa_WindowPos3fMESA; - exec->WindowPos3fvMESA = _mesa_WindowPos3fvMESA; - exec->WindowPos3iMESA = _mesa_WindowPos3iMESA; - exec->WindowPos3ivMESA = _mesa_WindowPos3ivMESA; - exec->WindowPos3sMESA = _mesa_WindowPos3sMESA; - exec->WindowPos3svMESA = _mesa_WindowPos3svMESA; - exec->WindowPos4dMESA = _mesa_WindowPos4dMESA; - exec->WindowPos4dvMESA = _mesa_WindowPos4dvMESA; - exec->WindowPos4fMESA = _mesa_WindowPos4fMESA; - exec->WindowPos4fvMESA = _mesa_WindowPos4fvMESA; - exec->WindowPos4iMESA = _mesa_WindowPos4iMESA; - exec->WindowPos4ivMESA = _mesa_WindowPos4ivMESA; - exec->WindowPos4sMESA = _mesa_WindowPos4sMESA; - exec->WindowPos4svMESA = _mesa_WindowPos4svMESA; - - /* GL_MESA_resize_buffers */ - exec->ResizeBuffersMESA = _mesa_ResizeBuffersMESA; - - /* GL_ARB_transpose_matrix */ + /* ARB 3. GL_ARB_transpose_matrix */ exec->LoadTransposeMatrixdARB = _mesa_LoadTransposeMatrixdARB; exec->LoadTransposeMatrixfARB = _mesa_LoadTransposeMatrixfARB; exec->MultTransposeMatrixdARB = _mesa_MultTransposeMatrixdARB; exec->MultTransposeMatrixfARB = _mesa_MultTransposeMatrixfARB; + + /* ARB 12. GL_ARB_texture_compression */ + exec->CompressedTexImage3DARB = _mesa_CompressedTexImage3DARB; + exec->CompressedTexImage2DARB = _mesa_CompressedTexImage2DARB; + exec->CompressedTexImage1DARB = _mesa_CompressedTexImage1DARB; + exec->CompressedTexSubImage3DARB = _mesa_CompressedTexSubImage3DARB; + exec->CompressedTexSubImage2DARB = _mesa_CompressedTexSubImage2DARB; + exec->CompressedTexSubImage1DARB = _mesa_CompressedTexSubImage1DARB; + exec->GetCompressedTexImageARB = _mesa_GetCompressedTexImageARB; + } + /**********************************************************************/ /***** State update logic *****/ /**********************************************************************/ @@ -778,8 +805,10 @@ static void update_rasterflags( GLcontext *ctx ) if (ctx->Scissor.Enabled) ctx->RasterMask |= SCISSOR_BIT; if (ctx->Stencil.Enabled) ctx->RasterMask |= STENCIL_BIT; if (ctx->Color.SWmasking) ctx->RasterMask |= MASKING_BIT; + if (ctx->Texture.ReallyEnabled) ctx->RasterMask |= TEXTURE_BIT; - if (ctx->Visual->SoftwareAlpha && ctx->Color.ColorMask[ACOMP] + if (ctx->DrawBuffer->UseSoftwareAlphaBuffers + && ctx->Color.ColorMask[ACOMP] && ctx->Color.DrawBuffer != GL_NONE) ctx->RasterMask |= ALPHABUF_BIT; @@ -790,11 +819,14 @@ static void update_rasterflags( GLcontext *ctx ) ctx->RasterMask |= WINCLIP_BIT; } + if (ctx->Depth.OcclusionTest) + ctx->RasterMask |= OCCLUSION_BIT; + + /* If we're not drawing to exactly one color buffer set the * MULTI_DRAW_BIT flag. Also set it if we're drawing to no * buffers or the RGBA or CI mask disables all writes. */ - ctx->TriangleCaps &= ~DD_MULTIDRAW; if (ctx->Color.MultiDrawBuffer) { @@ -898,8 +930,7 @@ void gl_update_state( GLcontext *ctx ) ctx->Enabled &= ~(ENABLE_TEXMAT0|ENABLE_TEXMAT1); for (i=0; i < MAX_TEXTURE_UNITS; i++) { - if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) - { + if (ctx->TextureMatrix[i].flags & MAT_DIRTY_ALL_OVER) { gl_matrix_analyze( &ctx->TextureMatrix[i] ); ctx->TextureMatrix[i].flags &= ~MAT_DIRTY_DEPENDENTS; @@ -913,7 +944,7 @@ void gl_update_state( GLcontext *ctx ) if (ctx->NewState & (NEW_TEXTURING | NEW_TEXTURE_ENABLE)) { ctx->Texture.NeedNormals = GL_FALSE; gl_update_dirty_texobjs(ctx); - ctx->Enabled &= ~(ENABLE_TEXGEN0|ENABLE_TEXGEN1); + ctx->Enabled &= ~(ENABLE_TEXGEN0 | ENABLE_TEXGEN1); ctx->Texture.ReallyEnabled = 0; for (i=0; i < MAX_TEXTURE_UNITS; i++) { @@ -921,19 +952,17 @@ void gl_update_state( GLcontext *ctx ) gl_update_texture_unit( ctx, &ctx->Texture.Unit[i] ); ctx->Texture.ReallyEnabled |= - ctx->Texture.Unit[i].ReallyEnabled<<(i*4); + ctx->Texture.Unit[i].ReallyEnabled << (i * 4); if (ctx->Texture.Unit[i].GenFlags != 0) { ctx->Enabled |= ENABLE_TEXGEN0 << i; - if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS) - { + if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_NORMALS) { ctx->Texture.NeedNormals = GL_TRUE; ctx->Texture.NeedEyeCoords = GL_TRUE; } - if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD) - { + if (ctx->Texture.Unit[i].GenFlags & TEXGEN_NEED_EYE_COORD) { ctx->Texture.NeedEyeCoords = GL_TRUE; } } @@ -944,10 +973,9 @@ void gl_update_state( GLcontext *ctx ) ctx->NeedNormals = (ctx->Light.Enabled || ctx->Texture.NeedNormals); } - if (ctx->NewState & (NEW_RASTER_OPS | NEW_LIGHTING | NEW_FOG)) { - + if (ctx->NewState & (NEW_RASTER_OPS | NEW_LIGHTING | NEW_FOG | NEW_TEXTURE_ENABLE)) { - if (ctx->NewState & NEW_RASTER_OPS) { + if (ctx->NewState & (NEW_RASTER_OPS | NEW_TEXTURE_ENABLE)) { update_pixel_logic(ctx); update_pixel_masking(ctx); update_fog_mode(ctx); @@ -956,20 +984,7 @@ void gl_update_state( GLcontext *ctx ) (*ctx->Driver.Dither)( ctx, ctx->Color.DitherFlag ); } - /* Check if incoming colors can be modified during rasterization */ - if (ctx->Fog.Enabled || - ctx->Texture.Enabled || - ctx->Color.BlendEnabled || - ctx->Color.SWmasking || - ctx->Color.SWLogicOpEnabled) { - ctx->MutablePixels = GL_TRUE; - } - else { - ctx->MutablePixels = GL_FALSE; - } - /* update scissor region */ - ctx->DrawBuffer->Xmin = 0; ctx->DrawBuffer->Ymin = 0; ctx->DrawBuffer->Xmax = ctx->DrawBuffer->Width-1; @@ -1132,6 +1147,10 @@ void gl_update_state( GLcontext *ctx ) ctx->ModelProjectWinMatrixUptodate = 0; } + if (ctx->NewState & NEW_COLOR_MATRIX) { + gl_matrix_analyze( &ctx->ColorMatrix ); + } + /* Figure out whether we can light in object space or not. If we * can, find the current positions of the lights in object space */ diff --git a/xc/extras/Mesa/src/state.h b/xc/extras/Mesa/src/state.h index 1c1c29a6f..3b12f5dcc 100644 --- a/xc/extras/Mesa/src/state.h +++ b/xc/extras/Mesa/src/state.h @@ -30,6 +30,13 @@ #include "types.h" +extern void +_mesa_init_no_op_table(struct _glapi_table *exec, GLuint tableSize); + +extern void +_mesa_init_exec_table(struct _glapi_table *exec, GLuint tableSize); + + extern void gl_update_state( GLcontext *ctx ); diff --git a/xc/extras/Mesa/src/teximage.c b/xc/extras/Mesa/src/teximage.c index 7248cbad9..0d25df6d8 100644 --- a/xc/extras/Mesa/src/teximage.c +++ b/xc/extras/Mesa/src/teximage.c @@ -49,6 +49,57 @@ */ +#ifdef DEBUG +static void PrintTexture(const struct gl_texture_image *img) +{ + int i, j, c; + GLubyte *data = img->Data; + + if (!data) { + printf("No texture data\n"); + return; + } + + switch (img->Format) { + case GL_ALPHA: + case GL_LUMINANCE: + case GL_INTENSITY: + case GL_COLOR_INDEX: + c = 1; + break; + case GL_LUMINANCE_ALPHA: + c = 2; + break; + case GL_RGB: + c = 3; + break; + case GL_RGBA: + c = 4; + break; + default: + gl_problem(NULL, "error in PrintTexture\n"); + return; + } + + + for (i = 0; i < img->Height; i++) { + for (j = 0; j < img->Width; j++) { + if (c==1) + printf("%02x ", data[0]); + else if (c==2) + printf("%02x%02x ", data[0], data[1]); + else if (c==3) + printf("%02x%02x%02x ", data[0], data[1], data[2]); + else if (c==4) + printf("%02x%02x%02x%02x ", data[0], data[1], data[2], data[3]); + data += c; + } + printf("\n"); + } +} +#endif + + /* * Compute log base 2 of n. @@ -85,16 +136,24 @@ logbase2( int n ) * GL_LUMANCE_ALPHA, GL_INTENSITY, GL_RGB, or GL_RGBA. * Return -1 if invalid enum. */ -static GLint -decode_internal_format( GLint format ) +GLint +_mesa_base_tex_format( GLcontext *ctx, GLint format ) { switch (format) { + case GL_COMPRESSED_ALPHA_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) + return -1; + /* fall-through */ case GL_ALPHA: case GL_ALPHA4: case GL_ALPHA8: case GL_ALPHA12: case GL_ALPHA16: return GL_ALPHA; + case GL_COMPRESSED_LUMINANCE_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) + return -1; + /* fall-through */ case 1: case GL_LUMINANCE: case GL_LUMINANCE4: @@ -102,6 +161,10 @@ decode_internal_format( GLint format ) case GL_LUMINANCE12: case GL_LUMINANCE16: return GL_LUMINANCE; + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) + return -1; + /* fall-through */ case 2: case GL_LUMINANCE_ALPHA: case GL_LUMINANCE4_ALPHA4: @@ -111,12 +174,31 @@ decode_internal_format( GLint format ) case GL_LUMINANCE12_ALPHA12: case GL_LUMINANCE16_ALPHA16: return GL_LUMINANCE_ALPHA; + case GL_COMPRESSED_INTENSITY_ARB: + if (ctx && !ctx->Extensions.HaveTextureCompression) + return -1; + /* fall-through */ case GL_INTENSITY: case GL_INTENSITY4: case GL_INTENSITY8: case GL_INTENSITY12: case GL_INTENSITY16: return GL_INTENSITY; + case GL_COMPRESSED_RGB_ARB: + if (ctx && ctx->Extensions.HaveTextureCompression) + return GL_RGB; + else + return -1; + case GL_COMPRESSED_RGB_FXT1_3DFX: + if (ctx && ctx->Extensions.HaveTextureCompressionFXT1) + return GL_RGB; + else + return -1; + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + if (ctx && ctx->Extensions.HaveTextureCompressionS3TC) + return GL_RGB; + else + return -1; case 3: case GL_RGB: case GL_R3_G3_B2: @@ -127,6 +209,23 @@ decode_internal_format( GLint format ) case GL_RGB12: case GL_RGB16: return GL_RGB; + case GL_COMPRESSED_RGBA_ARB: + if (ctx && ctx->Extensions.HaveTextureCompression) + return GL_RGBA; + else + return -1; + case GL_COMPRESSED_RGBA_FXT1_3DFX: + if (ctx && ctx->Extensions.HaveTextureCompressionFXT1) + return GL_RGBA; + else + return -1; + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + if (ctx && ctx->Extensions.HaveTextureCompressionS3TC) + return GL_RGBA; + else + return -1; case 4: case GL_RGBA: case GL_RGBA2: @@ -224,23 +323,30 @@ components_in_intformat( GLint format ) } - -struct gl_texture_image * -gl_alloc_texture_image( void ) -{ - return CALLOC_STRUCT(gl_texture_image); -} - - - -void -gl_free_texture_image( struct gl_texture_image *teximage ) +/* + * Return GL_TRUE if internalFormat is a compressed format, return GL_FALSE + * otherwise. + */ +static GLboolean +is_compressed_format(GLenum internalFormat) { - if (teximage->Data) { - FREE( teximage->Data ); - teximage->Data = NULL; + switch (internalFormat) { + case GL_COMPRESSED_ALPHA_ARB: + case GL_COMPRESSED_LUMINANCE_ARB: + case GL_COMPRESSED_LUMINANCE_ALPHA_ARB: + case GL_COMPRESSED_INTENSITY_ARB: + case GL_COMPRESSED_RGB_ARB: + case GL_COMPRESSED_RGBA_ARB: + case GL_COMPRESSED_RGB_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT: + case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT: + case GL_COMPRESSED_RGB_FXT1_3DFX: + case GL_COMPRESSED_RGBA_FXT1_3DFX: + return GL_TRUE; + default: + return GL_FALSE; } - FREE( teximage ); } @@ -354,6 +460,217 @@ set_teximage_component_sizes( struct gl_texture_image *texImage ) } +static void +set_tex_image(struct gl_texture_object *tObj, + GLenum target, GLint level, + struct gl_texture_image *texImage) +{ + ASSERT(tObj); + ASSERT(texImage); + switch (target) { + case GL_TEXTURE_2D: + tObj->Image[level] = texImage; + return; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + tObj->Image[level] = texImage; + return; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + tObj->NegX[level] = texImage; + return; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + tObj->PosY[level] = texImage; + return; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + tObj->NegY[level] = texImage; + return; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + tObj->PosZ[level] = texImage; + return; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + tObj->NegZ[level] = texImage; + return; + default: + gl_problem(NULL, "bad target in set_tex_image()"); + return; + } +} + + +/* + * Return new gl_texture_image struct with all fields initialized to zero. + */ +struct gl_texture_image * +_mesa_alloc_texture_image( void ) +{ + return CALLOC_STRUCT(gl_texture_image); +} + + + +/* + * Initialize most fields of a gl_texture_image struct. + */ +static void +init_texture_image( struct gl_texture_image *img, + GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum internalFormat ) +{ + ASSERT(img); + ASSERT(!img->Data); + img->Format = (GLenum) _mesa_base_tex_format(NULL, internalFormat); + set_teximage_component_sizes( img ); + img->IntFormat = (GLenum) internalFormat; + img->Border = border; + img->Width = width; + img->Height = height; + img->Depth = depth; + img->WidthLog2 = logbase2(width - 2 * border); + if (height == 1) /* 1-D texture */ + img->HeightLog2 = 0; + else + img->HeightLog2 = logbase2(height - 2 * border); + if (depth == 1) /* 2-D texture */ + img->DepthLog2 = 0; + else + img->DepthLog2 = logbase2(depth - 2 * border); + img->Width2 = 1 << img->WidthLog2; + img->Height2 = 1 << img->HeightLog2; + img->Depth2 = 1 << img->DepthLog2; + img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2); + img->IsCompressed = is_compressed_format(internalFormat); +} + + + +void +_mesa_free_texture_image( struct gl_texture_image *teximage ) +{ + if (teximage->Data) { + FREE( teximage->Data ); + teximage->Data = NULL; + } + FREE( teximage ); +} + + + +/* + * Return number of bytes of storage needed to store a compressed texture + * image. + */ +GLuint +_mesa_compressed_image_size(GLenum internalFormat, + GLint width, GLint height, GLint depth) +{ + return 0; +} + + + +/* + * Given a texture unit and a texture target, return the corresponding + * texture object. + */ +struct gl_texture_object * +_mesa_select_tex_object(GLcontext *ctx, struct gl_texture_unit *texUnit, + GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + return texUnit->CurrentD[1]; + case GL_PROXY_TEXTURE_1D: + return ctx->Texture.Proxy1D; + case GL_TEXTURE_2D: + return texUnit->CurrentD[2]; + case GL_PROXY_TEXTURE_2D: + return ctx->Texture.Proxy2D; + case GL_TEXTURE_3D: + return texUnit->CurrentD[3]; + case GL_PROXY_TEXTURE_3D: + return ctx->Texture.Proxy3D; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + return ctx->Extensions.HaveTextureCubeMap + ? texUnit->CurrentCubeMap : NULL; + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.HaveTextureCubeMap + ? ctx->Texture.ProxyCubeMap : NULL; + default: + gl_problem(NULL, "bad target in _mesa_select_tex_object()"); + return NULL; + } +} + + +/* + * Return the texture image struct which corresponds to target and level + * for the given texture unit. + */ +struct gl_texture_image * +_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit, + GLenum target, GLint level) +{ + ASSERT(texUnit); + switch (target) { + case GL_TEXTURE_1D: + return texUnit->CurrentD[1]->Image[level]; + case GL_PROXY_TEXTURE_1D: + return ctx->Texture.Proxy1D->Image[level]; + case GL_TEXTURE_2D: + return texUnit->CurrentD[2]->Image[level]; + case GL_PROXY_TEXTURE_2D: + return ctx->Texture.Proxy2D->Image[level]; + case GL_TEXTURE_3D: + return texUnit->CurrentD[3]->Image[level]; + case GL_PROXY_TEXTURE_3D: + return ctx->Texture.Proxy3D->Image[level]; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + return texUnit->CurrentCubeMap->Image[level]; + else + return NULL; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + return texUnit->CurrentCubeMap->NegX[level]; + else + return NULL; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + return texUnit->CurrentCubeMap->PosY[level]; + else + return NULL; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + return texUnit->CurrentCubeMap->NegY[level]; + else + return NULL; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + return texUnit->CurrentCubeMap->PosZ[level]; + else + return NULL; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + return texUnit->CurrentCubeMap->NegZ[level]; + else + return NULL; + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) + return ctx->Texture.ProxyCubeMap->Image[level]; + else + return NULL; + default: + gl_problem(ctx, "bad target in _mesa_select_tex_image()"); + return NULL; + } +} + + + /* Need this to prevent an out-of-bounds memory access when using * X86 optimized code. */ @@ -366,68 +683,45 @@ set_teximage_component_sizes( struct gl_texture_image *texImage ) /* - * This is called by glTexImage[123]D in order to build a gl_texture_image - * object given the client's parameters and image data. - * - * NOTES: Width, height and depth should include the border. - * All texture image parameters should have already been error checked. + * Called by glTexImage[123]D. Fill in a texture image with data given + * by the client. All pixel transfer and unpack modes are handled here. + * NOTE: All texture image parameters should have already been error checked. */ -static struct gl_texture_image * -make_texture_image( GLcontext *ctx, GLint internalFormat, - GLint width, GLint height, GLint depth, GLint border, +static void +make_texture_image( GLcontext *ctx, + struct gl_texture_image *texImage, GLenum srcFormat, GLenum srcType, const GLvoid *pixels, const struct gl_pixelstore_attrib *unpacking) { GLint components, numPixels; - struct gl_texture_image *texImage; - - assert(width > 0); - assert(height > 0); - assert(depth > 0); - assert(border == 0 || border == 1); - assert(pixels); - assert(unpacking); - - - /* - * Allocate and initialize the texture_image struct - */ - texImage = gl_alloc_texture_image(); - if (!texImage) - return NULL; - - texImage->Format = (GLenum) decode_internal_format(internalFormat); - set_teximage_component_sizes( texImage ); - texImage->IntFormat = (GLenum) internalFormat; - texImage->Border = border; - texImage->Width = width; - texImage->Height = height; - texImage->Depth = depth; - texImage->WidthLog2 = logbase2(width - 2 * border); - if (height == 1) /* 1-D texture */ - texImage->HeightLog2 = 0; - else - texImage->HeightLog2 = logbase2(height - 2 * border); - if (depth == 1) /* 2-D texture */ - texImage->DepthLog2 = 0; - else - texImage->DepthLog2 = logbase2(depth - 2 * border); - texImage->Width2 = 1 << texImage->WidthLog2; - texImage->Height2 = 1 << texImage->HeightLog2; - texImage->Depth2 = 1 << texImage->DepthLog2; - texImage->MaxLog2 = MAX2(texImage->WidthLog2, texImage->HeightLog2); - + GLint internalFormat, width, height, depth, border; + + ASSERT(ctx); + ASSERT(texImage); + ASSERT(!texImage->Data); + ASSERT(pixels); + ASSERT(unpacking); + + internalFormat = texImage->IntFormat; + width = texImage->Width; + height = texImage->Height; + depth = texImage->Depth; + border = texImage->Border; components = components_in_intformat(internalFormat); - numPixels = texImage->Width * texImage->Height * texImage->Depth; - texImage->Data = (GLubyte *) MALLOC(numPixels * components + EXTRA_BYTE); + ASSERT(width > 0); + ASSERT(height > 0); + ASSERT(depth > 0); + ASSERT(border == 0 || border == 1); + ASSERT(pixels); + ASSERT(unpacking); + ASSERT(components); - if (!texImage->Data) { - /* out of memory */ - gl_free_texture_image(texImage); - return NULL; - } + numPixels = width * height * depth; + texImage->Data = (GLubyte *) MALLOC(numPixels * components + EXTRA_BYTE); + if (!texImage->Data) + return; /* out of memory */ /* * OK, the texture image struct has been initialized and the texture @@ -441,15 +735,18 @@ make_texture_image( GLcontext *ctx, GLint internalFormat, && !ctx->Pixel.IndexOffset && !ctx->Pixel.IndexShift && srcType == GL_UNSIGNED_BYTE && depth == 1) { - if (srcFormat == internalFormat) { + if (srcFormat == internalFormat || + (srcFormat == GL_LUMINANCE && internalFormat == 1) || + (srcFormat == GL_LUMINANCE_ALPHA && internalFormat == 2) || + (srcFormat == GL_RGB && internalFormat == 3) || + (srcFormat == GL_RGBA && internalFormat == 4)) { /* This will cover the common GL_RGB, GL_RGBA, GL_ALPHA, * GL_LUMINANCE_ALPHA, etc. texture formats. */ - const GLubyte *src = gl_pixel_addr_in_image(unpacking, - pixels, width, height, srcFormat, srcType, 0, 0, 0); - const GLubyte *src1 = gl_pixel_addr_in_image(unpacking, - pixels, width, height, srcFormat, srcType, 0, 1, 0); - const GLint srcStride = src1 - src; + const GLubyte *src = (const GLubyte *) _mesa_image_address( + unpacking, pixels, width, height, srcFormat, srcType, 0, 0, 0); + const GLint srcStride = _mesa_image_row_stride(unpacking, width, + srcFormat, srcType); GLubyte *dst = texImage->Data; GLint dstBytesPerRow = width * components * sizeof(GLubyte); if (srcStride == dstBytesPerRow) { @@ -463,15 +760,14 @@ make_texture_image( GLcontext *ctx, GLint internalFormat, dst += dstBytesPerRow; } } - return texImage; /* all done */ + return; /* all done */ } else if (srcFormat == GL_RGBA && internalFormat == GL_RGB) { /* commonly used by Quake */ - const GLubyte *src = gl_pixel_addr_in_image(unpacking, - pixels, width, height, srcFormat, srcType, 0, 0, 0); - const GLubyte *src1 = gl_pixel_addr_in_image(unpacking, - pixels, width, height, srcFormat, srcType, 0, 1, 0); - const GLint srcStride = src1 - src; + const GLubyte *src = (const GLubyte *) _mesa_image_address( + unpacking, pixels, width, height, srcFormat, srcType, 0, 0, 0); + const GLint srcStride = _mesa_image_row_stride(unpacking, width, + srcFormat, srcType); GLubyte *dst = texImage->Data; GLint i, j; for (i = 0; i < height; i++) { @@ -484,7 +780,7 @@ make_texture_image( GLcontext *ctx, GLint internalFormat, } src += srcStride; } - return texImage; /* all done */ + return; /* all done */ } } @@ -500,7 +796,7 @@ make_texture_image( GLcontext *ctx, GLint internalFormat, GLint img, row; for (img = 0; img < depth; img++) { for (row = 0; row < height; row++) { - const GLvoid *source = gl_pixel_addr_in_image(unpacking, + const GLvoid *source = _mesa_image_address(unpacking, pixels, width, height, srcFormat, srcType, img, row, 0); _mesa_unpack_index_span(ctx, width, dstType, dest, srcType, source, unpacking, GL_TRUE); @@ -516,7 +812,7 @@ make_texture_image( GLcontext *ctx, GLint internalFormat, GLint img, row; for (img = 0; img < depth; img++) { for (row = 0; row < height; row++) { - const GLvoid *source = gl_pixel_addr_in_image(unpacking, + const GLvoid *source = _mesa_image_address(unpacking, pixels, width, height, srcFormat, srcType, img, row, 0); _mesa_unpack_ubyte_color_span(ctx, width, dstFormat, dest, srcFormat, srcType, source, unpacking, GL_TRUE); @@ -524,8 +820,6 @@ make_texture_image( GLcontext *ctx, GLint internalFormat, } } } - - return texImage; /* All done! */ } @@ -533,48 +827,19 @@ make_texture_image( GLcontext *ctx, GLint internalFormat, /* * glTexImage[123]D can accept a NULL image pointer. In this case we * create a texture image with unspecified image contents per the OpenGL - * spec. + * spec. This function creates an empty image for the given texture image. */ -static struct gl_texture_image * -make_null_texture( GLcontext *ctx, GLenum internalFormat, - GLsizei width, GLsizei height, GLsizei depth, GLint border ) +static void +make_null_texture( struct gl_texture_image *texImage ) { GLint components; - struct gl_texture_image *texImage; GLint numPixels; - (void) ctx; - - /*internalFormat = decode_internal_format(internalFormat);*/ - components = components_in_intformat(internalFormat); - numPixels = width * height * depth; - texImage = gl_alloc_texture_image(); - if (!texImage) - return NULL; - - texImage->Format = (GLenum) decode_internal_format(internalFormat); - set_teximage_component_sizes( texImage ); - texImage->IntFormat = internalFormat; - texImage->Border = border; - texImage->Width = width; - texImage->Height = height; - texImage->Depth = depth; - texImage->WidthLog2 = logbase2(width - 2*border); - if (height==1) /* 1-D texture */ - texImage->HeightLog2 = 0; - else - texImage->HeightLog2 = logbase2(height - 2*border); - if (depth==1) /* 2-D texture */ - texImage->DepthLog2 = 0; - else - texImage->DepthLog2 = logbase2(depth - 2*border); - texImage->Width2 = 1 << texImage->WidthLog2; - texImage->Height2 = 1 << texImage->HeightLog2; - texImage->Depth2 = 1 << texImage->DepthLog2; - texImage->MaxLog2 = MAX2( texImage->WidthLog2, texImage->HeightLog2 ); + ASSERT(texImage); + ASSERT(!texImage->Data); - /* XXX should we really allocate memory for the image or let it be NULL? */ - /*texImage->Data = NULL;*/ + components = components_in_intformat(texImage->IntFormat); + numPixels = texImage->Width * texImage->Height * texImage->Depth; texImage->Data = (GLubyte *) MALLOC( numPixels * components + EXTRA_BYTE ); @@ -597,9 +862,9 @@ make_null_texture( GLcontext *ctx, GLenum internalFormat, GLubyte *imgPtr = texImage->Data; GLint i, j, k; - for (i=0;i<height;i++) { + for (i = 0; i < texImage->Height; i++) { GLint srcRow = 7 - i % 8; - for (j=0;j<width;j++) { + for (j = 0; j < texImage->Width; j++) { GLint srcCol = j % 32; GLint texel = (message[srcRow][srcCol]=='X') ? 255 : 70; for (k=0;k<components;k++) { @@ -608,8 +873,6 @@ make_null_texture( GLcontext *ctx, GLenum internalFormat, } } } - - return texImage; } @@ -640,7 +903,10 @@ texture_error_check( GLcontext *ctx, GLenum target, } else if (dimensions == 2) { isProxy = (GLboolean) (target == GL_PROXY_TEXTURE_2D); - if (target != GL_TEXTURE_2D && !isProxy) { + if (target != GL_TEXTURE_2D && !isProxy && + !(ctx->Extensions.HaveTextureCubeMap && + target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { gl_error( ctx, GL_INVALID_ENUM, "glTexImage2D(target)" ); return GL_TRUE; } @@ -658,7 +924,7 @@ texture_error_check( GLcontext *ctx, GLenum target, } /* Border */ - if (border!=0 && border!=1) { + if (border != 0 && border != 1) { if (!isProxy) { char message[100]; sprintf(message, "glTexImage%dD(border)", dimensions); @@ -691,6 +957,17 @@ texture_error_check( GLcontext *ctx, GLenum target, } } + /* For cube map, width must equal height */ + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { + if (width != height) { + if (!isProxy) { + gl_error(ctx, GL_INVALID_VALUE, "glTexImage2D(width != height)"); + } + return GL_TRUE; + } + } + /* Depth */ if (dimensions >= 3) { if (depth < 2 * border || depth > 2 + ctx->Const.MaxTextureSize @@ -703,7 +980,7 @@ texture_error_check( GLcontext *ctx, GLenum target, } /* Level */ - if (level<0 || level>=ctx->Const.MaxTextureLevels) { + if (level < 0 || level >= ctx->Const.MaxTextureLevels) { if (!isProxy) { char message[100]; sprintf(message, "glTexImage%dD(level)", dimensions); @@ -712,7 +989,7 @@ texture_error_check( GLcontext *ctx, GLenum target, return GL_TRUE; } - iformat = decode_internal_format( internalFormat ); + iformat = _mesa_base_tex_format( ctx, internalFormat ); if (iformat < 0) { if (!isProxy) { char message[100]; @@ -722,16 +999,18 @@ texture_error_check( GLcontext *ctx, GLenum target, return GL_TRUE; } - if (!gl_is_legal_format_and_type( format, type )) { - /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there - * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4. - */ - if (!isProxy) { - char message[100]; - sprintf(message, "glTexImage%dD(format or type)", dimensions); - gl_error(ctx, GL_INVALID_OPERATION, message); + if (!is_compressed_format(internalFormat)) { + if (!_mesa_is_legal_format_and_type( format, type )) { + /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there + * is a type/format mismatch. See 1.2 spec page 94, sec 3.6.4. + */ + if (!isProxy) { + char message[100]; + sprintf(message, "glTexImage%dD(format or type)", dimensions); + gl_error(ctx, GL_INVALID_OPERATION, message); + } + return GL_TRUE; } - return GL_TRUE; } /* if we get here, the parameters are OK */ @@ -763,7 +1042,15 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions, } } else if (dimensions == 2) { - if (target != GL_TEXTURE_2D) { + if (ctx->Extensions.HaveTextureCubeMap) { + if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || + target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) && + target != GL_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); + return GL_TRUE; + } + } + else if (target != GL_TEXTURE_2D) { gl_error( ctx, GL_INVALID_ENUM, "glTexSubImage2D(target)" ); return GL_TRUE; } @@ -838,11 +1125,13 @@ subtexture_error_check( GLcontext *ctx, GLuint dimensions, } } - if (!gl_is_legal_format_and_type(format, type)) { - char message[100]; - sprintf(message, "glTexSubImage%dD(format or type)", dimensions); - gl_error(ctx, GL_INVALID_ENUM, message); - return GL_TRUE; + if (!is_compressed_format(destTex->IntFormat)) { + if (!_mesa_is_legal_format_and_type(format, type)) { + char message[100]; + sprintf(message, "glTexSubImage%dD(format or type)", dimensions); + gl_error(ctx, GL_INVALID_ENUM, message); + return GL_TRUE; + } } return GL_FALSE; @@ -861,18 +1150,25 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, { GLint iformat; - if (target != GL_TEXTURE_1D && target != GL_TEXTURE_2D) { - gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1/2D(target)" ); - return GL_TRUE; - } - - if (dimensions == 1 && target != GL_TEXTURE_1D) { - gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" ); - return GL_TRUE; + if (dimensions == 1) { + if (target != GL_TEXTURE_1D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage1D(target)" ); + return GL_TRUE; + } } - else if (dimensions == 2 && target != GL_TEXTURE_2D) { - gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); - return GL_TRUE; + else if (dimensions == 2) { + if (ctx->Extensions.HaveTextureCubeMap) { + if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || + target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) && + target != GL_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); + return GL_TRUE; + } + } + else if (target != GL_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexImage2D(target)" ); + return GL_TRUE; + } } /* Border */ @@ -903,6 +1199,15 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, } } + /* For cube map, width must equal height */ + if (target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) { + if (width != height) { + gl_error(ctx, GL_INVALID_VALUE, "glCopyTexImage2D(width != height)"); + return GL_TRUE; + } + } + /* Level */ if (level<0 || level>=ctx->Const.MaxTextureLevels) { char message[100]; @@ -911,7 +1216,7 @@ copytexture_error_check( GLcontext *ctx, GLuint dimensions, return GL_TRUE; } - iformat = decode_internal_format( internalFormat ); + iformat = _mesa_base_tex_format( ctx, internalFormat ); if (iformat < 0) { char message[100]; sprintf(message, "glCopyTexImage%dD(internalFormat)", dimensions); @@ -933,17 +1238,31 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions, struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; struct gl_texture_image *teximage; - if (dimensions == 1 && target != GL_TEXTURE_1D) { - gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" ); - return GL_TRUE; + if (dimensions == 1) { + if (target != GL_TEXTURE_1D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage1D(target)" ); + return GL_TRUE; + } } - else if (dimensions == 2 && target != GL_TEXTURE_2D) { - gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); - return GL_TRUE; + else if (dimensions == 2) { + if (ctx->Extensions.HaveTextureCubeMap) { + if ((target < GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB || + target > GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB) && + target != GL_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); + return GL_TRUE; + } + } + else if (target != GL_TEXTURE_2D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage2D(target)" ); + return GL_TRUE; + } } - else if (dimensions == 3 && target != GL_TEXTURE_3D) { - gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" ); - return GL_TRUE; + else if (dimensions == 3) { + if (target != GL_TEXTURE_3D) { + gl_error( ctx, GL_INVALID_ENUM, "glCopyTexSubImage3D(target)" ); + return GL_TRUE; + } } if (level < 0 || level >= ctx->Const.MaxTextureLevels) { @@ -1028,66 +1347,100 @@ copytexsubimage_error_check( GLcontext *ctx, GLuint dimensions, * Called from the API. Note that width includes the border. */ void -_mesa_TexImage1D( GLenum target, GLint level, GLint internalformat, +_mesa_TexImage1D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage1D"); if (target==GL_TEXTURE_1D) { - struct gl_texture_image *teximage; - if (texture_error_check( ctx, target, level, internalformat, - format, type, 1, width, 1, 1, border )) { - /* error in texture image was detected */ - return; + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (texture_error_check(ctx, target, level, internalFormat, + format, type, 1, width, 1, 1, border)) { + return; /* error in texture image was detected */ } - /* free current texture image, if any */ - if (texUnit->CurrentD[1]->Image[level]) { - gl_free_texture_image( texUnit->CurrentD[1]->Image[level] ); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = texUnit->CurrentD[1]; + texImage = texObj->Image[level]; + + if (!texImage) { + texImage = _mesa_alloc_texture_image(); + texObj->Image[level] = texImage; + if (!texImage) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D"); + return; + } + } + else if (texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; } - /* make new texture from source image */ + /* setup the teximage struct's fields */ + init_texture_image(texImage, width, 1, 1, border, internalFormat); + + /* process the texture image */ if (pixels) { - teximage = make_texture_image(ctx, internalformat, width, 1, 1, - border, format, type, pixels, &ctx->Unpack); + GLboolean retain = GL_TRUE; + GLboolean success = GL_FALSE; + if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA + && ctx->Driver.TexImage1D) { + /* let device driver try to use raw image */ + success = (*ctx->Driver.TexImage1D)( ctx, target, level, format, + type, pixels, &ctx->Unpack, + texObj, texImage, &retain); + } + if (retain || !success) { + /* make internal copy of the texture image */ + make_texture_image(ctx, texImage, format, type, + pixels, &ctx->Unpack); + if (!success && ctx->Driver.TexImage1D) { + /* let device driver try to use unpacked image */ + (*ctx->Driver.TexImage1D)( ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, + texObj, texImage, &retain); + } + } + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } } else { - teximage = make_null_texture(ctx, (GLenum) internalformat, - width, 1, 1, border); + make_null_texture(texImage); + if (ctx->Driver.TexImage1D) { + GLboolean retain; + (*ctx->Driver.TexImage1D)( ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, + texObj, texImage, &retain); + } } - /* install new texture image */ - texUnit->CurrentD[1]->Image[level] = teximage; - gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[1] ); + /* state update */ + gl_put_texobj_on_dirty_list( ctx, texObj ); ctx->NewState |= NEW_TEXTURING; - - /* tell driver about change */ - if (ctx->Driver.TexImage) { - (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D, - texUnit->CurrentD[1], - level, internalformat, teximage ); - } } else if (target==GL_PROXY_TEXTURE_1D) { /* Proxy texture: check for errors and update proxy state */ - if (texture_error_check( ctx, target, level, internalformat, - format, type, 1, width, 1, 1, border )) { + if (texture_error_check(ctx, target, level, internalFormat, + format, type, 1, width, 1, 1, border)) { + /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { MEMSET( ctx->Texture.Proxy1D->Image[level], 0, sizeof(struct gl_texture_image) ); } } else { - ctx->Texture.Proxy1D->Image[level]->Format = (GLenum) format; - set_teximage_component_sizes( ctx->Texture.Proxy1D->Image[level] ); - ctx->Texture.Proxy1D->Image[level]->IntFormat = (GLenum) internalformat; - ctx->Texture.Proxy1D->Image[level]->Border = border; - ctx->Texture.Proxy1D->Image[level]->Width = width; - ctx->Texture.Proxy1D->Image[level]->Height = 1; - ctx->Texture.Proxy1D->Image[level]->Depth = 1; + /* if no error, update proxy texture image parameters */ + init_texture_image(ctx->Texture.Proxy1D->Image[level], + width, 1, 1, border, internalFormat); } } else { @@ -1098,67 +1451,114 @@ _mesa_TexImage1D( GLenum target, GLint level, GLint internalformat, void -_mesa_TexImage2D( GLenum target, GLint level, GLint internalformat, +_mesa_TexImage2D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage2D"); - if (target==GL_TEXTURE_2D) { - struct gl_texture_image *teximage; - if (texture_error_check( ctx, target, level, internalformat, - format, type, 2, width, height, 1, border )) { - /* error in texture image was detected */ - return; + if (target==GL_TEXTURE_2D || + (ctx->Extensions.HaveTextureCubeMap && + target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (texture_error_check(ctx, target, level, internalFormat, + format, type, 2, width, height, 1, border)) { + return; /* error in texture image was detected */ } - /* free current texture image, if any */ - if (texUnit->CurrentD[2]->Image[level]) { - gl_free_texture_image( texUnit->CurrentD[2]->Image[level] ); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = _mesa_select_tex_object(ctx, texUnit, target); + texImage = _mesa_select_tex_image(ctx, texUnit, target, level); + + if (!texImage) { + texImage = _mesa_alloc_texture_image(); + set_tex_image(texObj, target, level, texImage); + /*texObj->Image[level] = texImage;*/ + if (!texImage) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D"); + return; + } + } + else if (texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; } - /* make new texture from source image */ + /* setup the teximage struct's fields */ + init_texture_image(texImage, width, height, 1, border, internalFormat); + + /* process the texture image */ if (pixels) { - teximage = make_texture_image(ctx, internalformat, width, height, 1, - border, format, type, pixels, &ctx->Unpack); + GLboolean retain = GL_TRUE; + GLboolean success = GL_FALSE; + if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA + && ctx->Driver.TexImage2D) { + /* let device driver try to use raw image */ + success = (*ctx->Driver.TexImage2D)( ctx, target, level, format, + type, pixels, &ctx->Unpack, + texObj, texImage, &retain); + } + if (retain || !success) { + /* make internal copy of the texture image */ + make_texture_image(ctx, texImage, format, type, + pixels, &ctx->Unpack); + if (!success && ctx->Driver.TexImage2D) { + /* let device driver try to use unpacked image */ + (*ctx->Driver.TexImage2D)( ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, + texObj, texImage, &retain); + } + } + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } } else { - teximage = make_null_texture(ctx, (GLenum) internalformat, - width, height, 1, border); + make_null_texture(texImage); + if (ctx->Driver.TexImage2D) { + GLboolean retain; + (*ctx->Driver.TexImage2D)( ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, + texObj, texImage, &retain); + } } - /* install new texture image */ - texUnit->CurrentD[2]->Image[level] = teximage; - gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[2] ); - ctx->NewState |= NEW_TEXTURING; - - /* tell driver about change */ +#define OLD_DD_TEXTURE +#ifdef OLD_DD_TEXTURE + /* XXX this will be removed in the future */ if (ctx->Driver.TexImage) { - (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D, - texUnit->CurrentD[2], - level, internalformat, teximage ); + (*ctx->Driver.TexImage)( ctx, target, texObj, level, internalFormat, + texImage ); } +#endif + + /* state update */ + gl_put_texobj_on_dirty_list( ctx, texObj ); + ctx->NewState |= NEW_TEXTURING; } else if (target==GL_PROXY_TEXTURE_2D) { /* Proxy texture: check for errors and update proxy state */ - if (texture_error_check( ctx, target, level, internalformat, - format, type, 2, width, height, 1, border )) { + if (texture_error_check(ctx, target, level, internalFormat, + format, type, 2, width, height, 1, border)) { + /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { MEMSET( ctx->Texture.Proxy2D->Image[level], 0, sizeof(struct gl_texture_image) ); } } else { - ctx->Texture.Proxy2D->Image[level]->Format = (GLenum) format; - set_teximage_component_sizes( ctx->Texture.Proxy2D->Image[level] ); - ctx->Texture.Proxy2D->Image[level]->IntFormat = (GLenum) internalformat; - ctx->Texture.Proxy2D->Image[level]->Border = border; - ctx->Texture.Proxy2D->Image[level]->Width = width; - ctx->Texture.Proxy2D->Image[level]->Height = height; - ctx->Texture.Proxy2D->Image[level]->Depth = 1; + /* if no error, update proxy texture image parameters */ + init_texture_image(ctx->Texture.Proxy1D->Image[level], + width, height, 1, border, internalFormat); } } else { @@ -1174,69 +1574,101 @@ _mesa_TexImage2D( GLenum target, GLint level, GLint internalformat, * Note that width and height include the border. */ void -_mesa_TexImage3D( GLenum target, GLint level, GLint internalformat, +_mesa_TexImage3D( GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage3DEXT"); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexImage3D"); if (target==GL_TEXTURE_3D_EXT) { - struct gl_texture_image *teximage; - if (texture_error_check( ctx, target, level, internalformat, - format, type, 3, width, height, depth, - border )) { - /* error in texture image was detected */ - return; + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + if (texture_error_check(ctx, target, level, internalFormat, + format, type, 3, width, height, depth, border)) { + return; /* error in texture image was detected */ } - /* free current texture image, if any */ - if (texUnit->CurrentD[3]->Image[level]) { - gl_free_texture_image( texUnit->CurrentD[3]->Image[level] ); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = texUnit->CurrentD[3]; + texImage = texObj->Image[level]; + + if (!texImage) { + texImage = _mesa_alloc_texture_image(); + texObj->Image[level] = texImage; + if (!texImage) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D"); + return; + } } + else if (texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } + + /* setup the teximage struct's fields */ + init_texture_image(texImage, width, height, depth, + border, internalFormat); - /* make new texture from source image */ + /* process the texture image */ if (pixels) { - teximage = make_texture_image(ctx, internalformat, width, height, - depth, border, format, type, pixels, &ctx->Unpack); + GLboolean retain = GL_TRUE; + GLboolean success = GL_FALSE; + if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA + && ctx->Driver.TexImage3D) { + /* let device driver try to use raw image */ + success = (*ctx->Driver.TexImage3D)( ctx, target, level, format, + type, pixels, &ctx->Unpack, + texObj, texImage, &retain); + } + if (retain || !success) { + /* make internal copy of the texture image */ + make_texture_image(ctx, texImage, format, type, + pixels, &ctx->Unpack); + if (!success && ctx->Driver.TexImage3D) { + /* let device driver try to use unpacked image */ + (*ctx->Driver.TexImage3D)( ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, + texObj, texImage, &retain); + } + } + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } } else { - teximage = make_null_texture(ctx, (GLenum) internalformat, - width, height, depth, border); + make_null_texture(texImage); + if (ctx->Driver.TexImage3D) { + GLboolean retain; + (*ctx->Driver.TexImage3D)( ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, + texObj, texImage, &retain); + } } - /* install new texture image */ - texUnit->CurrentD[3]->Image[level] = teximage; - gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[3] ); + /* state update */ + gl_put_texobj_on_dirty_list( ctx, texObj ); ctx->NewState |= NEW_TEXTURING; - - /* tell driver about change */ - if (ctx->Driver.TexImage) { - (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_3D_EXT, - texUnit->CurrentD[3], - level, internalformat, teximage ); - } } - else if (target==GL_PROXY_TEXTURE_3D_EXT) { + else if (target==GL_PROXY_TEXTURE_3D) { /* Proxy texture: check for errors and update proxy state */ - if (texture_error_check( ctx, target, level, internalformat, - format, type, 3, width, height, depth, - border )) { + if (texture_error_check(ctx, target, level, internalFormat, + format, type, 3, width, height, depth, border)) { + /* if error, clear all proxy texture image parameters */ if (level>=0 && level<ctx->Const.MaxTextureLevels) { MEMSET( ctx->Texture.Proxy3D->Image[level], 0, sizeof(struct gl_texture_image) ); } } else { - ctx->Texture.Proxy3D->Image[level]->Format = (GLenum) format; - set_teximage_component_sizes( ctx->Texture.Proxy3D->Image[level] ); - ctx->Texture.Proxy3D->Image[level]->IntFormat = (GLenum) internalformat; - ctx->Texture.Proxy3D->Image[level]->Border = border; - ctx->Texture.Proxy3D->Image[level]->Width = width; - ctx->Texture.Proxy3D->Image[level]->Height = height; - ctx->Texture.Proxy3D->Image[level]->Depth = depth; + /* if no error, update proxy texture image parameters */ + init_texture_image(ctx->Texture.Proxy1D->Image[level], + width, height, depth, border, internalFormat); } } else { @@ -1247,16 +1679,106 @@ _mesa_TexImage3D( GLenum target, GLint level, GLint internalformat, void -_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalformat, +_mesa_TexImage3DEXT( GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels ) { - _mesa_TexImage3D(target, level, (GLint) internalformat, width, height, + _mesa_TexImage3D(target, level, (GLint) internalFormat, width, height, depth, border, format, type, pixels); } +/* + * Fetch a texture image from the device driver. + * Store the results in the given texture object at the given mipmap level. + */ +void +_mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level, + const struct gl_texture_object *texObj ) +{ + GLvoid *image; + GLenum imgFormat, imgType; + GLboolean freeImage; + struct gl_texture_image *texImage; + GLint destComponents, numPixels, srcBytesPerTexel; + + if (!ctx->Driver.GetTexImage) + return; + + image = (*ctx->Driver.GetTexImage)( ctx, target, level, texObj, + &imgFormat, &imgType, &freeImage); + if (!image) + return; + + texImage = texObj->Image[level]; + ASSERT(texImage); + if (!texImage) + return; + + destComponents = components_in_intformat(texImage->Format); + assert(destComponents > 0); + numPixels = texImage->Width * texImage->Height * texImage->Depth; + assert(numPixels > 0); + srcBytesPerTexel = _mesa_bytes_per_pixel(imgFormat, imgType); + assert(srcBytesPerTexel > 0); + + if (!texImage->Data) { + /* Allocate memory for the texture image data */ + texImage->Data = (GLubyte *) MALLOC(numPixels * destComponents + EXTRA_BYTE); + } + + if (imgFormat == texImage->Format && imgType == GL_UNSIGNED_BYTE) { + /* We got lucky! The driver's format and type match Mesa's format. */ + if (texImage->Data) { + MEMCPY(texImage->Data, image, numPixels * destComponents); + } + } + else { + /* Convert the texture image from the driver's format to Mesa's + * internal format. + */ + const GLint width = texImage->Width; + const GLint height = texImage->Height; + const GLint depth = texImage->Depth; + const GLint destBytesPerRow = width * destComponents * sizeof(GLchan); + const GLint srcBytesPerRow = width * srcBytesPerTexel; + const GLenum dstType = GL_UNSIGNED_BYTE; + const GLenum dstFormat = texImage->Format; + const GLubyte *srcPtr = (const GLubyte *) image; + GLubyte *destPtr = texImage->Data; + + if (texImage->Format == GL_COLOR_INDEX) { + /* color index texture */ + GLint img, row; + assert(imgFormat == GL_COLOR_INDEX); + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + _mesa_unpack_index_span(ctx, width, dstType, destPtr, + imgType, srcPtr, &_mesa_native_packing, GL_FALSE); + destPtr += destBytesPerRow; + srcPtr += srcBytesPerRow; + } + } + } + else { + /* color texture */ + GLint img, row; + for (img = 0; img < depth; img++) { + for (row = 0; row < height; row++) { + _mesa_unpack_ubyte_color_span(ctx, width, dstFormat, destPtr, + imgFormat, imgType, srcPtr, &_mesa_native_packing, GL_FALSE); + destPtr += destBytesPerRow; + srcPtr += srcBytesPerRow; + } + } + } + } + + if (freeImage) + FREE(image); +} + void _mesa_GetTexImage( GLenum target, GLint level, GLenum format, @@ -1264,6 +1786,8 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, { GET_CURRENT_CONTEXT(ctx); const struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLboolean discardImage; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexImage"); @@ -1272,51 +1796,91 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, return; } - if (gl_sizeof_type(type) <= 0) { + if (_mesa_sizeof_type(type) <= 0) { gl_error( ctx, GL_INVALID_ENUM, "glGetTexImage(type)" ); return; } - if (gl_components_in_format(format) <= 0) { + if (_mesa_components_in_format(format) <= 0) { gl_error( ctx, GL_INVALID_ENUM, "glGetTexImage(format)" ); return; } if (!pixels) - return; /* XXX generate an error??? */ + return; switch (target) { case GL_TEXTURE_1D: texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[1]; + texImage = texObj->Image[level]; break; case GL_TEXTURE_2D: texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[2]; + texImage = texObj->Image[level]; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->Image[level]; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->NegX[level]; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->PosY[level]; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->NegY[level]; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->PosZ[level]; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->NegZ[level]; break; case GL_TEXTURE_3D: texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[3]; + texImage = texObj->Image[level]; break; default: gl_error( ctx, GL_INVALID_ENUM, "glGetTexImage(target)" ); return; } - if (texObj->Image[level] && texObj->Image[level]->Data) { - const struct gl_texture_image *texImage = texObj->Image[level]; + if (!texImage) { + /* invalid mipmap level */ + return; + } + + if (!texImage->Data) { + /* try to get the texture image from the device driver */ + _mesa_get_teximage_from_driver(ctx, target, level, texObj); + discardImage = GL_TRUE; + } + else { + discardImage = GL_FALSE; + } + + if (texImage->Data) { GLint width = texImage->Width; GLint height = texImage->Height; GLint row; for (row = 0; row < height; row++) { /* compute destination address in client memory */ - GLvoid *dest = gl_pixel_addr_in_image( &ctx->Unpack, pixels, + GLvoid *dest = _mesa_image_address( &ctx->Unpack, pixels, width, height, format, type, 0, row, 0); assert(dest); if (texImage->Format == GL_RGBA) { const GLubyte *src = texImage->Data + row * width * 4 * sizeof(GLubyte); - gl_pack_rgba_span( ctx, width, (void *) src, format, type, dest, - &ctx->Pack, GL_TRUE ); + _mesa_pack_rgba_span( ctx, width, (CONST GLubyte (*)[4]) src, + format, type, dest, &ctx->Pack, GL_TRUE ); } else { /* fetch RGBA row from texture image then pack it in client mem */ @@ -1379,10 +1943,16 @@ _mesa_GetTexImage( GLenum target, GLint level, GLenum format, default: gl_problem( ctx, "bad format in gl_GetTexImage" ); } - gl_pack_rgba_span( ctx, width, (const GLubyte (*)[4])rgba, - format, type, dest, &ctx->Pack, GL_TRUE ); + _mesa_pack_rgba_span( ctx, width, (const GLubyte (*)[4])rgba, + format, type, dest, &ctx->Pack, GL_TRUE ); } } + + /* if we got the teximage from the device driver we'll discard it now */ + if (discardImage) { + FREE(texImage->Data); + texImage->Data = NULL; + } } } @@ -1395,65 +1965,78 @@ _mesa_TexSubImage1D( GLenum target, GLint level, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_image *destTex; + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLboolean success = GL_FALSE; if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0, width, 1, 1, format, type)) { - /* error was detected */ - return; + return; /* error was detected */ } - destTex = texUnit->CurrentD[1]->Image[level]; - assert(destTex); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = texUnit->CurrentD[1]; + texImage = texObj->Image[level]; + assert(texImage); if (width == 0 || !pixels) return; /* no-op, not an error */ - /* - * Replace the texture subimage - */ - { - const GLint texComponents = components_in_intformat(destTex->Format); - const GLenum texFormat = destTex->Format; - const GLint xoffsetb = xoffset + destTex->Border; - GLubyte *dst = destTex->Data + xoffsetb * texComponents; + if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA + && ctx->Driver.TexSubImage1D) { + success = (*ctx->Driver.TexSubImage1D)( ctx, target, level, xoffset, + width, format, type, pixels, + &ctx->Unpack, texObj, texImage ); + } + if (!success) { + /* XXX if Driver.TexSubImage1D, unpack image and try again? */ + + const GLint texComponents = components_in_intformat(texImage->Format); + const GLenum texFormat = texImage->Format; + const GLint xoffsetb = xoffset + texImage->Border; + GLboolean retain = GL_TRUE; + if (!texImage->Data) { + _mesa_get_teximage_from_driver( ctx, target, level, texObj ); + if (!texImage->Data) { + make_null_texture(texImage); + } + if (!texImage->Data) + return; /* we're really out of luck! */ + } + if (texFormat == GL_COLOR_INDEX) { /* color index texture */ - const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels, - width, 1, format, type, 0, 0, 0); + GLubyte *dst = texImage->Data + xoffsetb * texComponents; + const GLvoid *src = _mesa_image_address(&ctx->Unpack, pixels, width, + 1, format, type, 0, 0, 0); _mesa_unpack_index_span(ctx, width, GL_UNSIGNED_BYTE, dst, - type, src, &ctx->Unpack, GL_TRUE); + type, src, &ctx->Unpack, GL_TRUE); } else { /* color texture */ - const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels, - width, 1, format, type, 0, 0, 0); - _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst, - format, type, src, &ctx->Unpack, GL_TRUE); + GLubyte *dst = texImage->Data + xoffsetb * texComponents; + const GLvoid *src = _mesa_image_address(&ctx->Unpack, pixels, width, + 1, format, type, 0, 0, 0); + _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst, format, + type, src, &ctx->Unpack, GL_TRUE); } - } - gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[1] ); + if (ctx->Driver.TexImage1D) { + (*ctx->Driver.TexImage1D)( ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, texObj, texImage, + &retain ); + } - /* - * Inform device driver of texture image change. - */ - if (ctx->Driver.TexSubImage) { - (*ctx->Driver.TexSubImage)(ctx, GL_TEXTURE_1D, texUnit->CurrentD[1], - level, xoffset, 0, width, 1, - texUnit->CurrentD[1]->Image[level]->IntFormat, - destTex ); - } - else { - if (ctx->Driver.TexImage) { - (*ctx->Driver.TexImage)(ctx, GL_TEXTURE_1D, texUnit->CurrentD[1], - level, - texUnit->CurrentD[1]->Image[level]->IntFormat, - destTex ); + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; } } + + /*gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[1] );*/ } @@ -1465,76 +2048,104 @@ _mesa_TexSubImage2D( GLenum target, GLint level, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_image *destTex; + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLboolean success = GL_FALSE; if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, width, height, 1, format, type)) { - /* error was detected */ - return; + return; /* error was detected */ } - destTex = texUnit->CurrentD[2]->Image[level]; - assert(destTex); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = _mesa_select_tex_object(ctx, texUnit, target); + texImage = texObj->Image[level]; + assert(texImage); if (width == 0 || height == 0 || !pixels) return; /* no-op, not an error */ + if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA + && ctx->Driver.TexSubImage2D) { + success = (*ctx->Driver.TexSubImage2D)( ctx, target, level, xoffset, + yoffset, width, height, format, type, + pixels, &ctx->Unpack, texObj, texImage ); + } + if (!success) { + /* XXX if Driver.TexSubImage2D, unpack image and try again? */ + + const GLint texComponents = components_in_intformat(texImage->Format); + const GLenum texFormat = texImage->Format; + const GLint xoffsetb = xoffset + texImage->Border; + const GLint yoffsetb = yoffset + texImage->Border; + const GLint srcStride = _mesa_image_row_stride(&ctx->Unpack, width, + format, type); + const GLint dstStride = texImage->Width * texComponents *sizeof(GLubyte); + GLboolean retain = GL_TRUE; + + if (!texImage->Data) { + _mesa_get_teximage_from_driver( ctx, target, level, texObj ); + if (!texImage->Data) { + make_null_texture(texImage); + } + if (!texImage->Data) + return; /* we're really out of luck! */ + } - /* - * Replace the texture subimage - */ - { - const GLint texComponents = components_in_intformat(destTex->Format); - const GLenum texFormat = destTex->Format; - const GLint xoffsetb = xoffset + destTex->Border; - const GLint yoffsetb = yoffset + destTex->Border; - GLubyte *dst = destTex->Data - + (yoffsetb * destTex->Width + xoffsetb) * texComponents; if (texFormat == GL_COLOR_INDEX) { /* color index texture */ - const GLint stride = destTex->Width * sizeof(GLubyte); + GLubyte *dst = texImage->Data + + (yoffsetb * texImage->Width + xoffsetb) * texComponents; + const GLubyte *src = _mesa_image_address(&ctx->Unpack, pixels, + width, height, format, type, 0, 0, 0); GLint row; for (row = 0; row < height; row++) { - const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels, - width, height, format, type, 0, row, 0); - _mesa_unpack_index_span(ctx, width, GL_UNSIGNED_BYTE, dst, - type, src, &ctx->Unpack, GL_TRUE); - dst += stride; + _mesa_unpack_index_span(ctx, width, GL_UNSIGNED_BYTE, dst, type, + (const GLvoid *) src, &ctx->Unpack, GL_TRUE); + src += srcStride; + dst += dstStride; } } else { /* color texture */ - const GLint stride = destTex->Width * texComponents * sizeof(GLubyte); + GLubyte *dst = texImage->Data + + (yoffsetb * texImage->Width + xoffsetb) * texComponents; + const GLubyte *src = _mesa_image_address(&ctx->Unpack, pixels, + width, height, format, type, 0, 0, 0); GLint row; for (row = 0; row < height; row++) { - const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels, - width, height, format, type, 0, row, 0); - _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst, - format, type, src, &ctx->Unpack, GL_TRUE); - dst += stride; + _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst, format, + type, (const GLvoid *) src, &ctx->Unpack, GL_TRUE); + src += srcStride; + dst += dstStride; } } - } - gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[2] ); + if (ctx->Driver.TexImage2D) { + (*ctx->Driver.TexImage2D)(ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, texObj, texImage, + &retain); + } - /* - * Inform device driver of texture image change. - */ - if (ctx->Driver.TexSubImage) { - (*ctx->Driver.TexSubImage)(ctx, GL_TEXTURE_2D, texUnit->CurrentD[2], - level, xoffset, yoffset, width, height, - texUnit->CurrentD[2]->Image[level]->IntFormat, - destTex ); - } - else { - if (ctx->Driver.TexImage) { - (*ctx->Driver.TexImage)(ctx, GL_TEXTURE_2D, texUnit->CurrentD[2], - level, - texUnit->CurrentD[2]->Image[level]->IntFormat, - destTex ); + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } + +#ifdef OLD_DD_TEXTURE + /* XXX this will be removed in the future */ + if (ctx->Driver.TexSubImage) { + (*ctx->Driver.TexSubImage)(ctx, target, texObj, level, + xoffset, yoffset, width, height, + texImage->IntFormat, texImage); } + else if (ctx->Driver.TexImage) { + (*ctx->Driver.TexImage)(ctx, GL_TEXTURE_2D, texObj, + level, texImage->IntFormat, texImage ); + } +#endif } } @@ -1548,71 +2159,90 @@ _mesa_TexSubImage3D( GLenum target, GLint level, const GLvoid *pixels ) { GET_CURRENT_CONTEXT(ctx); - struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; - struct gl_texture_image *destTex; + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLboolean success = GL_FALSE; if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset, width, height, depth, format, type)) { - /* error was detected */ - return; + return; /* error was detected */ } - destTex = texUnit->CurrentD[3]->Image[level]; - assert(destTex); + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = texUnit->CurrentD[3]; + texImage = texObj->Image[level]; + assert(texImage); if (width == 0 || height == 0 || height == 0 || !pixels) return; /* no-op, not an error */ - /* - * Replace the texture subimage - */ - { - const GLint texComponents = components_in_intformat(destTex->Format); - const GLenum texFormat = destTex->Format; - const GLint xoffsetb = xoffset + destTex->Border; - const GLint yoffsetb = yoffset + destTex->Border; - const GLint zoffsetb = zoffset + destTex->Border; - GLint dstRectArea = destTex->Width * destTex->Height; - GLubyte *dst = destTex->Data - + (zoffsetb * dstRectArea + yoffsetb * destTex->Width + xoffsetb) - * texComponents; + if (!ctx->Pixel.MapColorFlag && !ctx->Pixel.ScaleOrBiasRGBA + && ctx->Driver.TexSubImage3D) { + success = (*ctx->Driver.TexSubImage3D)( ctx, target, level, xoffset, + yoffset, zoffset, width, height, depth, format, + type, pixels, &ctx->Unpack, texObj, texImage ); + } + if (!success) { + /* XXX if Driver.TexSubImage3D, unpack image and try again? */ + + const GLint texComponents = components_in_intformat(texImage->Format); + const GLenum texFormat = texImage->Format; + const GLint xoffsetb = xoffset + texImage->Border; + const GLint yoffsetb = yoffset + texImage->Border; + const GLint zoffsetb = zoffset + texImage->Border; + const GLint texWidth = texImage->Width; + const GLint dstRectArea = texWidth * texImage->Height; + const GLint srcStride = _mesa_image_row_stride(&ctx->Unpack, + width, format, type); + const GLint dstStride = texWidth * texComponents * sizeof(GLubyte); + GLboolean retain = GL_TRUE; if (texFormat == GL_COLOR_INDEX) { /* color index texture */ - const GLint stride = destTex->Width * sizeof(GLubyte); GLint img, row; for (img = 0; img < depth; img++) { + const GLubyte *src = _mesa_image_address(&ctx->Unpack, pixels, + width, height, format, type, img, 0, 0); + GLubyte *dst = texImage->Data + ((zoffsetb + img) * dstRectArea + + yoffsetb * texWidth + xoffsetb) * texComponents; for (row = 0; row < height; row++) { - const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels, - width, height, format, type, img, row, 0); _mesa_unpack_index_span(ctx, width, GL_UNSIGNED_BYTE, dst, - type, src, &ctx->Unpack, GL_TRUE); - dst += stride; + type, (const GLvoid *) src, &ctx->Unpack, GL_TRUE); + src += srcStride; + dst += dstStride; } } } else { /* color texture */ - const GLint stride = destTex->Width * texComponents * sizeof(GLubyte); GLint img, row; for (img = 0; img < depth; img++) { + const GLubyte *src = _mesa_image_address(&ctx->Unpack, pixels, + width, height, format, type, img, 0, 0); + GLubyte *dst = texImage->Data + ((zoffsetb + img) * dstRectArea + + yoffsetb * texWidth + xoffsetb) * texComponents; for (row = 0; row < height; row++) { - const GLvoid *src = gl_pixel_addr_in_image(&ctx->Unpack, pixels, - width, height, format, type, img, row, 0); _mesa_unpack_ubyte_color_span(ctx, width, texFormat, dst, - format, type, src, &ctx->Unpack, GL_TRUE); - dst += stride; + format, type, (const GLvoid *) src, &ctx->Unpack, GL_TRUE); + src += srcStride; + dst += dstStride; } } } - } - gl_put_texobj_on_dirty_list( ctx, texUnit->CurrentD[1] ); + if (ctx->Driver.TexImage3D) { + (*ctx->Driver.TexImage3D)(ctx, target, level, texImage->Format, + GL_UNSIGNED_BYTE, texImage->Data, + &_mesa_native_packing, texObj, texImage, + &retain); + } - /* - * Inform device driver of texture image change. - */ - /* XXX todo */ + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } + } } @@ -1632,7 +2262,7 @@ read_color_image( GLcontext *ctx, GLint x, GLint y, GLint stride, i; GLubyte *image, *dst; - image = MALLOC(width * height * 4 * sizeof(GLubyte)); + image = (GLubyte *) MALLOC(width * height * 4 * sizeof(GLubyte)); if (!image) return NULL; @@ -1666,15 +2296,22 @@ _mesa_CopyTexImage1D( GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexImage1D"); - if (!copytexture_error_check(ctx, 1, target, level, internalFormat, - width, 1, border)) { + if (copytexture_error_check(ctx, 1, target, level, internalFormat, + width, 1, border)) + return; + + if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA + || !ctx->Driver.CopyTexImage1D + || !(*ctx->Driver.CopyTexImage1D)(ctx, target, level, + internalFormat, x, y, width, border)) + { GLubyte *image = read_color_image( ctx, x, y, width, 1 ); if (!image) { gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage1D" ); return; } (*ctx->Exec->TexImage1D)( target, level, internalFormat, width, - border, GL_RGBA, GL_UNSIGNED_BYTE, image ); + border, GL_RGBA, GL_UNSIGNED_BYTE, image ); FREE(image); } } @@ -1689,15 +2326,22 @@ _mesa_CopyTexImage2D( GLenum target, GLint level, GLenum internalFormat, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexImage2D"); - if (!copytexture_error_check(ctx, 2, target, level, internalFormat, - width, height, border)) { + if (copytexture_error_check(ctx, 2, target, level, internalFormat, + width, height, border)) + return; + + if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA + || !ctx->Driver.CopyTexImage2D + || !(*ctx->Driver.CopyTexImage2D)(ctx, target, level, + internalFormat, x, y, width, height, border)) + { GLubyte *image = read_color_image( ctx, x, y, width, height ); if (!image) { gl_error( ctx, GL_OUT_OF_MEMORY, "glCopyTexImage2D" ); return; } (ctx->Exec->TexImage2D)( target, level, internalFormat, width, - height, border, GL_RGBA, GL_UNSIGNED_BYTE, image ); + height, border, GL_RGBA, GL_UNSIGNED_BYTE, image ); FREE(image); } } @@ -1713,17 +2357,6 @@ copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest, GLint srcx, GLint srcy, GLint dstx, GLint dsty, GLint dstz ) { - static struct gl_pixelstore_attrib packing = { - 1, /* Alignment */ - 0, /* RowLength */ - 0, /* SkipPixels */ - 0, /* SkipRows */ - 0, /* ImageHeight */ - 0, /* SkipImages */ - GL_FALSE, /* SwapBytes */ - GL_FALSE /* LsbFirst */ - }; - GLint i; GLint format, components, rectarea; GLint texwidth, texheight, zoffset; @@ -1750,7 +2383,7 @@ copy_tex_sub_image( GLcontext *ctx, struct gl_texture_image *dest, dst = dest->Data + ( zoffset + (dsty+i) * texwidth + dstx) * components; _mesa_unpack_ubyte_color_span(ctx, width, format, dst, GL_RGBA, GL_UNSIGNED_BYTE, rgba, - &packing, GL_TRUE); + &_mesa_native_packing, GL_TRUE); } /* Read from draw buffer (the default) */ @@ -1768,8 +2401,14 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage1D"); - if (!copytexsubimage_error_check(ctx, 1, target, level, - xoffset, 0, 0, width, 1)) { + if (copytexsubimage_error_check(ctx, 1, target, level, + xoffset, 0, 0, width, 1)) + return; + + if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA + || !ctx->Driver.CopyTexSubImage1D + || !(*ctx->Driver.CopyTexSubImage1D)(ctx, target, level, + xoffset, x, y, width)) { struct gl_texture_unit *texUnit; struct gl_texture_image *teximage; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; @@ -1777,12 +2416,13 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level, assert(teximage); if (teximage->Data) { copy_tex_sub_image(ctx, teximage, width, 1, x, y, xoffset, 0, 0); - /* tell driver about the change */ - if (ctx->Driver.TexImage) { - (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D, - texUnit->CurrentD[1], - level, teximage->IntFormat, teximage ); - } + /* tell driver about the change */ + /* XXX this is obsolete */ + if (ctx->Driver.TexImage) { + (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_1D, + texUnit->CurrentD[1], + level, teximage->IntFormat, teximage ); + } } } } @@ -1797,8 +2437,14 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage2D"); - if (!copytexsubimage_error_check(ctx, 2, target, level, - xoffset, yoffset, 0, width, height)) { + if (copytexsubimage_error_check(ctx, 2, target, level, + xoffset, yoffset, 0, width, height)) + return; + + if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA + || !ctx->Driver.CopyTexSubImage2D + || !(*ctx->Driver.CopyTexSubImage2D)(ctx, target, level, + xoffset, yoffset, x, y, width, height )) { struct gl_texture_unit *texUnit; struct gl_texture_image *teximage; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; @@ -1807,11 +2453,12 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level, if (teximage->Data) { copy_tex_sub_image(ctx, teximage, width, height, x, y, xoffset, yoffset, 0); - /* tell driver about the change */ - if (ctx->Driver.TexImage) { - (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D, - texUnit->CurrentD[2], - level, teximage->IntFormat, teximage ); + /* tell driver about the change */ + /* XXX this is obsolete */ + if (ctx->Driver.TexImage) { + (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_2D, + texUnit->CurrentD[2], + level, teximage->IntFormat, teximage ); } } } @@ -1827,8 +2474,14 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCopyTexSubImage3D"); - if (!copytexsubimage_error_check(ctx, 3, target, level, - xoffset, yoffset, zoffset, width, height)) { + if (copytexsubimage_error_check(ctx, 3, target, level, + xoffset, yoffset, zoffset, width, height)) + return; + + if (ctx->Pixel.MapColorFlag || ctx->Pixel.ScaleOrBiasRGBA + || !ctx->Driver.CopyTexSubImage3D + || !(*ctx->Driver.CopyTexSubImage3D)(ctx, target, level, + xoffset, yoffset, zoffset, x, y, width, height )) { struct gl_texture_unit *texUnit; struct gl_texture_image *teximage; texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; @@ -1837,13 +2490,501 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, if (teximage->Data) { copy_tex_sub_image(ctx, teximage, width, height, x, y, xoffset, yoffset, zoffset); - /* tell driver about the change */ - if (ctx->Driver.TexImage) { - (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_3D, - texUnit->CurrentD[3], - level, teximage->IntFormat, teximage ); - } + /* tell driver about the change */ + /* XXX this is obsolete */ + if (ctx->Driver.TexImage) { + (*ctx->Driver.TexImage)( ctx, GL_TEXTURE_3D, + texUnit->CurrentD[3], + level, teximage->IntFormat, teximage ); + } + } + } +} + + + +void +_mesa_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage1DARB"); + + if (target == GL_TEXTURE_1D) { + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (texture_error_check(ctx, target, level, internalFormat, + GL_NONE, GL_NONE, 1, width, 1, 1, border)) { + return; /* error in texture image was detected */ + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = texUnit->CurrentD[1]; + texImage = texObj->Image[level]; + + if (!texImage) { + texImage = _mesa_alloc_texture_image(); + texObj->Image[level] = texImage; + if (!texImage) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage1DARB"); + return; + } + } + else if (texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } + + /* setup the teximage struct's fields */ + init_texture_image(texImage, width, 1, 1, border, internalFormat); + + /* process the texture image */ + if (data) { + GLboolean retain = GL_TRUE; + GLboolean success = GL_FALSE; + if (ctx->Driver.CompressedTexImage1D) { + success = (*ctx->Driver.CompressedTexImage1D)( ctx, target, level, + data, texObj, texImage, &retain); + } + if (retain || !success) { + /* make internal copy of the texture image */ + GLuint imageSize = _mesa_compressed_image_size(internalFormat, + width, 1, 1); + texImage->Data = MALLOC(imageSize); + if (texImage->Data) { + MEMCPY(texImage->Data, data, imageSize); + } + } + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } + } + else { + make_null_texture(texImage); + if (ctx->Driver.CompressedTexImage1D) { + GLboolean retain; + (*ctx->Driver.CompressedTexImage1D)( ctx, target, level, + texImage->Data, texObj, texImage, &retain); + } + } + + /* state update */ + gl_put_texobj_on_dirty_list( ctx, texObj ); + ctx->NewState |= NEW_TEXTURING; + } + else if (target == GL_PROXY_TEXTURE_1D) { + /* Proxy texture: check for errors and update proxy state */ + if (texture_error_check(ctx, target, level, internalFormat, + GL_NONE, GL_NONE, 1, width, 1, 1, border)) { + /* if error, clear all proxy texture image parameters */ + if (level>=0 && level<ctx->Const.MaxTextureLevels) { + MEMSET( ctx->Texture.Proxy1D->Image[level], 0, + sizeof(struct gl_texture_image) ); + } + } + else { + /* if no error, update proxy texture image parameters */ + init_texture_image(ctx->Texture.Proxy1D->Image[level], + width, 1, 1, border, internalFormat); + } + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage1DARB(target)" ); + return; + } +} + + +void +_mesa_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage2DARB"); + + if (target==GL_TEXTURE_2D || + (ctx->Extensions.HaveTextureCubeMap && + target >= GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB && + target <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB)) { + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (texture_error_check(ctx, target, level, internalFormat, + GL_NONE, GL_NONE, 1, width, height, 1, border)) { + return; /* error in texture image was detected */ + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = texUnit->CurrentD[2]; + texImage = texObj->Image[level]; + + if (!texImage) { + texImage = _mesa_alloc_texture_image(); + texObj->Image[level] = texImage; + if (!texImage) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage2DARB"); + return; + } + } + else if (texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } + + /* setup the teximage struct's fields */ + init_texture_image(texImage, width, height, 1, border, internalFormat); + + /* process the texture image */ + if (data) { + GLboolean retain = GL_TRUE; + GLboolean success = GL_FALSE; + if (ctx->Driver.CompressedTexImage2D) { + success = (*ctx->Driver.CompressedTexImage2D)( ctx, target, level, + data, texObj, texImage, &retain); + } + if (retain || !success) { + /* make internal copy of the texture image */ + GLuint imageSize = _mesa_compressed_image_size(internalFormat, + width, height, 1); + texImage->Data = MALLOC(imageSize); + if (texImage->Data) { + MEMCPY(texImage->Data, data, imageSize); + } + } + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } } + else { + make_null_texture(texImage); + if (ctx->Driver.CompressedTexImage2D) { + GLboolean retain; + (*ctx->Driver.CompressedTexImage2D)( ctx, target, level, + texImage->Data, texObj, texImage, &retain); + } + } + + /* state update */ + gl_put_texobj_on_dirty_list( ctx, texObj ); + ctx->NewState |= NEW_TEXTURING; + } + else if (target == GL_PROXY_TEXTURE_2D) { + /* Proxy texture: check for errors and update proxy state */ + if (texture_error_check(ctx, target, level, internalFormat, + GL_NONE, GL_NONE, 1, width, 1, 1, border)) { + /* if error, clear all proxy texture image parameters */ + if (level>=0 && level<ctx->Const.MaxTextureLevels) { + MEMSET( ctx->Texture.Proxy2D->Image[level], 0, + sizeof(struct gl_texture_image) ); + } + } + else { + /* if no error, update proxy texture image parameters */ + init_texture_image(ctx->Texture.Proxy2D->Image[level], + width, 1, 1, border, internalFormat); + } + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage2DARB(target)" ); + return; } } + +void +_mesa_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalFormat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glCompressedTexImage3DARB"); + + if (target == GL_TEXTURE_3D) { + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + if (texture_error_check(ctx, target, level, internalFormat, + GL_NONE, GL_NONE, 1, width, height, depth, border)) { + return; /* error in texture image was detected */ + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = texUnit->CurrentD[3]; + texImage = texObj->Image[level]; + + if (!texImage) { + texImage = _mesa_alloc_texture_image(); + texObj->Image[level] = texImage; + if (!texImage) { + gl_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexImage3DARB"); + return; + } + } + else if (texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } + + /* setup the teximage struct's fields */ + init_texture_image(texImage, width, height, depth, border, internalFormat); + + /* process the texture image */ + if (data) { + GLboolean retain = GL_TRUE; + GLboolean success = GL_FALSE; + if (ctx->Driver.CompressedTexImage3D) { + success = (*ctx->Driver.CompressedTexImage3D)( ctx, target, level, + data, texObj, texImage, &retain); + } + if (retain || !success) { + /* make internal copy of the texture image */ + GLuint imageSize = _mesa_compressed_image_size(internalFormat, + width, height, depth); + texImage->Data = MALLOC(imageSize); + if (texImage->Data) { + MEMCPY(texImage->Data, data, imageSize); + } + } + if (!retain && texImage->Data) { + FREE(texImage->Data); + texImage->Data = NULL; + } + } + else { + make_null_texture(texImage); + if (ctx->Driver.CompressedTexImage3D) { + GLboolean retain; + (*ctx->Driver.CompressedTexImage3D)( ctx, target, level, + texImage->Data, texObj, texImage, &retain); + } + } + + /* state update */ + gl_put_texobj_on_dirty_list( ctx, texObj ); + ctx->NewState |= NEW_TEXTURING; + } + else if (target == GL_PROXY_TEXTURE_3D) { + /* Proxy texture: check for errors and update proxy state */ + if (texture_error_check(ctx, target, level, internalFormat, + GL_NONE, GL_NONE, 1, width, height, depth, border)) { + /* if error, clear all proxy texture image parameters */ + if (level>=0 && level<ctx->Const.MaxTextureLevels) { + MEMSET( ctx->Texture.Proxy3D->Image[level], 0, + sizeof(struct gl_texture_image) ); + } + } + else { + /* if no error, update proxy texture image parameters */ + init_texture_image(ctx->Texture.Proxy3D->Image[level], + width, 1, 1, border, internalFormat); + } + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glCompressedTexImage3DARB(target)" ); + return; + } +} + + +void +_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLboolean success = GL_FALSE; + + if (subtexture_error_check(ctx, 1, target, level, xoffset, 0, 0, + width, 1, 1, format, GL_NONE)) { + return; /* error was detected */ + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = _mesa_select_tex_object(ctx, texUnit, target); + texImage = texObj->Image[level]; + assert(texImage); + + if (width == 0 || !data) + return; /* no-op, not an error */ + + if (ctx->Driver.CompressedTexSubImage1D) { + success = (*ctx->Driver.CompressedTexSubImage1D)(ctx, target, level, + xoffset, width, format, imageSize, data, texObj, texImage); + } + if (!success) { + /* XXX what else can we do? */ + gl_problem(ctx, "glCompressedTexSubImage1DARB failed!"); + return; + } + +} + + +void +_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLboolean success = GL_FALSE; + + if (subtexture_error_check(ctx, 2, target, level, xoffset, yoffset, 0, + width, height, 1, format, GL_NONE)) { + return; /* error was detected */ + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = _mesa_select_tex_object(ctx, texUnit, target); + texImage = texObj->Image[level]; + assert(texImage); + + if (width == 0 || height == 0 || !data) + return; /* no-op, not an error */ + + if (ctx->Driver.CompressedTexSubImage2D) { + success = (*ctx->Driver.CompressedTexSubImage2D)(ctx, target, level, + xoffset, yoffset, width, height, format, + imageSize, data, texObj, texImage); + } + if (!success) { + /* XXX what else can we do? */ + gl_problem(ctx, "glCompressedTexSubImage2DARB failed!"); + return; + } +} + + +void +_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid *data) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_texture_unit *texUnit; + struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + GLboolean success = GL_FALSE; + + if (subtexture_error_check(ctx, 3, target, level, xoffset, yoffset, zoffset, + width, height, depth, format, GL_NONE)) { + return; /* error was detected */ + } + + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + texObj = _mesa_select_tex_object(ctx, texUnit, target); + texImage = texObj->Image[level]; + assert(texImage); + + if (width == 0 || height == 0 || depth == 0 || !data) + return; /* no-op, not an error */ + + if (ctx->Driver.CompressedTexSubImage3D) { + success = (*ctx->Driver.CompressedTexSubImage3D)(ctx, target, level, + xoffset, yoffset, zoffset, width, height, depth, + format, imageSize, data, texObj, texImage); + } + if (!success) { + /* XXX what else can we do? */ + gl_problem(ctx, "glCompressedTexSubImage3DARB failed!"); + return; + } +} + + +void +_mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img) +{ + GET_CURRENT_CONTEXT(ctx); + const struct gl_texture_object *texObj; + struct gl_texture_image *texImage; + + ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetCompressedTexImageARB"); + + if (level < 0 || level >= ctx->Const.MaxTextureLevels) { + gl_error( ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)" ); + return; + } + + switch (target) { + case GL_TEXTURE_1D: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[1]; + texImage = texObj->Image[level]; + break; + case GL_TEXTURE_2D: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[2]; + texImage = texObj->Image[level]; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->Image[level]; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->NegX[level]; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->PosY[level]; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->NegY[level]; + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->PosZ[level]; + break; + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentCubeMap; + texImage = texObj->NegZ[level]; + break; + case GL_TEXTURE_3D: + texObj = ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentD[3]; + texImage = texObj->Image[level]; + break; + default: + gl_error(ctx, GL_INVALID_ENUM, "glGetCompressedTexImageARB(target)"); + return; + } + + if (!texImage) { + /* invalid mipmap level */ + gl_error(ctx, GL_INVALID_VALUE, "glGetCompressedTexImageARB(level)"); + return; + } + + if (!texImage->IsCompressed) { + gl_error(ctx, GL_INVALID_OPERATION, "glGetCompressedTexImageARB"); + return; + } + + if (!img) + return; + + if (ctx->Driver.GetCompressedTexImage) { + (*ctx->Driver.GetCompressedTexImage)(ctx, target, level, img, texObj, + texImage); + } + else { + gl_problem(ctx, "Driver doesn't implement GetCompressedTexImage"); + } +} diff --git a/xc/extras/Mesa/src/teximage.h b/xc/extras/Mesa/src/teximage.h index 167708d26..606bac31c 100644 --- a/xc/extras/Mesa/src/teximage.h +++ b/xc/extras/Mesa/src/teximage.h @@ -34,14 +34,37 @@ /*** Internal functions ***/ +extern GLint +_mesa_base_tex_format( GLcontext *ctx, GLint format ); + + extern struct gl_texture_image * -gl_alloc_texture_image( void ); +_mesa_alloc_texture_image( void ); extern void -gl_free_texture_image( struct gl_texture_image *teximage ); +_mesa_free_texture_image( struct gl_texture_image *teximage ); + + +extern GLuint +_mesa_compressed_image_size(GLenum internalFormat, + GLint width, GLint height, GLint depth); +extern struct gl_texture_object * +_mesa_select_tex_object(GLcontext *ctx, struct gl_texture_unit *texUnit, + GLenum target); + + +extern struct gl_texture_image * +_mesa_select_tex_image(GLcontext *ctx, const struct gl_texture_unit *texUnit, + GLenum target, GLint level); + + +extern void +_mesa_get_teximage_from_driver( GLcontext *ctx, GLenum target, GLint level, + const struct gl_texture_object *texObj ); + /*** API entry point functions ***/ @@ -126,5 +149,47 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height ); + + +extern void +_mesa_CompressedTexImage1DARB(GLenum target, GLint level, + GLenum internalformat, GLsizei width, + GLint border, GLsizei imageSize, + const GLvoid *data); + +extern void +_mesa_CompressedTexImage2DARB(GLenum target, GLint level, + GLenum internalformat, GLsizei width, + GLsizei height, GLint border, GLsizei imageSize, + const GLvoid *data); + +extern void +_mesa_CompressedTexImage3DARB(GLenum target, GLint level, + GLenum internalformat, GLsizei width, + GLsizei height, GLsizei depth, GLint border, + GLsizei imageSize, const GLvoid *data); + + +extern void +_mesa_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset, + GLsizei width, GLenum format, + GLsizei imageSize, const GLvoid *data); + +extern void +_mesa_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, + const GLvoid *data); + +extern void +_mesa_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset, + GLint yoffset, GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, GLenum format, + GLsizei imageSize, const GLvoid *data); + +extern void +_mesa_GetCompressedTexImageARB(GLenum target, GLint lod, GLvoid *img); + + #endif diff --git a/xc/extras/Mesa/src/texobj.c b/xc/extras/Mesa/src/texobj.c index e30032376..91876bf5b 100644 --- a/xc/extras/Mesa/src/texobj.c +++ b/xc/extras/Mesa/src/texobj.c @@ -28,6 +28,7 @@ #include "all.h" #else #include "glheader.h" +#include "colortab.h" #include "context.h" #include "enums.h" #include "hash.h" @@ -46,7 +47,7 @@ * table. * Input: shared - the shared GL state structure to contain the texture object * name - integer name for the texture object - * dimensions - either 1, 2 or 3 + * dimensions - either 1, 2, 3 or 6 (cube map) * Return: pointer to new texture object */ struct gl_texture_object * @@ -55,7 +56,7 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, { struct gl_texture_object *obj; - ASSERT(dimensions <= 3); + ASSERT(dimensions <= 3 || dimensions == 6); obj = CALLOC_STRUCT(gl_texture_object); @@ -73,13 +74,7 @@ gl_alloc_texture_object( struct gl_shared_state *shared, GLuint name, obj->BaseLevel = 0; obj->MaxLevel = 1000; obj->MinMagThresh = 0.0F; - obj->Palette.Table[0] = 255; - obj->Palette.Table[1] = 255; - obj->Palette.Table[2] = 255; - obj->Palette.Table[3] = 255; - obj->Palette.Size = 1; - obj->Palette.IntFormat = GL_RGBA; - obj->Palette.Format = GL_RGBA; + _mesa_init_colortable(&obj->Palette); /* insert into linked list */ if (shared) { @@ -143,12 +138,14 @@ void gl_free_texture_object( struct gl_shared_state *shared, _mesa_HashRemove(shared->TexObjects, t->Name); } - /* free texture image */ + _mesa_free_colortable_data(&t->Palette); + + /* free texture images */ { GLuint i; for (i=0;i<MAX_TEXTURE_LEVELS;i++) { if (t->Image[i]) { - gl_free_texture_image( t->Image[i] ); + _mesa_free_texture_image( t->Image[i] ); } } } @@ -162,24 +159,26 @@ void gl_free_texture_object( struct gl_shared_state *shared, * Examine a texture object to determine if it is complete or not. * The t->Complete flag will be set to GL_TRUE or GL_FALSE accordingly. */ -void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_texture_object *t ) +void +_mesa_test_texobj_completeness( const GLcontext *ctx, + struct gl_texture_object *t ) { t->Complete = GL_TRUE; /* be optimistic */ /* Always need level zero image */ - if (!t->Image[0] || !t->Image[0]->Data) { + if (!t->Image[0]) { t->Complete = GL_FALSE; return; } /* Compute number of mipmap levels */ - if (t->Dimensions==1) { + if (t->Dimensions == 1) { t->P = t->Image[0]->WidthLog2; } - else if (t->Dimensions==2) { + else if (t->Dimensions == 2 || t->Dimensions == 6) { t->P = MAX2(t->Image[0]->WidthLog2, t->Image[0]->HeightLog2); } - else if (t->Dimensions==3) { + else if (t->Dimensions == 3) { GLint max = MAX2(t->Image[0]->WidthLog2, t->Image[0]->HeightLog2); max = MAX2(max, (GLint)(t->Image[0]->DepthLog2)); t->P = max; @@ -189,7 +188,21 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur t->M = (GLfloat) (MIN2(t->MaxLevel, t->P) - t->BaseLevel); - if (t->MinFilter!=GL_NEAREST && t->MinFilter!=GL_LINEAR) { + if (t->Dimensions == 6) { + /* make sure all six level 0 images are same size */ + const GLint w = t->Image[0]->Width2; + const GLint h = t->Image[0]->Height2; + if (!t->NegX[0] || t->NegX[0]->Width2 != w || t->NegX[0]->Height2 != h || + !t->PosY[0] || t->PosY[0]->Width2 != w || t->PosY[0]->Height2 != h || + !t->NegY[0] || t->NegY[0]->Width2 != w || t->NegY[0]->Height2 != h || + !t->PosZ[0] || t->PosZ[0]->Width2 != w || t->PosZ[0]->Height2 != h || + !t->NegZ[0] || t->NegZ[0]->Width2 != w || t->NegZ[0]->Height2 != h) { + t->Complete = GL_FALSE; + return; + } + } + + if (t->MinFilter != GL_NEAREST && t->MinFilter != GL_LINEAR) { /* * Mipmapping: determine if we have a complete set of mipmaps */ @@ -206,10 +219,6 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur /* Test dimension-independent attributes */ for (i = minLevel; i <= maxLevel; i++) { if (t->Image[i]) { - if (!t->Image[i]->Data) { - t->Complete = GL_FALSE; - return; - } if (t->Image[i]->Format != t->Image[0]->Format) { t->Complete = GL_FALSE; return; @@ -222,11 +231,11 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur } /* Test things which depend on number of texture image dimensions */ - if (t->Dimensions==1) { + if (t->Dimensions == 1) { /* Test 1-D mipmaps */ GLuint width = t->Image[0]->Width2; - for (i=1; i<ctx->Const.MaxTextureLevels; i++) { - if (width>1) { + for (i = 1; i < ctx->Const.MaxTextureLevels; i++) { + if (width > 1) { width /= 2; } if (i >= minLevel && i <= maxLevel) { @@ -234,29 +243,25 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur t->Complete = GL_FALSE; return; } - if (!t->Image[i]->Data) { - t->Complete = GL_FALSE; - return; - } if (t->Image[i]->Width2 != width ) { t->Complete = GL_FALSE; return; } } - if (width==1) { + if (width == 1) { return; /* found smallest needed mipmap, all done! */ } } } - else if (t->Dimensions==2) { + else if (t->Dimensions == 2) { /* Test 2-D mipmaps */ GLuint width = t->Image[0]->Width2; GLuint height = t->Image[0]->Height2; - for (i=1; i<ctx->Const.MaxTextureLevels; i++) { - if (width>1) { + for (i = 1; i < ctx->Const.MaxTextureLevels; i++) { + if (width > 1) { width /= 2; } - if (height>1) { + if (height > 1) { height /= 2; } if (i >= minLevel && i <= maxLevel) { @@ -278,19 +283,19 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur } } } - else if (t->Dimensions==3) { + else if (t->Dimensions == 3) { /* Test 3-D mipmaps */ GLuint width = t->Image[0]->Width2; GLuint height = t->Image[0]->Height2; GLuint depth = t->Image[0]->Depth2; - for (i=1; i<ctx->Const.MaxTextureLevels; i++) { - if (width>1) { + for (i = 1; i < ctx->Const.MaxTextureLevels; i++) { + if (width > 1) { width /= 2; } - if (height>1) { + if (height > 1) { height /= 2; } - if (depth>1) { + if (depth > 1) { depth /= 2; } if (i >= minLevel && i <= maxLevel) { @@ -311,7 +316,41 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur return; } } - if (width==1 && height==1 && depth==1) { + if (width == 1 && height == 1 && depth == 1) { + return; /* found smallest needed mipmap, all done! */ + } + } + } + else if (t->Dimensions == 6) { + /* make sure 6 cube faces are consistant */ + GLuint width = t->Image[0]->Width2; + GLuint height = t->Image[0]->Height2; + for (i = 1; i < ctx->Const.MaxTextureLevels; i++) { + if (width > 1) { + width /= 2; + } + if (height > 1) { + height /= 2; + } + if (i >= minLevel && i <= maxLevel) { + /* check that we have images defined */ + if (!t->Image[i] || !t->NegX[i] || + !t->PosY[i] || !t->NegY[i] || + !t->PosZ[i] || !t->NegZ[i]) { + t->Complete = GL_FALSE; + return; + } + /* check that all six images have same size */ + if (t->NegX[i]->Width2!=width || t->NegX[i]->Height2!=height || + t->PosY[i]->Width2!=width || t->PosY[i]->Height2!=height || + t->NegY[i]->Width2!=width || t->NegY[i]->Height2!=height || + t->PosZ[i]->Width2!=width || t->PosZ[i]->Height2!=height || + t->NegZ[i]->Width2!=width || t->NegZ[i]->Height2!=height) { + t->Complete = GL_FALSE; + return; + } + } + if (width == 1 && height == 1) { return; /* found smallest needed mipmap, all done! */ } } @@ -324,6 +363,8 @@ void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_textur } +_glthread_DECLARE_STATIC_MUTEX(GenTexturesLock); + /* * Execute glGenTextures @@ -341,6 +382,12 @@ _mesa_GenTextures( GLsizei n, GLuint *texName ) return; } + + /* + * This must be atomic (generation and allocation of texture IDs) + */ + _glthread_LOCK_MUTEX(GenTexturesLock); + first = _mesa_HashFindFreeKeyBlock(ctx->Shared->TexObjects, n); /* Return the texture names */ @@ -354,6 +401,8 @@ _mesa_GenTextures( GLsizei n, GLuint *texName ) GLuint dims = 0; (void) gl_alloc_texture_object(ctx->Shared, name, dims); } + + _glthread_UNLOCK_MUTEX(GenTexturesLock); } @@ -429,25 +478,37 @@ _mesa_BindTexture( GLenum target, GLuint texName ) switch (target) { case GL_TEXTURE_1D: dim = 1; + oldTexObj = texUnit->CurrentD[1]; break; case GL_TEXTURE_2D: dim = 2; + oldTexObj = texUnit->CurrentD[2]; break; case GL_TEXTURE_3D: dim = 3; + oldTexObj = texUnit->CurrentD[3]; break; + case GL_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) { + dim = 6; + oldTexObj = texUnit->CurrentCubeMap; + break; + } + /* fallthrough */ default: gl_error( ctx, GL_INVALID_ENUM, "glBindTexture(target)" ); return; } - oldTexObj = texUnit->CurrentD[dim]; - if (oldTexObj->Name == texName) return; - if (texName == 0) - newTexObj = ctx->Shared->DefaultD[dim]; + if (texName == 0) { + if (target == GL_TEXTURE_CUBE_MAP_ARB) + newTexObj = ctx->Shared->DefaultCubeMap; + else + newTexObj = ctx->Shared->DefaultD[dim]; + } else { struct _mesa_HashTable *hash = ctx->Shared->TexObjects; newTexObj = (struct gl_texture_object *) _mesa_HashLookup(hash, texName); @@ -467,7 +528,22 @@ _mesa_BindTexture( GLenum target, GLuint texName ) newTexObj->RefCount++; - texUnit->CurrentD[dim] = newTexObj; + switch (target) { + case GL_TEXTURE_1D: + texUnit->CurrentD[1] = newTexObj; + break; + case GL_TEXTURE_2D: + texUnit->CurrentD[2] = newTexObj; + break; + case GL_TEXTURE_3D: + texUnit->CurrentD[3] = newTexObj; + break; + case GL_TEXTURE_CUBE_MAP_ARB: + texUnit->CurrentCubeMap = newTexObj; + break; + default: + gl_problem(ctx, "bad target in BindTexture"); + } /* If we've changed the CurrentD[123] texture object then update the * ctx->Texture.Current pointer to point to the new texture object. diff --git a/xc/extras/Mesa/src/texobj.h b/xc/extras/Mesa/src/texobj.h index 5c578e9d0..c83c6144c 100644 --- a/xc/extras/Mesa/src/texobj.h +++ b/xc/extras/Mesa/src/texobj.h @@ -31,9 +31,6 @@ #include "types.h" -#ifdef VMS -#define gl_test_texture_object_completeness gl_test_texture_object_complete -#endif /* * Internal functions @@ -48,7 +45,9 @@ extern void gl_free_texture_object( struct gl_shared_state *shared, struct gl_texture_object *t ); -extern void gl_test_texture_object_completeness( const GLcontext *ctx, struct gl_texture_object *t ); +extern void +_mesa_test_texobj_completeness( const GLcontext *ctx, + struct gl_texture_object *t ); /* diff --git a/xc/extras/Mesa/src/texstate.c b/xc/extras/Mesa/src/texstate.c index 3b0a7f539..a51a7f873 100644 --- a/xc/extras/Mesa/src/texstate.c +++ b/xc/extras/Mesa/src/texstate.c @@ -34,6 +34,7 @@ #include "macros.h" #include "matrix.h" #include "texobj.h" +#include "teximage.h" #include "texstate.h" #include "texture.h" #include "types.h" @@ -68,35 +69,24 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glTexEnv"); - if (target!=GL_TEXTURE_ENV) { - gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" ); - return; - } + if (target==GL_TEXTURE_ENV) { - if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) - fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n", - gl_lookup_enum_by_nr(target), - gl_lookup_enum_by_nr(pname), - *param, - gl_lookup_enum_by_nr((GLenum) (GLint) *param)); - - - if (pname==GL_TEXTURE_ENV_MODE) { - GLenum mode = (GLenum) (GLint) *param; - switch (mode) { - case GL_ADD: - if (!gl_extension_is_enabled(ctx, "GL_EXT_texture_env_add")) { - gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)"); - return; - } - /* FALL-THROUGH */ - case GL_MODULATE: - case GL_BLEND: - case GL_DECAL: - case GL_REPLACE: + if (pname==GL_TEXTURE_ENV_MODE) { + GLenum mode = (GLenum) (GLint) *param; + switch (mode) { + case GL_ADD: + if (!ctx->Extensions.HaveTextureEnvAdd) { + gl_error(ctx, GL_INVALID_ENUM, "glTexEnv(param)"); + return; + } + /* FALL-THROUGH */ + case GL_MODULATE: + case GL_BLEND: + case GL_DECAL: + case GL_REPLACE: /* A small optimization for drivers */ if (texUnit->EnvMode == mode) - return; + return; if (MESA_VERBOSE & (VERBOSE_STATE|VERBOSE_TEXTURE)) fprintf(stderr, "glTexEnv: old mode %s, new mode %s\n", @@ -109,23 +99,53 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param ) default: gl_error( ctx, GL_INVALID_VALUE, "glTexEnv(param)" ); return; + } } + else if (pname==GL_TEXTURE_ENV_COLOR) { + texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F ); + texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F ); + texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F ); + texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F ); + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); + return; + } + } - else if (pname==GL_TEXTURE_ENV_COLOR) { - texUnit->EnvColor[0] = CLAMP( param[0], 0.0F, 1.0F ); - texUnit->EnvColor[1] = CLAMP( param[1], 0.0F, 1.0F ); - texUnit->EnvColor[2] = CLAMP( param[2], 0.0F, 1.0F ); - texUnit->EnvColor[3] = CLAMP( param[3], 0.0F, 1.0F ); + else if (target==GL_TEXTURE_FILTER_CONTROL_EXT) { + + if (!ctx->Extensions.HaveTextureLodBias) { + gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(param)" ); + return; + } + + if (pname==GL_TEXTURE_LOD_BIAS_EXT) { + texUnit->LodBias = param[0]; + } + else { + gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); + return; + } + } else { - gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname)" ); + gl_error( ctx, GL_INVALID_ENUM, "glTexEnv(target)" ); return; } + if (MESA_VERBOSE&(VERBOSE_API|VERBOSE_TEXTURE)) + fprintf(stderr, "glTexEnv %s %s %.1f(%s) ...\n", + gl_lookup_enum_by_nr(target), + gl_lookup_enum_by_nr(pname), + *param, + gl_lookup_enum_by_nr((GLenum) (GLint) *param)); + /* Tell device driver about the new texture environment */ if (ctx->Driver.TexEnv) { - (*ctx->Driver.TexEnv)( ctx, pname, param ); + (*ctx->Driver.TexEnv)( ctx, target, pname, param ); } + } @@ -253,6 +273,12 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) case GL_TEXTURE_3D_EXT: texObj = texUnit->CurrentD[3]; break; + case GL_TEXTURE_CUBE_MAP_ARB: + if (ctx->Extensions.HaveTextureCubeMap) { + texObj = texUnit->CurrentCubeMap; + break; + } + /* fallthrough */ default: gl_error( ctx, GL_INVALID_ENUM, "glTexParameter(target)" ); return; @@ -405,6 +431,28 @@ _mesa_GetTexLevelParameterfv( GLenum target, GLint level, } +static GLuint +tex_image_dimensions(GLcontext *ctx, GLenum target) +{ + switch (target) { + case GL_TEXTURE_1D: + case GL_PROXY_TEXTURE_1D: + return 1; + case GL_TEXTURE_2D: + case GL_PROXY_TEXTURE_2D: + return 2; + case GL_TEXTURE_3D: + case GL_PROXY_TEXTURE_3D: + return 3; + case GL_TEXTURE_CUBE_MAP_ARB: + case GL_PROXY_TEXTURE_CUBE_MAP_ARB: + return ctx->Extensions.HaveTextureCubeMap ? 2 : 0; + default: + gl_problem(ctx, "bad target in _mesa_tex_target_dimensions()"); + return 0; + } +} + void _mesa_GetTexLevelParameteriv( GLenum target, GLint level, @@ -414,6 +462,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; const struct gl_texture_image *img = NULL; GLuint dimensions; + GLboolean isProxy; ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexLevelParameter"); @@ -422,36 +471,13 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, return; } - switch (target) { - case GL_TEXTURE_1D: - img = texUnit->CurrentD[1]->Image[level]; - dimensions = 1; - break; - case GL_TEXTURE_2D: - img = texUnit->CurrentD[2]->Image[level]; - dimensions = 2; - break; - case GL_TEXTURE_3D: - img = texUnit->CurrentD[3]->Image[level]; - dimensions = 3; - break; - case GL_PROXY_TEXTURE_1D: - img = ctx->Texture.Proxy1D->Image[level]; - dimensions = 1; - break; - case GL_PROXY_TEXTURE_2D: - img = ctx->Texture.Proxy2D->Image[level]; - dimensions = 2; - break; - case GL_PROXY_TEXTURE_3D: - img = ctx->Texture.Proxy3D->Image[level]; - dimensions = 3; - break; - default: - gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)"); - return; + dimensions = tex_image_dimensions(ctx, target); /* 1, 2 or 3 */ + if (dimensions == 0) { + gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(target)"); + return; } + img = _mesa_select_tex_image(ctx, texUnit, target, level); if (!img) { if (pname == GL_TEXTURE_COMPONENTS) *params = 1; @@ -460,6 +486,11 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, return; } + isProxy = (target == GL_PROXY_TEXTURE_1D) || + (target == GL_PROXY_TEXTURE_2D) || + (target == GL_PROXY_TEXTURE_3D) || + (target == GL_PROXY_TEXTURE_CUBE_MAP_ARB); + switch (pname) { case GL_TEXTURE_WIDTH: *params = img->Width; @@ -509,9 +540,31 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level, case GL_TEXTURE_INDEX_SIZE_EXT: *params = img->IndexBits; return; + + /* GL_ARB_texture_compression */ + case GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB: + if (ctx->Extensions.HaveTextureCompression) { + if (img->IsCompressed && !isProxy) + *params = img->CompressedSize; + else + gl_error(ctx, GL_INVALID_OPERATION, + "glGetTexLevelParameter[if]v(pname)"); + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); + } + return; + case GL_TEXTURE_COMPRESSED_ARB: + if (ctx->Extensions.HaveTextureCompression) { + *params = (GLint) img->IsCompressed; + } + else { + gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); + } + return; + default: - gl_error( ctx, GL_INVALID_ENUM, - "glGetTexLevelParameter[if]v(pname)" ); + gl_error(ctx, GL_INVALID_ENUM, "glGetTexLevelParameter[if]v(pname)"); } } @@ -526,19 +579,10 @@ _mesa_GetTexParameterfv( GLenum target, GLenum pname, GLfloat *params ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexParameterfv"); - switch (target) { - case GL_TEXTURE_1D: - obj = texUnit->CurrentD[1]; - break; - case GL_TEXTURE_2D: - obj = texUnit->CurrentD[2]; - break; - case GL_TEXTURE_3D_EXT: - obj = texUnit->CurrentD[3]; - break; - default: - gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)"); - return; + obj = _mesa_select_tex_object(ctx, texUnit, target); + if (!obj) { + gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameterfv(target)"); + return; } switch (pname) { @@ -596,19 +640,10 @@ _mesa_GetTexParameteriv( GLenum target, GLenum pname, GLint *params ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexParameteriv"); - switch (target) { - case GL_TEXTURE_1D: - obj = texUnit->CurrentD[1]; - break; - case GL_TEXTURE_2D: - obj = texUnit->CurrentD[2]; - break; - case GL_TEXTURE_3D_EXT: - obj = texUnit->CurrentD[3]; - break; - default: - gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)"); - return; + obj = _mesa_select_tex_object(ctx, texUnit, target); + if (!obj) { + gl_error(ctx, GL_INVALID_ENUM, "glGetTexParameteriv(target)"); + return; } switch (pname) { @@ -737,30 +772,30 @@ _mesa_TexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) case GL_T: if (pname==GL_TEXTURE_GEN_MODE) { GLenum mode = (GLenum) (GLint) *params; - switch(mode) { - case GL_OBJECT_LINEAR: - texUnit->GenModeT = GL_OBJECT_LINEAR; - texUnit->GenBitT = TEXGEN_OBJ_LINEAR; - break; - case GL_EYE_LINEAR: - texUnit->GenModeT = GL_EYE_LINEAR; - texUnit->GenBitT = TEXGEN_EYE_LINEAR; - break; - case GL_REFLECTION_MAP_NV: - texUnit->GenModeT = GL_REFLECTION_MAP_NV; - texUnit->GenBitT = TEXGEN_REFLECTION_MAP_NV; - break; - case GL_NORMAL_MAP_NV: - texUnit->GenModeT = GL_NORMAL_MAP_NV; - texUnit->GenBitT = TEXGEN_NORMAL_MAP_NV; - break; - case GL_SPHERE_MAP: - texUnit->GenModeT = GL_SPHERE_MAP; - texUnit->GenBitT = TEXGEN_SPHERE_MAP; - break; - default: - gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); - return; + switch (mode) { + case GL_OBJECT_LINEAR: + texUnit->GenModeT = GL_OBJECT_LINEAR; + texUnit->GenBitT = TEXGEN_OBJ_LINEAR; + break; + case GL_EYE_LINEAR: + texUnit->GenModeT = GL_EYE_LINEAR; + texUnit->GenBitT = TEXGEN_EYE_LINEAR; + break; + case GL_REFLECTION_MAP_NV: + texUnit->GenModeT = GL_REFLECTION_MAP_NV; + texUnit->GenBitT = TEXGEN_REFLECTION_MAP_NV; + break; + case GL_NORMAL_MAP_NV: + texUnit->GenModeT = GL_NORMAL_MAP_NV; + texUnit->GenBitT = TEXGEN_NORMAL_MAP_NV; + break; + case GL_SPHERE_MAP: + texUnit->GenModeT = GL_SPHERE_MAP; + texUnit->GenBitT = TEXGEN_SPHERE_MAP; + break; + default: + gl_error( ctx, GL_INVALID_ENUM, "glTexGenfv(param)" ); + return; } } else if (pname==GL_OBJECT_PLANE) { @@ -927,7 +962,7 @@ _mesa_GetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGendv"); - switch( coord ) { + switch (coord) { case GL_S: if (pname==GL_TEXTURE_GEN_MODE) { params[0] = ENUM_TO_DOUBLE(texUnit->GenModeS); @@ -1005,7 +1040,7 @@ _mesa_GetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGenfv"); - switch( coord ) { + switch (coord) { case GL_S: if (pname==GL_TEXTURE_GEN_MODE) { params[0] = ENUM_TO_FLOAT(texUnit->GenModeS); @@ -1083,7 +1118,7 @@ _mesa_GetTexGeniv( GLenum coord, GLenum pname, GLint *params ) ASSERT_OUTSIDE_BEGIN_END_AND_FLUSH(ctx, "glGetTexGeniv"); - switch( coord ) { + switch (coord) { case GL_S: if (pname==GL_TEXTURE_GEN_MODE) { params[0] = texUnit->GenModeS; @@ -1289,8 +1324,8 @@ void gl_update_dirty_texobjs( GLcontext *ctx ) struct gl_texture_object *t, *next; for (t = ctx->Shared->DirtyTexObjList; t; t = next) { next = t->NextDirty; - gl_test_texture_object_completeness(ctx, t); - gl_set_texture_sampler(t); + _mesa_test_texobj_completeness(ctx, t); + _mesa_set_texture_sampler(t); t->NextDirty = NULL; t->Dirty = GL_FALSE; } diff --git a/xc/extras/Mesa/src/texture.c b/xc/extras/Mesa/src/texture.c index c73171bd2..829b1bcb7 100644 --- a/xc/extras/Mesa/src/texture.c +++ b/xc/extras/Mesa/src/texture.c @@ -32,6 +32,7 @@ #include "macros.h" #include "mmath.h" #include "pb.h" +#include "teximage.h" #include "texture.h" #include "types.h" #include "xform.h" @@ -144,7 +145,12 @@ void gl_update_texture_unit( GLcontext *ctx, struct gl_texture_unit *texUnit ) { (void) ctx; - if ((texUnit->Enabled & TEXTURE0_3D) && texUnit->CurrentD[3]->Complete) { + if ((texUnit->Enabled & TEXTURE0_CUBE) && texUnit->CurrentCubeMap->Complete) { + texUnit->ReallyEnabled = TEXTURE0_CUBE; + texUnit->Current = texUnit->CurrentCubeMap; + texUnit->CurrentDimension = 6; + } + else if ((texUnit->Enabled & TEXTURE0_3D) && texUnit->CurrentD[3]->Complete) { texUnit->ReallyEnabled = TEXTURE0_3D; texUnit->Current = texUnit->CurrentD[3]; texUnit->CurrentDimension = 3; @@ -162,6 +168,10 @@ void gl_update_texture_unit( GLcontext *ctx, struct gl_texture_unit *texUnit ) else { if (MESA_VERBOSE & VERBOSE_TEXTURE) { switch (texUnit->Enabled) { + case TEXTURE0_CUBE: + fprintf(stderr, "Using incomplete cube texture %u\n", + texUnit->CurrentCubeMap->Name); + break; case TEXTURE0_3D: fprintf(stderr, "Using incomplete 3d texture %u\n", texUnit->CurrentD[3]->Name); @@ -245,11 +255,13 @@ static void palette_sample(const struct gl_texture_object *tObj, GLenum format; if (ctx->Texture.SharedPalette) { - palette = ctx->Texture.Palette.Table; + ASSERT(ctx->Texture.Palette.TableType == GL_UNSIGNED_BYTE); + palette = (const GLubyte *) ctx->Texture.Palette.Table; format = ctx->Texture.Palette.Format; } else { - palette = tObj->Palette.Table; + ASSERT(tObj->Palette.TableType == GL_UNSIGNED_BYTE); + palette = (const GLubyte *) tObj->Palette.Table; format = tObj->Palette.Format; } @@ -532,10 +544,10 @@ static void sample_1d_linear( const struct gl_texture_object *tObj, } { - GLfloat a = myFrac(u); + const GLfloat a = myFrac(u); /* compute sample weights in fixed point in [0,WEIGHT_SCALE] */ - GLint w0 = (GLint) ((1.0F-a) * WEIGHT_SCALE + 0.5F); - GLint w1 = (GLint) ( a * WEIGHT_SCALE + 0.5F); + const GLint w0 = (GLint) ((1.0F-a) * WEIGHT_SCALE + 0.5F); + const GLint w1 = (GLint) ( a * WEIGHT_SCALE + 0.5F); GLubyte t0[4], t1[4]; /* texels */ @@ -614,7 +626,7 @@ sample_1d_nearest_mipmap_linear( const struct gl_texture_object *tObj, } else { GLubyte t0[4], t1[4]; - GLfloat f = myFrac(lambda); + const GLfloat f = myFrac(lambda); sample_1d_nearest( tObj, tObj->Image[level ], s, t0 ); sample_1d_nearest( tObj, tObj->Image[level+1], s, t1 ); rgba[RCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -643,7 +655,7 @@ sample_1d_linear_mipmap_linear( const struct gl_texture_object *tObj, } else { GLubyte t0[4], t1[4]; - GLfloat f = myFrac(lambda); + const GLfloat f = myFrac(lambda); sample_1d_linear( tObj, tObj->Image[level ], s, t0 ); sample_1d_linear( tObj, tObj->Image[level+1], s, t1 ); rgba[RCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -906,13 +918,13 @@ static void sample_2d_linear( const struct gl_texture_object *tObj, } { - GLfloat a = myFrac(u); - GLfloat b = myFrac(v); + const GLfloat a = myFrac(u); + const GLfloat b = myFrac(v); /* compute sample weights in fixed point in [0,WEIGHT_SCALE] */ - GLint w00 = (GLint) ((1.0F-a)*(1.0F-b) * WEIGHT_SCALE + 0.5F); - GLint w10 = (GLint) ( a *(1.0F-b) * WEIGHT_SCALE + 0.5F); - GLint w01 = (GLint) ((1.0F-a)* b * WEIGHT_SCALE + 0.5F); - GLint w11 = (GLint) ( a * b * WEIGHT_SCALE + 0.5F); + const GLint w00 = (GLint) ((1.0F-a)*(1.0F-b) * WEIGHT_SCALE + 0.5F); + const GLint w10 = (GLint) ( a *(1.0F-b) * WEIGHT_SCALE + 0.5F); + const GLint w01 = (GLint) ((1.0F-a)* b * WEIGHT_SCALE + 0.5F); + const GLint w11 = (GLint) ( a * b * WEIGHT_SCALE + 0.5F); GLubyte t00[4]; GLubyte t10[4]; GLubyte t01[4]; @@ -1008,7 +1020,7 @@ sample_2d_nearest_mipmap_linear( const struct gl_texture_object *tObj, } else { GLubyte t0[4], t1[4]; /* texels */ - GLfloat f = myFrac(lambda); + const GLfloat f = myFrac(lambda); sample_2d_nearest( tObj, tObj->Image[level ], s, t, t0 ); sample_2d_nearest( tObj, tObj->Image[level+1], s, t, t1 ); rgba[RCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -1037,7 +1049,7 @@ sample_2d_linear_mipmap_linear( const struct gl_texture_object *tObj, } else { GLubyte t0[4], t1[4]; /* texels */ - GLfloat f = myFrac(lambda); + const GLfloat f = myFrac(lambda); sample_2d_linear( tObj, tObj->Image[level ], s, t, t0 ); sample_2d_linear( tObj, tObj->Image[level+1], s, t, t1 ); rgba[RCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -1385,9 +1397,9 @@ static void sample_3d_linear( const struct gl_texture_object *tObj, } { - GLfloat a = myFrac(u); - GLfloat b = myFrac(v); - GLfloat c = myFrac(w); + const GLfloat a = myFrac(u); + const GLfloat b = myFrac(v); + const GLfloat c = myFrac(w); /* compute sample weights in fixed point in [0,WEIGHT_SCALE] */ GLint w000 = (GLint) ((1.0F-a)*(1.0F-b)*(1.0F-c) * WEIGHT_SCALE + 0.5F); GLint w100 = (GLint) ( a *(1.0F-b)*(1.0F-c) * WEIGHT_SCALE + 0.5F); @@ -1525,7 +1537,7 @@ sample_3d_nearest_mipmap_linear( const struct gl_texture_object *tObj, } else { GLubyte t0[4], t1[4]; /* texels */ - GLfloat f = myFrac(lambda); + const GLfloat f = myFrac(lambda); sample_3d_nearest( tObj, tObj->Image[level ], s, t, r, t0 ); sample_3d_nearest( tObj, tObj->Image[level+1], s, t, r, t1 ); rgba[RCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -1553,7 +1565,7 @@ sample_3d_linear_mipmap_linear( const struct gl_texture_object *tObj, } else { GLubyte t0[4], t1[4]; /* texels */ - GLfloat f = myFrac(lambda); + const GLfloat f = myFrac(lambda); sample_3d_linear( tObj, tObj->Image[level ], s, t, r, t0 ); sample_3d_linear( tObj, tObj->Image[level+1], s, t, r, t1 ); rgba[RCOMP] = (GLubyte) (GLint) ((1.0F-f) * t0[RCOMP] + f * t1[RCOMP]); @@ -1648,6 +1660,187 @@ static void sample_lambda_3d( const struct gl_texture_object *tObj, GLuint n, } +/**********************************************************************/ +/* Texture Cube Map Sampling Functions */ +/**********************************************************************/ + +static struct gl_texture_image * +choose_cube_face(const struct gl_texture_object *texObj, + const GLfloat texcoord[4], + GLint level, + GLfloat *newS, GLfloat *newT) +{ +/* + major axis + direction target sc tc ma + ---------- ------------------------------- --- --- --- + +rx TEXTURE_CUBE_MAP_POSITIVE_X_EXT -rz -ry rx + -rx TEXTURE_CUBE_MAP_NEGATIVE_X_EXT +rz -ry rx + +ry TEXTURE_CUBE_MAP_POSITIVE_Y_EXT +rx +rz ry + -ry TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT +rx -rz ry + +rz TEXTURE_CUBE_MAP_POSITIVE_Z_EXT +rx -ry rz + -rz TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT -rx -ry rz +*/ + struct gl_texture_image *texImg; + const GLfloat rx = texcoord[0], ry = texcoord[1], rz = texcoord[2]; + const GLfloat arx = ABSF(rx), ary = ABSF(ry), arz = ABSF(rz); + GLfloat sc, tc, ma; + + if (arx > ary && arx > arz) { + if (rx >= 0.0F) { + texImg = texObj->Image[level]; + sc = -rz; + tc = -ry; + ma = arx; + } + else { + texImg = texObj->NegX[level]; + sc = rz; + tc = -ry; + ma = arx; + } + } + else if (ary > arx && ary > arz) { + if (ry >= 0.0F) { + texImg = texObj->PosY[level]; + sc = rx; + tc = rz; + ma = ary; + } + else { + texImg = texObj->NegY[level]; + sc = rx; + tc = -rz; + ma = ary; + } + } + else { + if (rz > 0.0F) { + texImg = texObj->PosZ[level]; + sc = rx; + tc = -ry; + ma = arz; + } + else { + texImg = texObj->NegZ[level]; + sc = -rx; + tc = -ry; + ma = arz; + } + } + + *newS = ( sc / ma + 1.0F ) * 0.5F; + *newT = ( tc / ma + 1.0F ) * 0.5F; + return texImg; +} + + +static void +sample_nearest_cube(const struct gl_texture_object *tObj, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte rgba[][4]) +{ + GLuint i; + (void) lambda; + for (i = 0; i < n; i++) { + struct gl_texture_image *image; + GLfloat newS, newT; + GLfloat coord[4]; + coord[0] = s[i]; + coord[1] = t[i]; + coord[2] = u[i]; + image = choose_cube_face(tObj, coord, 0, &newS, &newT); + sample_2d_nearest( tObj, image, newS, newT, rgba[i] ); + } +} + +static void +sample_linear_cube(const struct gl_texture_object *tObj, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte rgba[][4]) +{ + GLuint i; + (void) lambda; + for (i = 0; i < n; i++) { + struct gl_texture_image *image; + GLfloat newS, newT; + GLfloat coord[4]; + coord[0] = s[i]; + coord[1] = t[i]; + coord[2] = u[i]; + image = choose_cube_face(tObj, coord, 0, &newS, &newT); + sample_2d_linear( tObj, image, newS, newT, rgba[i] ); + } +} + +static void +sample_lambda_cube(const struct gl_texture_object *tObj, GLuint n, + const GLfloat s[], const GLfloat t[], + const GLfloat u[], const GLfloat lambda[], + GLubyte rgba[][4]) +{ + GLuint i; + + for (i = 0; i < n; i++) { + struct gl_texture_image *image; + GLfloat newS, newT; + GLfloat coord[4]; + coord[0] = s[i]; + coord[1] = t[i]; + coord[2] = u[i]; + image = choose_cube_face(tObj, coord, 0, &newS, &newT); + + if (lambda[i] > tObj->MinMagThresh) { + /* minification */ + switch (tObj->MinFilter) { + case GL_NEAREST: + sample_2d_nearest( tObj, image, newS, newT, rgba[i] ); + break; + case GL_LINEAR: + sample_2d_linear( tObj, image, newS, newT, rgba[i] ); + break; + case GL_NEAREST_MIPMAP_NEAREST: + /* + sample_3d_nearest_mipmap_nearest( tObj, s[i], t[i], u[i], lambda[i], rgba[i] ); + */ + break; + case GL_LINEAR_MIPMAP_NEAREST: + /* + sample_3d_linear_mipmap_nearest( tObj, s[i], t[i], u[i], lambda[i], rgba[i] ); + */ + break; + case GL_NEAREST_MIPMAP_LINEAR: + /* + sample_3d_nearest_mipmap_linear( tObj, s[i], t[i], u[i], lambda[i], rgba[i] ); + */ + break; + case GL_LINEAR_MIPMAP_LINEAR: + /* + sample_3d_linear_mipmap_linear( tObj, s[i], t[i], u[i], lambda[i], rgba[i] ); + */ + break; + default: + gl_problem(NULL, "Bad min filter in sample_lambda_cube"); + } + } + else { + /* magnification */ + switch (tObj->MagFilter) { + case GL_NEAREST: + sample_2d_nearest( tObj, image, newS, newT, rgba[i] ); + break; + case GL_LINEAR: + sample_2d_linear( tObj, image, newS, newT, rgba[i] ); + break; + default: + gl_problem(NULL, "Bad mag filter in sample_lambda_cube"); + } + } + } +} + /**********************************************************************/ /* Texture Sampling Setup */ @@ -1657,7 +1850,8 @@ static void sample_lambda_3d( const struct gl_texture_object *tObj, GLuint n, /* * Setup the texture sampling function for this texture object. */ -void gl_set_texture_sampler( struct gl_texture_object *t ) +void +_mesa_set_texture_sampler( struct gl_texture_object *t ) { if (!t->Complete) { t->SampleFunc = NULL; @@ -1723,8 +1917,20 @@ void gl_set_texture_sampler( struct gl_texture_object *t ) t->SampleFunc = sample_nearest_3d; } break; + case 6: /* cube map */ + if (needLambda) { + t->SampleFunc = sample_lambda_cube; + } + else if (t->MinFilter==GL_LINEAR) { + t->SampleFunc = sample_linear_cube; + } + else { + ASSERT(t->MinFilter==GL_NEAREST); + t->SampleFunc = sample_nearest_cube; + } + break; default: - gl_problem(NULL, "invalid dimensions in gl_set_texture_sampler"); + gl_problem(NULL, "invalid dimensions in _mesa_set_texture_sampler"); } } } @@ -2092,12 +2298,18 @@ void gl_texture_pixels( GLcontext *ctx, GLuint texUnit, GLuint n, const GLfloat r[], GLfloat lambda[], GLubyte rgba[][4] ) { - GLuint mask = (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D) << (texUnit * 4); + GLuint mask = (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE) << (texUnit * 4); if (ctx->Texture.Enabled & mask) { const struct gl_texture_unit *textureUnit = &ctx->Texture.Unit[texUnit]; if (textureUnit->Current && textureUnit->Current->SampleFunc) { - GLubyte texel[PB_SIZE][4]; + if (textureUnit->LodBias != 0.0F) { + /* apply LOD bias, but don't clamp yet */ + GLuint i; + for (i=0;i<n;i++) { + lambda[i] += textureUnit->LodBias; + } + } if (textureUnit->Current->MinLod != -1000.0 || textureUnit->Current->MaxLod != 1000.0) { @@ -2111,6 +2323,45 @@ void gl_texture_pixels( GLcontext *ctx, GLuint texUnit, GLuint n, } } + /* fetch texture images from device driver, if needed */ + { + static const GLenum targets[] = { + GL_TEXTURE_1D, + GL_TEXTURE_2D, + GL_TEXTURE_3D, + GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_CUBE_MAP_ARB, + GL_TEXTURE_CUBE_MAP_ARB + }; + struct gl_texture_object *texObj = textureUnit->Current; + GLboolean needLambda = (texObj->MinFilter != texObj->MagFilter); + GLenum target = targets[texObj->Dimensions - 1]; + if (needLambda) { + GLint level; + /* Get images for all mipmap levels. We might not need them + * all but this is easier. We're on a (slow) software path + * anyway. + */ + for (level = 0; level <= texObj->P; level++) { + struct gl_texture_image *texImg = texObj->Image[level]; + if (!texImg->Data) { + _mesa_get_teximage_from_driver(ctx, target, level, texObj); + if (!texImg->Data) + return; /* out of memory */ + } + } + } + else { + GLint level = texObj->BaseLevel; + struct gl_texture_image *texImg = texObj->Image[level]; + if (!texImg->Data) { + _mesa_get_teximage_from_driver(ctx, target, level, texObj); + if (!texImg->Data) + return; /* out of memory */ + } + } + } + /* Sample the texture. */ (*textureUnit->Current->SampleFunc)( textureUnit->Current, n, s, t, r, lambda, texel ); diff --git a/xc/extras/Mesa/src/texture.h b/xc/extras/Mesa/src/texture.h index d6631b786..58bc13136 100644 --- a/xc/extras/Mesa/src/texture.h +++ b/xc/extras/Mesa/src/texture.h @@ -34,7 +34,8 @@ #include "types.h" -extern void gl_set_texture_sampler( struct gl_texture_object *t ); +extern void +_mesa_set_texture_sampler( struct gl_texture_object *t ); extern void gl_init_texture( void ); diff --git a/xc/extras/Mesa/src/types.h b/xc/extras/Mesa/src/types.h index b3af90a8c..d85698a73 100644 --- a/xc/extras/Mesa/src/types.h +++ b/xc/extras/Mesa/src/types.h @@ -31,7 +31,6 @@ #include "glheader.h" #include "config.h" -#include "extensions.h" #include "fixed.h" #include "glapitable.h" #include "glthread.h" @@ -82,13 +81,7 @@ /* * Depth buffer data type: */ -#if DEPTH_BITS==16 - typedef GLushort GLdepth; -#elif DEPTH_BITS==32 - typedef GLint GLdepth; -#else -# error "illegal number of depth bits" -#endif +typedef GLuint GLdepth; /* Must be 32-bits! */ @@ -182,42 +175,52 @@ typedef void (*TextureSampleFunc)( const struct gl_texture_object *tObj, /* Texture image record */ struct gl_texture_image { - GLenum Format; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, + GLenum Format; /* GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, * GL_INTENSITY, GL_RGB, GL_RGBA, or * GL_COLOR_INDEX only */ - GLenum IntFormat; /* Internal format as given by the user */ - GLubyte RedBits; /* Bits per texel component */ - GLubyte GreenBits; /* These are initialized by Mesa but */ - GLubyte BlueBits; /* may be reassigned by the device */ - GLubyte AlphaBits; /* driver to indicate the true texture */ - GLubyte IntensityBits; /* color resolution. */ - GLubyte LuminanceBits; - GLubyte IndexBits; - GLuint Border; /* 0 or 1 */ - GLuint Width; /* = 2^WidthLog2 + 2*Border */ - GLuint Height; /* = 2^HeightLog2 + 2*Border */ - GLuint Depth; /* = 2^DepthLog2 + 2*Border */ - GLuint Width2; /* = Width - 2*Border */ - GLuint Height2; /* = Height - 2*Border */ - GLuint Depth2; /* = Depth - 2*Border */ - GLuint WidthLog2; /* = log2(Width2) */ - GLuint HeightLog2; /* = log2(Height2) */ - GLuint DepthLog2; /* = log2(Depth2) */ - GLuint MaxLog2; /* = MAX(WidthLog2, HeightLog2) */ - GLubyte *Data; /* Image data as unsigned bytes */ - - /* For device driver: */ - void *DriverData; /* Arbitrary device driver data */ + GLenum IntFormat; /* Internal format as given by the user */ + GLubyte RedBits; /* Bits per texel component */ + GLubyte GreenBits; /* These are initialized by Mesa but */ + GLubyte BlueBits; /* may be reassigned by the device */ + GLubyte AlphaBits; /* driver to indicate the true texture */ + GLubyte IntensityBits; /* color resolution. */ + GLubyte LuminanceBits; + GLubyte IndexBits; + GLuint Border; /* 0 or 1 */ + GLuint Width; /* = 2^WidthLog2 + 2*Border */ + GLuint Height; /* = 2^HeightLog2 + 2*Border */ + GLuint Depth; /* = 2^DepthLog2 + 2*Border */ + GLuint Width2; /* = Width - 2*Border */ + GLuint Height2; /* = Height - 2*Border */ + GLuint Depth2; /* = Depth - 2*Border */ + GLuint WidthLog2; /* = log2(Width2) */ + GLuint HeightLog2; /* = log2(Height2) */ + GLuint DepthLog2; /* = log2(Depth2) */ + GLuint MaxLog2; /* = MAX(WidthLog2, HeightLog2) */ + GLubyte *Data; /* Image data as unsigned bytes */ + + GLboolean IsCompressed; /* GL_ARB_texture_compression */ + GLuint CompressedSize; /* GL_ARB_texture_compression */ + + /* For device driver: */ + void *DriverData; /* Arbitrary device driver data */ }; /* Data structure for color tables */ struct gl_color_table { - GLubyte Table[4 * MAX_TEXTURE_PALETTE_SIZE]; - GLuint Size; /* number of entries (rows) in table */ - GLenum Format; - GLenum IntFormat; + GLvoid *Table; + GLenum TableType; /* GL_UNSIGNED_BYTE or GL_FLOAT */ + GLuint Size; /* number of entries (rows) in table */ + GLenum Format; + GLenum IntFormat; + GLint RedSize; + GLint GreenSize; + GLint BlueSize; + GLint AlphaSize; + GLint LuminanceSize; + GLint IntensitySize; }; @@ -261,47 +264,47 @@ struct gl_color_table { #define SHINE_TABLE_SIZE 256 struct gl_light { - struct gl_light *next; /* double linked list with sentinel */ - struct gl_light *prev; - - GLfloat Ambient[4]; /* ambient color */ - GLfloat Diffuse[4]; /* diffuse color */ - GLfloat Specular[4]; /* specular color */ - GLfloat EyePosition[4]; /* position in eye coordinates */ - GLfloat EyeDirection[4]; /* spotlight dir in eye coordinates */ - GLfloat SpotExponent; - GLfloat SpotCutoff; /* in degress */ - GLfloat CosCutoff; /* = MAX(0, cos(SpotCutoff)) */ - GLfloat ConstantAttenuation; - GLfloat LinearAttenuation; - GLfloat QuadraticAttenuation; - GLboolean Enabled; /* On/off flag */ - - /* Derived fields */ - GLuint Flags; /* State */ - - GLfloat Position[4]; /* position in eye/obj coordinates */ - GLfloat VP_inf_norm[3]; /* Norm direction to infinite light */ - GLfloat h_inf_norm[3]; /* Norm( VP_inf_norm + <0,0,1> ) */ - GLfloat NormDirection[4]; /* normalized spotlight direction */ - GLfloat VP_inf_spot_attenuation; - - GLfloat SpotExpTable[EXP_TABLE_SIZE][2]; /* to replace a pow() call */ - GLfloat MatAmbient[2][3]; /* material ambient * light ambient */ - GLfloat MatDiffuse[2][3]; /* material diffuse * light diffuse */ - GLfloat MatSpecular[2][3]; /* material spec * light specular */ - GLfloat dli; /* CI diffuse light intensity */ - GLfloat sli; /* CI specular light intensity */ - GLboolean IsMatSpecular[2]; + struct gl_light *next; /* double linked list with sentinel */ + struct gl_light *prev; + + GLfloat Ambient[4]; /* ambient color */ + GLfloat Diffuse[4]; /* diffuse color */ + GLfloat Specular[4]; /* specular color */ + GLfloat EyePosition[4]; /* position in eye coordinates */ + GLfloat EyeDirection[4]; /* spotlight dir in eye coordinates */ + GLfloat SpotExponent; + GLfloat SpotCutoff; /* in degress */ + GLfloat CosCutoff; /* = MAX(0, cos(SpotCutoff)) */ + GLfloat ConstantAttenuation; + GLfloat LinearAttenuation; + GLfloat QuadraticAttenuation; + GLboolean Enabled; /* On/off flag */ + + /* Derived fields */ + GLuint Flags; /* State */ + + GLfloat Position[4]; /* position in eye/obj coordinates */ + GLfloat VP_inf_norm[3]; /* Norm direction to infinite light */ + GLfloat h_inf_norm[3]; /* Norm( VP_inf_norm + <0,0,1> ) */ + GLfloat NormDirection[4]; /* normalized spotlight direction */ + GLfloat VP_inf_spot_attenuation; + + GLfloat SpotExpTable[EXP_TABLE_SIZE][2]; /* to replace a pow() call */ + GLfloat MatAmbient[2][3]; /* material ambient * light ambient */ + GLfloat MatDiffuse[2][3]; /* material diffuse * light diffuse */ + GLfloat MatSpecular[2][3]; /* material spec * light specular */ + GLfloat dli; /* CI diffuse light intensity */ + GLfloat sli; /* CI specular light intensity */ + GLboolean IsMatSpecular[2]; }; struct gl_lightmodel { - GLfloat Ambient[4]; /* ambient color */ - GLboolean LocalViewer; /* Local (or infinite) view point? */ - GLboolean TwoSide; /* Two (or one) sided lighting? */ - GLenum ColorControl; /* either GL_SINGLE_COLOR */ - /* or GL_SEPARATE_SPECULAR_COLOR */ + GLfloat Ambient[4]; /* ambient color */ + GLboolean LocalViewer; /* Local (or infinite) view point? */ + GLboolean TwoSide; /* Two (or one) sided lighting? */ + GLenum ColorControl; /* either GL_SINGLE_COLOR */ + /* or GL_SEPARATE_SPECULAR_COLOR */ }; @@ -313,7 +316,7 @@ struct gl_lightmodel { struct gl_accum_attrib { - GLfloat ClearColor[4]; /* Accumulation buffer clear color */ + GLfloat ClearColor[4]; /* Accumulation buffer clear color */ }; @@ -327,180 +330,220 @@ struct gl_accum_attrib { struct gl_colorbuffer_attrib { - GLuint ClearIndex; /* Index to use for glClear */ - GLfloat ClearColor[4]; /* Color to use for glClear */ - - GLuint IndexMask; /* Color index write mask */ - GLubyte ColorMask[4]; /* Each flag is 0xff or 0x0 */ - GLboolean SWmasking; /* Do color/CI masking in software? */ - - GLenum DrawBuffer; /* Which buffer to draw into */ - GLenum DriverDrawBuffer; /* Current device driver dest buffer */ - GLboolean MultiDrawBuffer; /* Drawing to mutliple buffers? */ - GLubyte DrawDestMask; /* bitwise-OR of bitflags above */ - - /* alpha testing */ - GLboolean AlphaEnabled; /* Alpha test enabled flag */ - GLenum AlphaFunc; /* Alpha test function */ - GLubyte AlphaRef; /* Alpha ref value in range [0,255] */ - - /* blending */ - GLboolean BlendEnabled; /* Blending enabled flag */ - GLenum BlendSrcRGB; /* Blending source operator */ - GLenum BlendDstRGB; /* Blending destination operator */ - GLenum BlendSrcA; /* GL_INGR_blend_func_separate */ - GLenum BlendDstA; /* GL_INGR_blend_func_separate */ - GLenum BlendEquation; - GLfloat BlendColor[4]; - blend_func BlendFunc; /* Points to C blending function */ - - /* logic op */ - GLenum LogicOp; /* Logic operator */ - GLboolean IndexLogicOpEnabled; /* Color index logic op enabled flag */ - GLboolean ColorLogicOpEnabled; /* RGBA logic op enabled flag */ - GLboolean SWLogicOpEnabled; /* Do logic ops in software? */ - - GLboolean DitherFlag; /* Dither enable flag */ + GLuint ClearIndex; /* Index to use for glClear */ + GLfloat ClearColor[4]; /* Color to use for glClear */ + + GLuint IndexMask; /* Color index write mask */ + GLubyte ColorMask[4]; /* Each flag is 0xff or 0x0 */ + GLboolean SWmasking; /* Do color/CI masking in software? */ + + GLenum DrawBuffer; /* Which buffer to draw into */ + GLenum DriverDrawBuffer; /* Current device driver dest buffer */ + GLboolean MultiDrawBuffer; /* Drawing to mutliple buffers? */ + GLubyte DrawDestMask; /* bitwise-OR of bitflags above */ + + /* alpha testing */ + GLboolean AlphaEnabled; /* Alpha test enabled flag */ + GLenum AlphaFunc; /* Alpha test function */ + GLubyte AlphaRef; /* Alpha ref value in range [0,255] */ + + /* blending */ + GLboolean BlendEnabled; /* Blending enabled flag */ + GLenum BlendSrcRGB; /* Blending source operator */ + GLenum BlendDstRGB; /* Blending destination operator */ + GLenum BlendSrcA; /* GL_INGR_blend_func_separate */ + GLenum BlendDstA; /* GL_INGR_blend_func_separate */ + GLenum BlendEquation; + GLfloat BlendColor[4]; + blend_func BlendFunc; /* Points to C blending function */ + + /* logic op */ + GLenum LogicOp; /* Logic operator */ + GLboolean IndexLogicOpEnabled; /* Color index logic op enabled flag */ + GLboolean ColorLogicOpEnabled; /* RGBA logic op enabled flag */ + GLboolean SWLogicOpEnabled; /* Do logic ops in software? */ + + GLboolean DitherFlag; /* Dither enable flag */ }; struct gl_current_attrib { - /* KW: These values valid only when the VB is flushed. - */ - GLuint Flag; /* Contains size information */ - GLfloat Normal[3]; - GLubyte ByteColor[4]; /* Current RGBA color */ - GLuint Index; /* Current color index */ - GLboolean EdgeFlag; /* Current edge flag */ - GLfloat Texcoord[MAX_TEXTURE_UNITS][4]; /* Current texture coords */ - GLenum Primitive; /* Prim or GL_POLYGON+1 */ + /* KW: These values valid only when the VB is flushed. + */ + GLuint Flag; /* Contains size information */ + GLfloat Normal[3]; + GLubyte ByteColor[4]; /* Current RGBA color */ + GLuint Index; /* Current color index */ + GLboolean EdgeFlag; /* Current edge flag */ + GLfloat Texcoord[MAX_TEXTURE_UNITS][4]; /* Current texture coords */ + GLenum Primitive; /* Prim or GL_POLYGON+1 */ - /* KW: No change to these values. - */ - GLfloat RasterPos[4]; /* Current raster position */ - GLfloat RasterDistance; /* Current raster distance */ - GLfloat RasterColor[4]; /* Current raster color */ - GLuint RasterIndex; /* Current raster index */ - GLfloat *RasterTexCoord; /* Current raster texcoord*/ - GLfloat RasterMultiTexCoord[MAX_TEXTURE_UNITS][4]; - GLboolean RasterPosValid; /* Raster po valid flag */ + /* KW: No change to these values. + */ + GLfloat RasterPos[4]; /* Current raster position */ + GLfloat RasterDistance; /* Current raster distance */ + GLfloat RasterColor[4]; /* Current raster color */ + GLuint RasterIndex; /* Current raster index */ + GLfloat *RasterTexCoord; /* Current raster texcoord*/ + GLfloat RasterMultiTexCoord[MAX_TEXTURE_UNITS][4]; + GLboolean RasterPosValid; /* Raster po valid flag */ }; struct gl_depthbuffer_attrib { - GLenum Func; /* Function for depth buffer compare */ - GLfloat Clear; /* Value to clear depth buffer to */ - GLboolean Test; /* Depth buffering enabled flag */ - GLboolean Mask; /* Depth buffer writable? */ + GLenum Func; /* Function for depth buffer compare */ + GLfloat Clear; /* Value to clear depth buffer to */ + GLboolean Test; /* Depth buffering enabled flag */ + GLboolean Mask; /* Depth buffer writable? */ + GLboolean OcclusionTest; /* GL_HP_occlusion_test */ }; struct gl_enable_attrib { - GLboolean AlphaTest; - GLboolean AutoNormal; - GLboolean Blend; - GLboolean ClipPlane[MAX_CLIP_PLANES]; - GLboolean ColorMaterial; - GLboolean CullFace; - GLboolean DepthTest; - GLboolean Dither; - GLboolean Fog; - GLboolean Light[MAX_LIGHTS]; - GLboolean Lighting; - GLboolean LineSmooth; - GLboolean LineStipple; - GLboolean IndexLogicOp; - GLboolean ColorLogicOp; - GLboolean Map1Color4; - GLboolean Map1Index; - GLboolean Map1Normal; - GLboolean Map1TextureCoord1; - GLboolean Map1TextureCoord2; - GLboolean Map1TextureCoord3; - GLboolean Map1TextureCoord4; - GLboolean Map1Vertex3; - GLboolean Map1Vertex4; - GLboolean Map2Color4; - GLboolean Map2Index; - GLboolean Map2Normal; - GLboolean Map2TextureCoord1; - GLboolean Map2TextureCoord2; - GLboolean Map2TextureCoord3; - GLboolean Map2TextureCoord4; - GLboolean Map2Vertex3; - GLboolean Map2Vertex4; - GLboolean Normalize; - GLboolean PointSmooth; - GLboolean PolygonOffsetPoint; - GLboolean PolygonOffsetLine; - GLboolean PolygonOffsetFill; - GLboolean PolygonSmooth; - GLboolean PolygonStipple; - GLboolean RescaleNormals; - GLboolean Scissor; - GLboolean Stencil; - GLuint Texture; - GLuint TexGen[MAX_TEXTURE_UNITS]; + GLboolean AlphaTest; + GLboolean AutoNormal; + GLboolean Blend; + GLboolean ClipPlane[MAX_CLIP_PLANES]; + GLboolean ColorMaterial; + GLboolean Convolution1D; + GLboolean Convolution2D; + GLboolean Separable2D; + GLboolean CullFace; + GLboolean DepthTest; + GLboolean Dither; + GLboolean Fog; + GLboolean Histogram; + GLboolean Light[MAX_LIGHTS]; + GLboolean Lighting; + GLboolean LineSmooth; + GLboolean LineStipple; + GLboolean IndexLogicOp; + GLboolean ColorLogicOp; + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean MinMax; + GLboolean Normalize; + GLboolean PixelTexture; + GLboolean PointSmooth; + GLboolean PolygonOffsetPoint; + GLboolean PolygonOffsetLine; + GLboolean PolygonOffsetFill; + GLboolean PolygonSmooth; + GLboolean PolygonStipple; + GLboolean RescaleNormals; + GLboolean Scissor; + GLboolean Stencil; + GLuint Texture; + GLuint TexGen[MAX_TEXTURE_UNITS]; }; struct gl_eval_attrib { - /* Enable bits */ - GLboolean Map1Color4; - GLboolean Map1Index; - GLboolean Map1Normal; - GLboolean Map1TextureCoord1; - GLboolean Map1TextureCoord2; - GLboolean Map1TextureCoord3; - GLboolean Map1TextureCoord4; - GLboolean Map1Vertex3; - GLboolean Map1Vertex4; - GLboolean Map2Color4; - GLboolean Map2Index; - GLboolean Map2Normal; - GLboolean Map2TextureCoord1; - GLboolean Map2TextureCoord2; - GLboolean Map2TextureCoord3; - GLboolean Map2TextureCoord4; - GLboolean Map2Vertex3; - GLboolean Map2Vertex4; - GLboolean AutoNormal; - /* Map Grid endpoints and divisions and calculated du values */ - GLint MapGrid1un; - GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; - GLint MapGrid2un, MapGrid2vn; - GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; - GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; + /* Enable bits */ + GLboolean Map1Color4; + GLboolean Map1Index; + GLboolean Map1Normal; + GLboolean Map1TextureCoord1; + GLboolean Map1TextureCoord2; + GLboolean Map1TextureCoord3; + GLboolean Map1TextureCoord4; + GLboolean Map1Vertex3; + GLboolean Map1Vertex4; + GLboolean Map2Color4; + GLboolean Map2Index; + GLboolean Map2Normal; + GLboolean Map2TextureCoord1; + GLboolean Map2TextureCoord2; + GLboolean Map2TextureCoord3; + GLboolean Map2TextureCoord4; + GLboolean Map2Vertex3; + GLboolean Map2Vertex4; + GLboolean AutoNormal; + /* Map Grid endpoints and divisions and calculated du values */ + GLint MapGrid1un; + GLfloat MapGrid1u1, MapGrid1u2, MapGrid1du; + GLint MapGrid2un, MapGrid2vn; + GLfloat MapGrid2u1, MapGrid2u2, MapGrid2du; + GLfloat MapGrid2v1, MapGrid2v2, MapGrid2dv; }; struct gl_fog_attrib { - GLboolean Enabled; /* Fog enabled flag */ - GLfloat Color[4]; /* Fog color */ - GLfloat Density; /* Density >= 0.0 */ - GLfloat Start; /* Start distance in eye coords */ - GLfloat End; /* End distance in eye coords */ - GLfloat Index; /* Fog index */ - GLenum Mode; /* Fog mode */ + GLboolean Enabled; /* Fog enabled flag */ + GLfloat Color[4]; /* Fog color */ + GLfloat Density; /* Density >= 0.0 */ + GLfloat Start; /* Start distance in eye coords */ + GLfloat End; /* End distance in eye coords */ + GLfloat Index; /* Fog index */ + GLenum Mode; /* Fog mode */ }; struct gl_hint_attrib { - /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */ - GLenum PerspectiveCorrection; - GLenum PointSmooth; - GLenum LineSmooth; - GLenum PolygonSmooth; - GLenum Fog; - - /* GL_PGI_misc_hints */ - GLenum AllowDrawWin; - GLenum AllowDrawSpn; - GLenum AllowDrawMem; - GLenum StrictLighting; - - /* GL_EXT_clip_volume_hint */ - GLenum ClipVolumeClipping; + /* always one of GL_FASTEST, GL_NICEST, or GL_DONT_CARE */ + GLenum PerspectiveCorrection; + GLenum PointSmooth; + GLenum LineSmooth; + GLenum PolygonSmooth; + GLenum Fog; + + /* GL_PGI_misc_hints */ + GLenum AllowDrawWin; + GLenum AllowDrawFrg; + GLenum AllowDrawMem; + GLenum StrictLighting; + + /* GL_EXT_clip_volume_hint */ + GLenum ClipVolumeClipping; + + /* GL_ARB_texture_compression */ + GLenum TextureCompression; +}; + + +struct gl_histogram_attrib { + GLuint Width; + GLint Format; + GLboolean Sink; + GLuint RedSize; + GLuint GreenSize; + GLuint BlueSize; + GLuint AlphaSize; + GLuint LuminanceSize; + GLuint Count[HISTOGRAM_TABLE_SIZE][4]; +}; + + +struct gl_minmax_attrib { + GLenum Format; + GLboolean Sink; + GLfloat Min[4], Max[4]; /* RGBA */ +}; + + +struct gl_convolution_attrib { + /* XXX not done yet */ + GLenum Format; + GLenum InternalFormat; + GLuint Width; + GLuint Height; + GLfloat Filter[MAX_CONVOLUTION_WIDTH * MAX_CONVOLUTION_HEIGHT * 4]; }; @@ -534,109 +577,139 @@ struct gl_light_attrib { #define LIGHT_NEED_VERTICES (LIGHT_POSITIONAL|LIGHT_LOCAL_VIEWER) struct gl_line_attrib { - GLboolean SmoothFlag; /* GL_LINE_SMOOTH enabled? */ - GLboolean StippleFlag; /* GL_LINE_STIPPLE enabled? */ - GLushort StipplePattern; /* Stipple pattern */ - GLint StippleFactor; /* Stipple repeat factor */ - GLfloat Width; /* Line width */ + GLboolean SmoothFlag; /* GL_LINE_SMOOTH enabled? */ + GLboolean StippleFlag; /* GL_LINE_STIPPLE enabled? */ + GLushort StipplePattern; /* Stipple pattern */ + GLint StippleFactor; /* Stipple repeat factor */ + GLfloat Width; /* Line width */ }; struct gl_list_attrib { - GLuint ListBase; + GLuint ListBase; }; struct gl_pixel_attrib { - GLenum ReadBuffer; /* src buffer for glRead/CopyPixels */ - GLenum DriverReadBuffer; /* Driver's current source buffer */ - GLfloat RedBias, RedScale; - GLfloat GreenBias, GreenScale; - GLfloat BlueBias, BlueScale; - GLfloat AlphaBias, AlphaScale; - GLboolean ScaleOrBiasRGBA; - GLfloat DepthBias, DepthScale; - GLint IndexShift, IndexOffset; - GLboolean MapColorFlag; - GLboolean MapStencilFlag; - GLfloat ZoomX; /* Pixel zoom X factor */ - GLfloat ZoomY; /* Pixel zoom Y factor */ - GLint MapStoSsize; /* Size of each pixel map */ - GLint MapItoIsize; - GLint MapItoRsize; - GLint MapItoGsize; - GLint MapItoBsize; - GLint MapItoAsize; - GLint MapRtoRsize; - GLint MapGtoGsize; - GLint MapBtoBsize; - GLint MapAtoAsize; - GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /* Pixel map tables */ - GLint MapItoI[MAX_PIXEL_MAP_TABLE]; - GLfloat MapItoR[MAX_PIXEL_MAP_TABLE]; - GLfloat MapItoG[MAX_PIXEL_MAP_TABLE]; - GLfloat MapItoB[MAX_PIXEL_MAP_TABLE]; - GLfloat MapItoA[MAX_PIXEL_MAP_TABLE]; - GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /* converted to 8-bit color */ - GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE]; - GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE]; - GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE]; - GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE]; - GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE]; - GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE]; - GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE]; + GLenum ReadBuffer; /* src buffer for glRead/CopyPixels */ + GLenum DriverReadBuffer; /* Driver's current source buffer */ + GLfloat RedBias, RedScale; + GLfloat GreenBias, GreenScale; + GLfloat BlueBias, BlueScale; + GLfloat AlphaBias, AlphaScale; + GLboolean ScaleOrBiasRGBA; + GLfloat DepthBias, DepthScale; + GLint IndexShift, IndexOffset; + GLboolean MapColorFlag; + GLboolean MapStencilFlag; + GLfloat ZoomX, ZoomY; + GLint MapStoSsize; /* Size of each pixel map */ + GLint MapItoIsize; + GLint MapItoRsize; + GLint MapItoGsize; + GLint MapItoBsize; + GLint MapItoAsize; + GLint MapRtoRsize; + GLint MapGtoGsize; + GLint MapBtoBsize; + GLint MapAtoAsize; + GLint MapStoS[MAX_PIXEL_MAP_TABLE]; /* Pixel map tables */ + GLint MapItoI[MAX_PIXEL_MAP_TABLE]; + GLfloat MapItoR[MAX_PIXEL_MAP_TABLE]; + GLfloat MapItoG[MAX_PIXEL_MAP_TABLE]; + GLfloat MapItoB[MAX_PIXEL_MAP_TABLE]; + GLfloat MapItoA[MAX_PIXEL_MAP_TABLE]; + GLubyte MapItoR8[MAX_PIXEL_MAP_TABLE]; /* converted to 8-bit color */ + GLubyte MapItoG8[MAX_PIXEL_MAP_TABLE]; + GLubyte MapItoB8[MAX_PIXEL_MAP_TABLE]; + GLubyte MapItoA8[MAX_PIXEL_MAP_TABLE]; + GLfloat MapRtoR[MAX_PIXEL_MAP_TABLE]; + GLfloat MapGtoG[MAX_PIXEL_MAP_TABLE]; + GLfloat MapBtoB[MAX_PIXEL_MAP_TABLE]; + GLfloat MapAtoA[MAX_PIXEL_MAP_TABLE]; + /* GL_EXT_histogram */ + GLboolean HistogramEnabled; + GLboolean MinMaxEnabled; + /* GL_SGIS_pixel_texture */ + GLboolean PixelTextureEnabled; + GLenum FragmentRgbSource; + GLenum FragmentAlphaSource; + /* GL_SGI_color_matrix */ + GLfloat PostColorMatrixScale[4]; /* RGBA */ + GLfloat PostColorMatrixBias[4]; /* RGBA */ + GLboolean ScaleOrBiasRGBApcm; + /* GL_SGI_color_table */ + GLfloat ColorTableScale[4]; + GLfloat ColorTableBias[4]; + GLboolean ColorTableEnabled; + GLfloat PCCTscale[4]; + GLfloat PCCTbias[4]; + GLboolean PostConvolutionColorTableEnabled; + GLfloat PCMCTscale[4]; + GLfloat PCMCTbias[4]; + GLboolean PostColorMatrixColorTableEnabled; + /* Convolution */ + GLboolean Convolution1DEnabled; + GLboolean Convolution2DEnabled; + GLboolean Separable2DEnabled; + GLfloat ConvolutionBorderColor[3][4]; + GLenum ConvolutionBorderMode[3]; + GLfloat ConvolutionFilterScale[3][4]; + GLfloat ConvolutionFilterBias[3][4]; + GLfloat PostConvolutionScale[4]; /* RGBA */ + GLfloat PostConvolutionBias[4]; /* RGBA */ }; struct gl_point_attrib { - GLboolean SmoothFlag; /* True if GL_POINT_SMOOTH is enabled */ - GLfloat Size; /* Point size */ - GLfloat Params[3]; /* Point Parameters EXT distance atenuation - factors by default = {1,0,0} */ - GLfloat MinSize; /* Default 0.0 always >=0 */ - GLfloat MaxSize; /* Default MAX_POINT_SIZE */ - GLfloat Threshold; /* Default 1.0 */ - GLboolean Attenuated; + GLboolean SmoothFlag;/* True if GL_POINT_SMOOTH is enabled */ + GLfloat UserSize; /* User-specified point size */ + GLfloat Size; /* Point size actually used */ + GLfloat Params[3]; /* Point Parameters EXT distance atenuation + factors by default = {1,0,0} */ + GLfloat MinSize; /* Default 0.0 always >=0 */ + GLfloat MaxSize; /* Default MAX_POINT_SIZE */ + GLfloat Threshold; /* Default 1.0 */ + GLboolean Attenuated; }; struct gl_polygon_attrib { - GLenum FrontFace; /* Either GL_CW or GL_CCW */ - GLenum FrontMode; /* Either GL_POINT, GL_LINE or GL_FILL */ - GLenum BackMode; /* Either GL_POINT, GL_LINE or GL_FILL */ - GLboolean FrontBit; /* */ - GLboolean Unfilled; /* True if back or front mode is not GL_FILL */ - GLboolean CullFlag; /* Culling on/off flag */ - GLubyte CullBits; /* Used for cull testing */ - GLboolean SmoothFlag; /* True if GL_POLYGON_SMOOTH is enabled */ - GLboolean StippleFlag; /* True if GL_POLYGON_STIPPLE is enabled */ - GLenum CullFaceMode; /* Culling mode GL_FRONT or GL_BACK */ - GLfloat OffsetFactor; /* Polygon offset factor */ - GLfloat OffsetUnits; /* Polygon offset units */ - GLboolean OffsetPoint; /* Offset in GL_POINT mode? */ - GLboolean OffsetLine; /* Offset in GL_LINE mode? */ - GLboolean OffsetFill; /* Offset in GL_FILL mode? */ - + GLenum FrontFace; /* Either GL_CW or GL_CCW */ + GLenum FrontMode; /* Either GL_POINT, GL_LINE or GL_FILL */ + GLenum BackMode; /* Either GL_POINT, GL_LINE or GL_FILL */ + GLboolean FrontBit; /* */ + GLboolean Unfilled; /* True if back or front mode is not GL_FILL */ + GLboolean CullFlag; /* Culling on/off flag */ + GLubyte CullBits; /* Used for cull testing */ + GLboolean SmoothFlag; /* True if GL_POLYGON_SMOOTH is enabled */ + GLboolean StippleFlag; /* True if GL_POLYGON_STIPPLE is enabled */ + GLenum CullFaceMode; /* Culling mode GL_FRONT or GL_BACK */ + GLfloat OffsetFactor; /* Polygon offset factor */ + GLfloat OffsetUnits; /* Polygon offset units */ + GLboolean OffsetPoint; /* Offset in GL_POINT mode? */ + GLboolean OffsetLine; /* Offset in GL_LINE mode? */ + GLboolean OffsetFill; /* Offset in GL_FILL mode? */ }; struct gl_scissor_attrib { - GLboolean Enabled; /* Scissor test enabled? */ - GLint X, Y; /* Lower left corner of box */ - GLsizei Width, Height; /* Size of box */ + GLboolean Enabled; /* Scissor test enabled? */ + GLint X, Y; /* Lower left corner of box */ + GLsizei Width, Height; /* Size of box */ }; struct gl_stencil_attrib { - GLboolean Enabled; /* Enabled flag */ - GLenum Function; /* Stencil function */ - GLenum FailFunc; /* Fail function */ - GLenum ZPassFunc; /* Depth buffer pass function */ - GLenum ZFailFunc; /* Depth buffer fail function */ - GLstencil Ref; /* Reference value */ - GLstencil ValueMask; /* Value mask */ - GLstencil Clear; /* Clear value */ - GLstencil WriteMask; /* Write mask */ + GLboolean Enabled; /* Enabled flag */ + GLenum Function; /* Stencil function */ + GLenum FailFunc; /* Fail function */ + GLenum ZPassFunc; /* Depth buffer pass function */ + GLenum ZFailFunc; /* Depth buffer fail function */ + GLstencil Ref; /* Reference value */ + GLstencil ValueMask; /* Value mask */ + GLstencil Clear; /* Clear value */ + GLstencil WriteMask; /* Write mask */ }; @@ -647,14 +720,16 @@ struct gl_stencil_attrib { #define Q_BIT 8 /* Texture Enabled flags */ -#define TEXTURE0_1D S_BIT /* Texture unit 0 (default) */ -#define TEXTURE0_2D T_BIT -#define TEXTURE0_3D R_BIT -#define TEXTURE0_ANY (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D) -#define TEXTURE1_1D (S_BIT<<4) /* Texture unit 1 */ -#define TEXTURE1_2D (T_BIT<<4) -#define TEXTURE1_3D (R_BIT<<4) -#define TEXTURE1_ANY (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D) +#define TEXTURE0_1D 0x1 /* Texture unit 0 (default) */ +#define TEXTURE0_2D 0x2 +#define TEXTURE0_3D 0x4 +#define TEXTURE0_CUBE 0x8 +#define TEXTURE0_ANY (TEXTURE0_1D | TEXTURE0_2D | TEXTURE0_3D | TEXTURE0_CUBE) +#define TEXTURE1_1D (TEXTURE0_1D << 4) /* Texture unit 1 */ +#define TEXTURE1_2D (TEXTURE0_2D << 4) +#define TEXTURE1_3D (TEXTURE0_3D << 4) +#define TEXTURE1_CUBE (TEXTURE0_CUBE << 4) +#define TEXTURE1_ANY (TEXTURE1_1D | TEXTURE1_2D | TEXTURE1_3D | TEXTURE1_CUBE) /* Bitmap versions of the GL_ constants. */ @@ -706,37 +781,45 @@ typedef void (*texgen_func)( struct vertex_buffer *VB, /* Texture object record */ struct gl_texture_object { - _glthread_Mutex Mutex; /* for thread safety */ - GLint RefCount; /* reference count */ - GLuint Name; /* an unsigned integer */ - GLuint Dimensions; /* 1 or 2 or 3 */ - GLfloat Priority; /* in [0,1] */ - GLubyte BorderColor[4]; /* as integers in [0,255] */ - GLenum WrapS; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ - GLenum WrapT; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ - GLenum WrapR; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ - GLenum MinFilter; /* minification filter */ - GLenum MagFilter; /* magnification filter */ - GLfloat MinLod; /* OpenGL 1.2 */ - GLfloat MaxLod; /* OpenGL 1.2 */ - GLint BaseLevel; /* OpenGL 1.2 */ - GLint MaxLevel; /* OpenGL 1.2 */ - GLint P; /* Highest mipmap level */ - GLfloat M; /* = MIN(MaxLevel, P) - BaseLevel */ - GLfloat MinMagThresh; /* min/mag threshold */ - struct gl_texture_image *Image[MAX_TEXTURE_LEVELS]; - - /* GL_EXT_paletted_texture */ - struct gl_color_table Palette; - - /* For device driver: */ - GLboolean Dirty; /* Is this texture object in dirty list? */ - void *DriverData; /* Arbitrary device driver data */ - - GLboolean Complete; /* Complete set of images? */ - TextureSampleFunc SampleFunc; /* The texel sampling function */ - struct gl_texture_object *Next; /* Next in linked list */ - struct gl_texture_object *NextDirty; /* Next in dirty linked list */ + _glthread_Mutex Mutex; /* for thread safety */ + GLint RefCount; /* reference count */ + GLuint Name; /* an unsigned integer */ + GLuint Dimensions; /* 1 or 2 or 3 */ + GLfloat Priority; /* in [0,1] */ + GLubyte BorderColor[4]; /* as integers in [0,255] */ + GLenum WrapS; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ + GLenum WrapT; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ + GLenum WrapR; /* GL_CLAMP, REPEAT or CLAMP_TO_EDGE */ + GLenum MinFilter; /* minification filter */ + GLenum MagFilter; /* magnification filter */ + GLfloat MinLod; /* OpenGL 1.2 */ + GLfloat MaxLod; /* OpenGL 1.2 */ + GLint BaseLevel; /* OpenGL 1.2 */ + GLint MaxLevel; /* OpenGL 1.2 */ + GLint P; /* Highest mipmap level */ + GLfloat M; /* = MIN(MaxLevel, P) - BaseLevel */ + GLfloat MinMagThresh; /* min/mag threshold */ + struct gl_texture_image *Image[MAX_TEXTURE_LEVELS]; + + /* Texture cube faces */ + /* Image[] is alias for *PosX[MAX_TEXTURE_LEVELS]; */ + struct gl_texture_image *NegX[MAX_TEXTURE_LEVELS]; + struct gl_texture_image *PosY[MAX_TEXTURE_LEVELS]; + struct gl_texture_image *NegY[MAX_TEXTURE_LEVELS]; + struct gl_texture_image *PosZ[MAX_TEXTURE_LEVELS]; + struct gl_texture_image *NegZ[MAX_TEXTURE_LEVELS]; + + /* GL_EXT_paletted_texture */ + struct gl_color_table Palette; + + /* For device driver: */ + GLboolean Dirty; /* Is this texture object in dirty list? */ + void *DriverData; /* Arbitrary device driver data */ + + GLboolean Complete; /* Complete set of images? */ + TextureSampleFunc SampleFunc; /* The texel sampling function */ + struct gl_texture_object *Next; /* Next in linked list */ + struct gl_texture_object *NextDirty; /* Next in dirty linked list */ }; @@ -745,69 +828,73 @@ struct gl_texture_object { * Texture units are new with the multitexture extension. */ struct gl_texture_unit { - GLuint Enabled; - GLuint ReallyEnabled; - - GLenum EnvMode; /* GL_MODULATE, GL_DECAL, GL_BLEND */ - GLenum LastEnvMode; - - GLfloat EnvColor[4]; - GLuint TexGenEnabled; /* Bitwise-OR of [STRQ]_BIT values */ - GLenum GenModeS; /* Tex coord generation mode, either */ - GLenum GenModeT; /* GL_OBJECT_LINEAR, or */ - GLenum GenModeR; /* GL_EYE_LINEAR, or */ - GLenum GenModeQ; /* GL_SPHERE_MAP */ - GLuint GenBitS; - GLuint GenBitT; - GLuint GenBitR; - GLuint GenBitQ; - GLuint GenFlags; /* bitwise or of GenBit[STRQ] */ - GLfloat ObjectPlaneS[4]; - GLfloat ObjectPlaneT[4]; - GLfloat ObjectPlaneR[4]; - GLfloat ObjectPlaneQ[4]; - GLfloat EyePlaneS[4]; - GLfloat EyePlaneT[4]; - GLfloat EyePlaneR[4]; - GLfloat EyePlaneQ[4]; - texgen_func *func; /* points to array of func pointers */ - GLubyte Holes; /* elements not generated by texgen */ - GLuint TexgenSize; /* size of element generated */ - GLboolean AnyTransform; /* texgen or non-identity matrix */ - - struct gl_texture_object *CurrentD[4]; - struct gl_texture_object *Current; - GLuint CurrentDimension; - - struct gl_texture_object Saved1D; /* only used by glPush/PopAttrib */ - struct gl_texture_object Saved2D; - struct gl_texture_object Saved3D; + GLuint Enabled; + GLuint ReallyEnabled; + + GLenum EnvMode; /* GL_MODULATE, GL_DECAL, GL_BLEND */ + GLenum LastEnvMode; + + GLfloat EnvColor[4]; + GLuint TexGenEnabled; /* Bitwise-OR of [STRQ]_BIT values */ + GLenum GenModeS; /* Tex coord generation mode, either */ + GLenum GenModeT; /* GL_OBJECT_LINEAR, or */ + GLenum GenModeR; /* GL_EYE_LINEAR, or */ + GLenum GenModeQ; /* GL_SPHERE_MAP */ + GLuint GenBitS; + GLuint GenBitT; + GLuint GenBitR; + GLuint GenBitQ; + GLuint GenFlags; /* bitwise or of GenBit[STRQ] */ + GLfloat ObjectPlaneS[4]; + GLfloat ObjectPlaneT[4]; + GLfloat ObjectPlaneR[4]; + GLfloat ObjectPlaneQ[4]; + GLfloat EyePlaneS[4]; + GLfloat EyePlaneT[4]; + GLfloat EyePlaneR[4]; + GLfloat EyePlaneQ[4]; + texgen_func *func; /* points to array of func pointers */ + GLubyte Holes; /* elements not generated by texgen */ + GLuint TexgenSize; /* size of element generated */ + GLboolean AnyTransform; /* texgen or non-identity matrix */ + GLfloat LodBias; /* for biasing mipmap levels */ + + struct gl_texture_object *CurrentD[4]; + struct gl_texture_object *CurrentCubeMap; /* GL_ARB_texture_cube_map */ + + struct gl_texture_object *Current; + GLuint CurrentDimension; + + struct gl_texture_object Saved1D; /* only used by glPush/PopAttrib */ + struct gl_texture_object Saved2D; + struct gl_texture_object Saved3D; }; struct gl_texture_attrib { - /* multitexture */ - GLuint CurrentUnit; /* Current texture unit */ - GLuint CurrentTransformUnit; /* Current texture xform unit */ + /* multitexture */ + GLuint CurrentUnit; /* Current texture unit */ + GLuint CurrentTransformUnit; /* Current texture xform unit */ - /* Bitwise-OR of TEXTURE_XD values */ - GLuint Enabled; /* Enabled by the user */ - GLuint ReallyEnabled; /* Really enabled (w.r.t. completeness, etc) */ + /* Bitwise-OR of TEXTURE_XD values */ + GLuint Enabled; /* Enabled by the user */ + GLuint ReallyEnabled; /* Really enabled (w.r.t. completeness, etc) */ - GLuint LastEnabled; /* Decide whether enabled has really changed */ + GLuint LastEnabled; /* Decide whether enabled has really changed */ - GLboolean NeedNormals; - GLboolean NeedEyeCoords; + GLboolean NeedNormals; + GLboolean NeedEyeCoords; - struct gl_texture_unit Unit[MAX_TEXTURE_UNITS]; + struct gl_texture_unit Unit[MAX_TEXTURE_UNITS]; - struct gl_texture_object *Proxy1D; - struct gl_texture_object *Proxy2D; - struct gl_texture_object *Proxy3D; - - /* GL_EXT_shared_texture_palette */ - GLboolean SharedPalette; - struct gl_color_table Palette; + struct gl_texture_object *Proxy1D; + struct gl_texture_object *Proxy2D; + struct gl_texture_object *Proxy3D; + struct gl_texture_object *ProxyCubeMap; + + /* GL_EXT_shared_texture_palette */ + GLboolean SharedPalette; + struct gl_color_table Palette; }; @@ -815,29 +902,29 @@ struct gl_texture_attrib { /* KW: Renamed ClipEquation to avoid having 'ClipClipEquation' */ struct gl_transform_attrib { - GLenum MatrixMode; /* Matrix mode */ - GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; - GLfloat ClipUserPlane[MAX_CLIP_PLANES][4]; /* derived */ - GLboolean ClipEnabled[MAX_CLIP_PLANES]; - GLubyte AnyClip; /* How many ClipEnabled? */ - GLboolean Normalize; /* Normalize all normals? */ - GLboolean RescaleNormals; /* GL_EXT_rescale_normal */ + GLenum MatrixMode; /* Matrix mode */ + GLfloat EyeUserPlane[MAX_CLIP_PLANES][4]; + GLfloat ClipUserPlane[MAX_CLIP_PLANES][4]; /* derived */ + GLboolean ClipEnabled[MAX_CLIP_PLANES]; + GLubyte AnyClip; /* How many ClipEnabled? */ + GLboolean Normalize; /* Normalize all normals? */ + GLboolean RescaleNormals; /* GL_EXT_rescale_normal */ }; struct gl_viewport_attrib { - GLint X, Y; /* position */ - GLsizei Width, Height; /* size */ - GLfloat Near, Far; /* Depth buffer range */ - GLmatrix WindowMap; /* Mapping transformation as a matrix. */ + GLint X, Y; /* position */ + GLsizei Width, Height; /* size */ + GLfloat Near, Far; /* Depth buffer range */ + GLmatrix WindowMap; /* Mapping transformation as a matrix. */ }; /* For the attribute stack: */ struct gl_attrib_node { - GLbitfield kind; - void *data; - struct gl_attrib_node *next; + GLbitfield kind; + void *data; + struct gl_attrib_node *next; }; @@ -846,14 +933,14 @@ struct gl_attrib_node { * Client pixel packing/unpacking attributes */ struct gl_pixelstore_attrib { - GLint Alignment; - GLint RowLength; - GLint SkipPixels; - GLint SkipRows; - GLint ImageHeight; /* for GL_EXT_texture3D */ - GLint SkipImages; /* for GL_EXT_texture3D */ - GLboolean SwapBytes; - GLboolean LsbFirst; + GLint Alignment; + GLint RowLength; + GLint SkipPixels; + GLint SkipRows; + GLint ImageHeight; /* for GL_EXT_texture3D */ + GLint SkipImages; /* for GL_EXT_texture3D */ + GLboolean SwapBytes; + GLboolean LsbFirst; }; @@ -944,37 +1031,37 @@ typedef void (*trans_elt_3f_func)(GLfloat (*to)[3], struct gl_array_attrib { - struct gl_client_array Vertex; /* client data descriptors */ - struct gl_client_array Normal; - struct gl_client_array Color; - struct gl_client_array Index; - struct gl_client_array TexCoord[MAX_TEXTURE_UNITS]; - struct gl_client_array EdgeFlag; - - trans_4f_func VertexFunc; /* conversion functions */ - trans_3f_func NormalFunc; - trans_4ub_func ColorFunc; - trans_1ui_func IndexFunc; - trans_4f_func TexCoordFunc[MAX_TEXTURE_UNITS]; - trans_1ub_func EdgeFlagFunc; - - trans_elt_4f_func VertexEltFunc; /* array elt conversion functions */ - trans_elt_3f_func NormalEltFunc; - trans_elt_4ub_func ColorEltFunc; - trans_elt_1ui_func IndexEltFunc; - trans_elt_4f_func TexCoordEltFunc[MAX_TEXTURE_UNITS]; - trans_elt_1ub_func EdgeFlagEltFunc; - - GLint TexCoordInterleaveFactor; - GLint ActiveTexture; /* Client Active Texture */ - - GLuint LockFirst; - GLuint LockCount; + struct gl_client_array Vertex; /* client data descriptors */ + struct gl_client_array Normal; + struct gl_client_array Color; + struct gl_client_array Index; + struct gl_client_array TexCoord[MAX_TEXTURE_UNITS]; + struct gl_client_array EdgeFlag; + + trans_4f_func VertexFunc; /* conversion functions */ + trans_3f_func NormalFunc; + trans_4ub_func ColorFunc; + trans_1ui_func IndexFunc; + trans_4f_func TexCoordFunc[MAX_TEXTURE_UNITS]; + trans_1ub_func EdgeFlagFunc; + + trans_elt_4f_func VertexEltFunc; /* array elt conversion functions */ + trans_elt_3f_func NormalEltFunc; + trans_elt_4ub_func ColorEltFunc; + trans_elt_1ui_func IndexEltFunc; + trans_elt_4f_func TexCoordEltFunc[MAX_TEXTURE_UNITS]; + trans_elt_1ub_func EdgeFlagEltFunc; + + GLint TexCoordInterleaveFactor; + GLint ActiveTexture; /* Client Active Texture */ + + GLuint LockFirst; + GLuint LockCount; - GLuint Flag[VB_SIZE]; /* crock */ - GLuint Flags; - GLuint Summary; /* Like flags, but no size information */ - GLuint NewArrayState; /* Tracks which arrays have been changed. */ + GLuint Flag[VB_SIZE]; /* crock */ + GLuint Flags; + GLuint Summary; /* Like flags, but no size information */ + GLuint NewArrayState; /* Tracks which arrays have been changed. */ }; @@ -982,11 +1069,11 @@ struct gl_array_attrib { * arrays (with zero StrideB). */ struct gl_fallback_arrays { - struct gl_client_array Normal; - struct gl_client_array Color; - struct gl_client_array Index; - struct gl_client_array TexCoord[MAX_TEXTURE_UNITS]; - struct gl_client_array EdgeFlag; + struct gl_client_array Normal; + struct gl_client_array Color; + struct gl_client_array Index; + struct gl_client_array TexCoord[MAX_TEXTURE_UNITS]; + struct gl_client_array EdgeFlag; }; #define MAX_PIPELINE_STAGES 30 @@ -1010,10 +1097,10 @@ struct gl_fallback_arrays { * point/line/tri primitives. */ struct gl_prim_state { - GLuint v0, v1; - GLboolean draw; - GLboolean finish_loop; /* not used... */ - struct gl_prim_state *next; + GLuint v0, v1; + GLboolean draw; + GLboolean finish_loop; /* not used... */ + struct gl_prim_state *next; }; @@ -1021,88 +1108,88 @@ typedef void (*vb_func)( struct vertex_buffer *VB ); typedef void (*ctx_func)( GLcontext * ); struct gl_pipeline_stage { - const char *name; - GLuint ops; /* PIPE_OP flags */ - GLuint type; /* PIPE flags */ - GLuint special; /* PIPE flags - force update_inputs() */ - GLuint state_change; /* state flags - trigger update_inputs() */ - GLuint cva_state_change; /* state flags - recalc cva buffer */ - GLuint elt_forbidden_inputs; /* VERT flags - force a pipeline recalc */ - GLuint pre_forbidden_inputs; /* VERT flags - force a pipeline recalc */ - GLuint active; /* PIPE flags */ - GLuint inputs; /* VERT flags */ - GLuint outputs; /* VERT flags */ - void (*check)( GLcontext *ctx, struct gl_pipeline_stage * ); - void (*run)( struct vertex_buffer *VB ); + const char *name; + GLuint ops; /* PIPE_OP flags */ + GLuint type; /* PIPE flags */ + GLuint special; /* PIPE flags - force update_inputs() */ + GLuint state_change; /* state flags - trigger update_inputs() */ + GLuint cva_state_change; /* state flags - recalc cva buffer */ + GLuint elt_forbidden_inputs; /* VERT flags - force a pipeline recalc */ + GLuint pre_forbidden_inputs; /* VERT flags - force a pipeline recalc */ + GLuint active; /* PIPE flags */ + GLuint inputs; /* VERT flags */ + GLuint outputs; /* VERT flags */ + void (*check)( GLcontext *ctx, struct gl_pipeline_stage * ); + void (*run)( struct vertex_buffer *VB ); }; struct gl_pipeline { - GLuint state_change; /* state changes which require recalc */ - GLuint cva_state_change; /* ... which require re-run */ - GLuint forbidden_inputs; /* inputs which require recalc */ - GLuint ops; /* what gets done in this pipe */ - GLuint changed_ops; - GLuint inputs; - GLuint outputs; - GLuint new_inputs; - GLuint new_outputs; - GLuint fallback; - GLuint type; - GLuint pipeline_valid:1; - GLuint data_valid:1; - GLuint copy_transformed_data:1; - GLuint replay_copied_vertices:1; - GLuint new_state; /* state changes since last recalc */ - struct gl_pipeline_stage *stages[MAX_PIPELINE_STAGES]; + GLuint state_change; /* state changes which require recalc */ + GLuint cva_state_change; /* ... which require re-run */ + GLuint forbidden_inputs; /* inputs which require recalc */ + GLuint ops; /* what gets done in this pipe */ + GLuint changed_ops; + GLuint inputs; + GLuint outputs; + GLuint new_inputs; + GLuint new_outputs; + GLuint fallback; + GLuint type; + GLuint pipeline_valid:1; + GLuint data_valid:1; + GLuint copy_transformed_data:1; + GLuint replay_copied_vertices:1; + GLuint new_state; /* state changes since last recalc */ + struct gl_pipeline_stage *stages[MAX_PIPELINE_STAGES]; }; struct gl_cva { - struct gl_pipeline pre; - struct gl_pipeline elt; + struct gl_pipeline pre; + struct gl_pipeline elt; - struct gl_client_array Elt; - trans_1ui_func EltFunc; + struct gl_client_array Elt; + trans_1ui_func EltFunc; - struct vertex_buffer *VB; - struct vertex_arrays v; - struct vertex_data store; + struct vertex_buffer *VB; + struct vertex_arrays v; + struct vertex_data store; - GLuint elt_count; - GLenum elt_mode; - GLuint elt_size; + GLuint elt_count; + GLenum elt_mode; + GLuint elt_size; - GLuint forbidden_inputs; - GLuint orflag; - GLuint merge; + GLuint forbidden_inputs; + GLuint orflag; + GLuint merge; - GLuint lock_changed; - GLuint last_orflag; - GLuint last_array_flags; - GLuint last_array_new_state; + GLuint lock_changed; + GLuint last_orflag; + GLuint last_array_flags; + GLuint last_array_new_state; }; struct gl_feedback { - GLenum Type; - GLuint Mask; - GLfloat *Buffer; - GLuint BufferSize; - GLuint Count; + GLenum Type; + GLuint Mask; + GLfloat *Buffer; + GLuint BufferSize; + GLuint Count; }; struct gl_selection { - GLuint *Buffer; - GLuint BufferSize; /* size of SelectBuffer */ - GLuint BufferCount; /* number of values in SelectBuffer */ - GLuint Hits; /* number of records in SelectBuffer */ - GLuint NameStackDepth; - GLuint NameStack[MAX_NAME_STACK_DEPTH]; - GLboolean HitFlag; - GLfloat HitMinZ, HitMaxZ; + GLuint *Buffer; + GLuint BufferSize; /* size of SelectBuffer */ + GLuint BufferCount; /* number of values in SelectBuffer */ + GLuint Hits; /* number of records in SelectBuffer */ + GLuint NameStackDepth; + GLuint NameStack[MAX_NAME_STACK_DEPTH]; + GLboolean HitFlag; + GLfloat HitMinZ, HitMaxZ; }; @@ -1111,9 +1198,9 @@ struct gl_selection { * 1-D Evaluator control points */ struct gl_1d_map { - GLuint Order; /* Number of control points */ - GLfloat u1, u2, du; /* u1, u2, 1.0/(u2-u1) */ - GLfloat *Points; /* Points to contiguous control points */ + GLuint Order; /* Number of control points */ + GLfloat u1, u2, du; /* u1, u2, 1.0/(u2-u1) */ + GLfloat *Points; /* Points to contiguous control points */ }; @@ -1121,11 +1208,11 @@ struct gl_1d_map { * 2-D Evaluator control points */ struct gl_2d_map { - GLuint Uorder; /* Number of control points in U dimension */ - GLuint Vorder; /* Number of control points in V dimension */ - GLfloat u1, u2, du; - GLfloat v1, v2, dv; - GLfloat *Points; /* Points to contiguous control points */ + GLuint Uorder; /* Number of control points in U dimension */ + GLuint Vorder; /* Number of control points in V dimension */ + GLfloat u1, u2, du; + GLfloat v1, v2, dv; + GLfloat *Points; /* Points to contiguous control points */ }; @@ -1133,27 +1220,27 @@ struct gl_2d_map { * All evalutator control points */ struct gl_evaluators { - /* 1-D maps */ - struct gl_1d_map Map1Vertex3; - struct gl_1d_map Map1Vertex4; - struct gl_1d_map Map1Index; - struct gl_1d_map Map1Color4; - struct gl_1d_map Map1Normal; - struct gl_1d_map Map1Texture1; - struct gl_1d_map Map1Texture2; - struct gl_1d_map Map1Texture3; - struct gl_1d_map Map1Texture4; - - /* 2-D maps */ - struct gl_2d_map Map2Vertex3; - struct gl_2d_map Map2Vertex4; - struct gl_2d_map Map2Index; - struct gl_2d_map Map2Color4; - struct gl_2d_map Map2Normal; - struct gl_2d_map Map2Texture1; - struct gl_2d_map Map2Texture2; - struct gl_2d_map Map2Texture3; - struct gl_2d_map Map2Texture4; + /* 1-D maps */ + struct gl_1d_map Map1Vertex3; + struct gl_1d_map Map1Vertex4; + struct gl_1d_map Map1Index; + struct gl_1d_map Map1Color4; + struct gl_1d_map Map1Normal; + struct gl_1d_map Map1Texture1; + struct gl_1d_map Map1Texture2; + struct gl_1d_map Map1Texture3; + struct gl_1d_map Map1Texture4; + + /* 2-D maps */ + struct gl_2d_map Map2Vertex3; + struct gl_2d_map Map2Vertex4; + struct gl_2d_map Map2Index; + struct gl_2d_map Map2Color4; + struct gl_2d_map Map2Normal; + struct gl_2d_map Map2Texture1; + struct gl_2d_map Map2Texture2; + struct gl_2d_map Map2Texture3; + struct gl_2d_map Map2Texture4; }; @@ -1171,6 +1258,7 @@ struct gl_shared_state { /* Default texture objects (shared by all multi-texture units) */ struct gl_texture_object *DefaultD[4]; + struct gl_texture_object *DefaultCubeMap; }; @@ -1192,11 +1280,16 @@ struct gl_visual { GLint IndexBits; /* Bits/pixel if in color index mode */ - GLint AccumBits; /* Number of bits per color channel, or 0 */ + GLint AccumRedBits; /* Number of bits in red accum channel */ + GLint AccumGreenBits; /* Number of bits in green accum channel */ + GLint AccumBlueBits; /* Number of bits in blue accum channel */ + GLint AccumAlphaBits; /* Number of bits in alpha accum channel */ GLint DepthBits; /* Number of bits in depth buffer, or 0 */ GLint StencilBits; /* Number of bits in stencil buffer, or 0 */ + GLint NumSamples; /* Samples/pixel for multisampling */ - GLboolean SoftwareAlpha; /* Implement software alpha buffer? */ + GLuint DepthMax; /* Max depth buffer value */ + GLfloat DepthMaxF; /* Float max depth buffer value */ }; @@ -1218,7 +1311,7 @@ struct gl_frame_buffer { GLboolean UseSoftwareAlphaBuffers; /* Software depth (aka Z) buffer */ - GLdepth *Depth; /* array [Width*Height] of GLdepth values */ + GLvoid *DepthBuffer; /* array [Width*Height] of GLushort or GLuint*/ /* Software stencil buffer */ GLstencil *Stencil; /* array [Width*Height] of GLstencil values */ @@ -1234,7 +1327,7 @@ struct gl_frame_buffer { GLubyte *Alpha; /* Points to current alpha buffer */ /* Drawing bounds: intersection of window size and scissor box */ - GLint Xmin, Xmax, Ymin, Ymax; + GLint Xmin, Xmax, Ymin, Ymax; /* [Xmin,Xmax] X [Ymin,Ymax] */ }; @@ -1243,6 +1336,7 @@ struct gl_frame_buffer { */ struct gl_constants { GLint MaxTextureSize; + GLint MaxCubeTextureSize; GLint MaxTextureLevels; GLuint MaxTextureUnits; GLuint MaxArrayLockSize; @@ -1254,6 +1348,11 @@ struct gl_constants { GLfloat MinLineWidthAA, MaxLineWidthAA; /* antialiased */ GLfloat LineWidthGranularity; GLuint NumAuxBuffers; + GLuint MaxColorTableSize; + GLuint MaxConvolutionWidth; + GLuint MaxConvolutionHeight; + GLuint NumCompressedTextureFormats; /* GL_ARB_texture_compression */ + GLenum CompressedTextureFormats[MAX_COMPRESSED_TEXTURE_FORMATS]; }; @@ -1264,6 +1363,14 @@ struct extension; struct gl_extensions { char *ext_string; struct extension *ext_list; + /* flags to quickly test if certain extensions are available */ + GLboolean HaveTextureEnvAdd; + GLboolean HaveTextureLodBias; + GLboolean HaveHpOcclusionTest; + GLboolean HaveTextureCubeMap; + GLboolean HaveTextureCompression; + GLboolean HaveTextureCompressionS3TC; + GLboolean HaveTextureCompressionFXT1; }; @@ -1282,6 +1389,9 @@ struct gl_extensions { #define WINCLIP_BIT 0x200 /* Clip pixels/primitives to window */ #define MULTI_DRAW_BIT 0x400 /* Write to more than one color- */ /* buffer or no buffers. */ +#define OCCLUSION_BIT 0x800 /* GL_HP_occlusion_test enabled */ +#define TEXTURE_BIT 0x1000 /* Texturing really enabled */ + /* * Bits to indicate what state has to be updated (NewState) @@ -1304,6 +1414,7 @@ struct gl_extensions { #define NEW_NORMAL_TRANSFORM 0x8000 #define NEW_VIEWPORT 0x10000 #define NEW_TEXTURE_ENABLE 0x20000 +#define NEW_COLOR_MATRIX 0x40000 #define NEW_ALL ~0 @@ -1338,6 +1449,9 @@ struct gl_extensions { #define DD_TRI_CULL_FRONT_BACK 0x400000 /* not supported by most drivers */ #define DD_Z_NEVER 0x800000 #define DD_STENCIL 0x1000000 +#define DD_CLIP_FOG_COORD 0x2000000 + + #define DD_SW_SETUP (DD_TRI_CULL| \ DD_TRI_CULL_FRONT_BACK| \ @@ -1540,7 +1654,8 @@ typedef union node Node; #define VERT_EVAL_C2 0x2000000 /* - or just use 3 bits */ #define VERT_EVAL_P1 0x4000000 /* */ #define VERT_EVAL_P2 0x8000000 /* */ -#define VERT_FLOAT_RGBA 0x10000000 /* allow partial support for this */ +#define VERT_SPEC_RGB 0x10000000 +#define VERT_FOG_COORD 0x20000000 /* internal use only, currently */ #define VERT_EYE VERT_BEGIN /* for pipeline management & cva */ #define VERT_WIN VERT_END /* some overlaps can be tolerated */ @@ -1591,7 +1706,7 @@ typedef union node Node; #define VERT_DATA (VERT_TEX0_ANY|VERT_TEX1_ANY|VERT_RGBA| \ VERT_INDEX|VERT_EDGE|VERT_NORM| \ VERT_OBJ_ANY|VERT_MATERIAL|VERT_ELT| \ - VERT_EVAL_ANY) + VERT_EVAL_ANY|VERT_FOG_COORD) #define VERT_TO_PIPE (~VERT_END_VB) @@ -1626,233 +1741,232 @@ typedef GLuint (*clip_poly_func)( struct vertex_buffer *VB, */ struct gl_context { - /* State possibly shared with other contexts in the address space */ - struct gl_shared_state *Shared; + /* State possibly shared with other contexts in the address space */ + struct gl_shared_state *Shared; - /* API function pointer tables */ - struct _glapi_table *Save; /* Display list save funcs */ - struct _glapi_table *Exec; /* Execute funcs */ - struct _glapi_table *CurrentDispatch; /* == Save or Exec !! */ + /* API function pointer tables */ + struct _glapi_table *Save; /* Display list save funcs */ + struct _glapi_table *Exec; /* Execute funcs */ + struct _glapi_table *CurrentDispatch; /* == Save or Exec !! */ - GLvisual *Visual; - GLframebuffer *DrawBuffer; /* buffer for writing */ - GLframebuffer *ReadBuffer; /* buffer for reading */ + GLvisual *Visual; + GLframebuffer *DrawBuffer; /* buffer for writing */ + GLframebuffer *ReadBuffer; /* buffer for reading */ - /* Driver function pointer table */ - struct dd_function_table Driver; + /* Driver function pointer table */ + struct dd_function_table Driver; - triangle_func TriangleFunc; /* driver or indirect triangle func */ - quad_func QuadFunc; - triangle_func ClippedTriangleFunc; - clip_poly_func *poly_clip_tab; - clip_line_func *line_clip_tab; - - void *DriverCtx; /* Points to device driver context/state */ - void *DriverMgrCtx; /* Points to device driver manager (optional)*/ - - /* Core/Driver constants */ - struct gl_constants Const; - - /* Modelview matrix and stack */ - GLmatrix ModelView; /* current matrix, not stored on stack */ - GLuint ModelViewStackDepth; - GLmatrix ModelViewStack[MAX_MODELVIEW_STACK_DEPTH - 1]; - - /* Projection matrix and stack */ - GLmatrix ProjectionMatrix; /* current matrix, not stored on stack */ - GLuint ProjectionStackDepth; - GLmatrix ProjectionStack[MAX_PROJECTION_STACK_DEPTH - 1]; - GLfloat NearFarStack[MAX_PROJECTION_STACK_DEPTH - 1][2]; - - /* Combined modelview and projection matrix */ - GLmatrix ModelProjectMatrix; - - /* Combined modelview, projection and window matrix */ - GLmatrix ModelProjectWinMatrix; - GLboolean ModelProjectWinMatrixUptodate; - - /* Texture matrix and stack */ - GLmatrix TextureMatrix[MAX_TEXTURE_UNITS]; - GLuint TextureStackDepth[MAX_TEXTURE_UNITS]; - GLmatrix TextureStack[MAX_TEXTURE_UNITS][MAX_TEXTURE_STACK_DEPTH - 1]; - - /* Display lists */ - GLuint CallDepth; /* Current recursion calling depth */ - GLboolean ExecuteFlag; /* Execute GL commands? */ - GLboolean CompileFlag; /* Compile GL commands into display list? */ - GLboolean CompileCVAFlag; - Node *CurrentListPtr; /* Head of list being compiled */ - GLuint CurrentListNum; /* Number of the list being compiled */ - Node *CurrentBlock; /* Pointer to current block of nodes */ - GLuint CurrentPos; /* Index into current block of nodes */ - - /* Extensions */ - struct gl_extensions Extensions; - - - /* Pipeline stages - shared between the two pipelines, - * which live in CVA. - */ - struct gl_pipeline_stage PipelineStage[MAX_PIPELINE_STAGES]; - GLuint NrPipelineStages; - - /* Cva */ - struct gl_cva CVA; - - /* Renderer attribute stack */ - GLuint AttribStackDepth; - struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; - - /* Renderer attribute groups */ - struct gl_accum_attrib Accum; - struct gl_colorbuffer_attrib Color; - struct gl_current_attrib Current; - struct gl_depthbuffer_attrib Depth; - struct gl_eval_attrib Eval; - struct gl_fog_attrib Fog; - struct gl_hint_attrib Hint; - struct gl_light_attrib Light; - struct gl_line_attrib Line; - struct gl_list_attrib List; - struct gl_pixel_attrib Pixel; - struct gl_point_attrib Point; - struct gl_polygon_attrib Polygon; - GLuint PolygonStipple[32]; - struct gl_scissor_attrib Scissor; - struct gl_stencil_attrib Stencil; - struct gl_texture_attrib Texture; - struct gl_transform_attrib Transform; - struct gl_viewport_attrib Viewport; - - /* Client attribute stack */ - GLuint ClientAttribStackDepth; - struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; - - /* Client attribute groups */ - struct gl_array_attrib Array; /* Vertex arrays */ - struct gl_pixelstore_attrib Pack; /* Pixel packing */ - struct gl_pixelstore_attrib Unpack; /* Pixel unpacking */ - - struct gl_evaluators EvalMap; /* All evaluators */ - struct gl_feedback Feedback; /* Feedback */ - struct gl_selection Select; /* Selection */ - - /* Optimized Accumulation buffer info */ - GLboolean IntegerAccumMode; /* Storing unscaled integers? */ - GLfloat IntegerAccumScaler; /* Implicit scale factor */ - - - struct gl_fallback_arrays Fallback; - - GLenum ErrorValue; /* Last error code */ - - /* Miscellaneous */ - GLuint NewState; /* bitwise OR of NEW_* flags */ - GLuint Enabled; /* bitwise or of ENABLE_* flags */ - GLenum RenderMode; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */ - GLuint StippleCounter; /* Line stipple counter */ - GLuint RasterMask; /* OR of rasterization flags */ - GLuint TriangleCaps; /* OR of DD_* flags */ - GLuint IndirectTriangles; /* TriangleCaps not handled by the driver */ - GLfloat PolygonZoffset; /* Z offset for GL_FILL polygons */ - GLfloat LineZoffset; /* Z offset for GL_LINE polygons */ - GLfloat PointZoffset; /* Z offset for GL_POINT polygons */ - GLboolean NeedNormals; /* Are vertex normal vectors needed? */ - GLboolean MutablePixels;/* Can rasterization change pixel's color? */ - GLboolean MonoPixels; /* Are all pixels likely to be same color? */ - GLuint FogMode; /* FOG_OFF, FOG_VERTEX or FOG_FRAGMENT */ - - GLboolean DoViewportMapping; - - - GLuint RenderFlags; /* Active inputs to render stage */ - - GLuint RequireWriteableFlags; /* What can the driver/clipping tolerate? */ - - /* Points to function which interpolates colors, etc when clipping */ - clip_interp_func ClipInterpFunc; - GLuint ClipTabMask; - - normal_func *NormalTransform; - - /* Current shading function */ - GLuint shade_func_flags; - - GLfloat EyeZDir[3]; - GLfloat rescale_factor; - - GLfloat vb_rescale_factor; - GLmatrix *vb_proj_matrix; - - GLubyte AllowVertexCull; /* To be set by the geometry driver */ - GLboolean NeedEyeCoords; - GLboolean NeedEyeNormals; - GLboolean NeedClipCoords; - - GLfloat backface_sign; - - /* Destination of immediate mode commands */ - struct immediate *input; - - - /* Cache of unused immediate structs - */ - struct immediate *freed_im_queue; - GLuint nr_im_queued; - - /* The vertex buffer being used by this context. - */ - struct vertex_buffer *VB; + triangle_func TriangleFunc; /* driver or indirect triangle func */ + quad_func QuadFunc; + triangle_func ClippedTriangleFunc; + clip_poly_func *poly_clip_tab; + clip_line_func *line_clip_tab; + + void *DriverCtx; /* Points to device driver context/state */ + void *DriverMgrCtx; /* Points to device driver manager (optional)*/ + + /* Core/Driver constants */ + struct gl_constants Const; + + /* Modelview matrix and stack */ + GLmatrix ModelView; /* current matrix, not stored on stack */ + GLuint ModelViewStackDepth; + GLmatrix ModelViewStack[MAX_MODELVIEW_STACK_DEPTH - 1]; + + /* Projection matrix and stack */ + GLmatrix ProjectionMatrix; /* current matrix, not stored on stack */ + GLuint ProjectionStackDepth; + GLmatrix ProjectionStack[MAX_PROJECTION_STACK_DEPTH - 1]; + GLfloat NearFarStack[MAX_PROJECTION_STACK_DEPTH - 1][2]; + + /* Combined modelview and projection matrix */ + GLmatrix ModelProjectMatrix; + + /* Combined modelview, projection and window matrix */ + GLmatrix ModelProjectWinMatrix; + GLboolean ModelProjectWinMatrixUptodate; + + /* Texture matrix and stack */ + GLmatrix TextureMatrix[MAX_TEXTURE_UNITS]; + GLuint TextureStackDepth[MAX_TEXTURE_UNITS]; + GLmatrix TextureStack[MAX_TEXTURE_UNITS][MAX_TEXTURE_STACK_DEPTH - 1]; + + /* Color matrix and stack */ + GLmatrix ColorMatrix; + GLuint ColorStackDepth; + GLmatrix ColorStack[MAX_COLOR_STACK_DEPTH - 1]; + + /* Display lists */ + GLuint CallDepth; /* Current recursion calling depth */ + GLboolean ExecuteFlag; /* Execute GL commands? */ + GLboolean CompileFlag; /* Compile GL commands into display list? */ + GLboolean CompileCVAFlag; + Node *CurrentListPtr; /* Head of list being compiled */ + GLuint CurrentListNum; /* Number of the list being compiled */ + Node *CurrentBlock; /* Pointer to current block of nodes */ + GLuint CurrentPos; /* Index into current block of nodes */ + + /* Extensions */ + struct gl_extensions Extensions; + + + /* Pipeline stages - shared between the two pipelines, + * which live in CVA. + */ + struct gl_pipeline_stage PipelineStage[MAX_PIPELINE_STAGES]; + GLuint NrPipelineStages; + + /* Cva */ + struct gl_cva CVA; + + /* Renderer attribute stack */ + GLuint AttribStackDepth; + struct gl_attrib_node *AttribStack[MAX_ATTRIB_STACK_DEPTH]; + + /* Renderer attribute groups */ + struct gl_accum_attrib Accum; + struct gl_colorbuffer_attrib Color; + struct gl_current_attrib Current; + struct gl_depthbuffer_attrib Depth; + struct gl_eval_attrib Eval; + struct gl_fog_attrib Fog; + struct gl_hint_attrib Hint; + struct gl_light_attrib Light; + struct gl_line_attrib Line; + struct gl_list_attrib List; + struct gl_pixel_attrib Pixel; + struct gl_point_attrib Point; + struct gl_polygon_attrib Polygon; + GLuint PolygonStipple[32]; + struct gl_scissor_attrib Scissor; + struct gl_stencil_attrib Stencil; + struct gl_texture_attrib Texture; + struct gl_transform_attrib Transform; + struct gl_viewport_attrib Viewport; + + /* Other attribute groups */ + struct gl_histogram_attrib Histogram; + struct gl_minmax_attrib MinMax; + struct gl_convolution_attrib Convolution1D; + struct gl_convolution_attrib Convolution2D; + struct gl_convolution_attrib Separable2D; + + /* Client attribute stack */ + GLuint ClientAttribStackDepth; + struct gl_attrib_node *ClientAttribStack[MAX_CLIENT_ATTRIB_STACK_DEPTH]; + + /* Client attribute groups */ + struct gl_array_attrib Array; /* Vertex arrays */ + struct gl_pixelstore_attrib Pack; /* Pixel packing */ + struct gl_pixelstore_attrib Unpack; /* Pixel unpacking */ + + struct gl_evaluators EvalMap; /* All evaluators */ + struct gl_feedback Feedback; /* Feedback */ + struct gl_selection Select; /* Selection */ + + struct gl_color_table ColorTable; /* Pre-convolution */ + struct gl_color_table ProxyColorTable; /* Pre-convolution */ + struct gl_color_table PostConvolutionColorTable; + struct gl_color_table ProxyPostConvolutionColorTable; + struct gl_color_table PostColorMatrixColorTable; + struct gl_color_table ProxyPostColorMatrixColorTable; + + /* Optimized Accumulation buffer info */ + GLboolean IntegerAccumMode; /* Storing unscaled integers? */ + GLfloat IntegerAccumScaler; /* Implicit scale factor */ + + struct gl_fallback_arrays Fallback; + + GLenum ErrorValue; /* Last error code */ + + /* Miscellaneous */ + GLuint NewState; /* bitwise OR of NEW_* flags */ + GLuint Enabled; /* bitwise or of ENABLE_* flags */ + GLenum RenderMode; /* either GL_RENDER, GL_SELECT, GL_FEEDBACK */ + GLuint StippleCounter; /* Line stipple counter */ + GLuint RasterMask; /* OR of rasterization flags */ + GLuint TriangleCaps; /* OR of DD_* flags */ + GLuint IndirectTriangles; /* TriangleCaps not handled by the driver */ + GLfloat PolygonZoffset; /* Z offset for GL_FILL polygons */ + GLfloat LineZoffset; /* Z offset for GL_LINE polygons */ + GLfloat PointZoffset; /* Z offset for GL_POINT polygons */ + GLboolean NeedNormals; /* Are vertex normal vectors needed? */ + GLuint FogMode; /* FOG_OFF, FOG_VERTEX or FOG_FRAGMENT */ + + GLboolean DoViewportMapping; + + GLuint RenderFlags; /* Active inputs to render stage */ + + GLuint RequireWriteableFlags; /* What can the driver/clipping tolerate? */ + + /* Points to function which interpolates colors, etc when clipping */ + clip_interp_func ClipInterpFunc; + GLuint ClipTabMask; + + normal_func *NormalTransform; + + /* Current shading function */ + GLuint shade_func_flags; + + GLfloat EyeZDir[3]; + GLfloat rescale_factor; + + GLfloat vb_rescale_factor; + GLmatrix *vb_proj_matrix; + + GLubyte AllowVertexCull; /* To be set by the geometry driver */ + GLboolean NeedEyeCoords; + GLboolean NeedEyeNormals; + GLboolean NeedClipCoords; + + GLfloat backface_sign; + + GLboolean OcclusionResult; /* GL_HP_occlusion_test */ + GLboolean OcclusionResultSaved; /* GL_HP_occlusion_test */ + + /* Destination of immediate mode commands */ + struct immediate *input; + + + /* Cache of unused immediate structs + */ + struct immediate *freed_im_queue; + GLuint nr_im_queued; + + /* The vertex buffer being used by this context. + */ + struct vertex_buffer *VB; - /* The pixel buffer being used by this context */ - struct pixel_buffer* PB; - - struct gl_shine_tab *ShineTable[4]; /* Active shine tables */ - struct gl_shine_tab *ShineTabList; /* Mru list of inactive shine tables */ - - -#ifdef PROFILE - /* Performance measurements */ - GLuint BeginEndCount; /* number of glBegin/glEnd pairs */ - GLdouble BeginEndTime; /* seconds spent between glBegin/glEnd */ - GLuint VertexCount; /* number of vertices processed */ - GLdouble VertexTime; /* total time in seconds */ - GLuint PointCount; /* number of points rendered */ - GLdouble PointTime; /* total time in seconds */ - GLuint LineCount; /* number of lines rendered */ - GLdouble LineTime; /* total time in seconds */ - GLuint PolygonCount; /* number of polygons rendered */ - GLdouble PolygonTime; /* total time in seconds */ - GLuint ClearCount; /* number of glClear calls */ - GLdouble ClearTime; /* seconds spent in glClear */ - GLuint SwapCount; /* number of swap-buffer calls */ - GLdouble SwapTime; /* seconds spent in swap-buffers */ -#endif + /* The pixel buffer being used by this context */ + struct pixel_buffer* PB; + struct gl_shine_tab *ShineTable[4]; /* Active shine tables */ + struct gl_shine_tab *ShineTabList; /* Mru list of inactive shine tables */ - /* Should 3Dfx Glide driver catch signals? */ - GLboolean CatchSignals; + /* Should 3Dfx Glide driver catch signals? */ + GLboolean CatchSignals; - /* For debugging/development only */ - GLboolean NoRaster; - GLboolean FirstTimeCurrent; + /* For debugging/development only */ + GLboolean NoRaster; + GLboolean FirstTimeCurrent; - /* Dither disable via MESA_NO_DITHER env var */ - GLboolean NoDither; + /* Dither disable via MESA_NO_DITHER env var */ + GLboolean NoDither; }; -#ifndef MESA_DEBUG +#ifdef MESA_DEBUG +extern int MESA_VERBOSE; +extern int MESA_DEBUG_FLAGS; +#else # define MESA_VERBOSE 0 # define MESA_DEBUG_FLAGS 0 # ifndef NDEBUG # define NDEBUG # endif -#else -extern int MESA_VERBOSE; -extern int MESA_DEBUG_FLAGS; #endif + enum _verbose { VERBOSE_VARRAY = 0x1, VERBOSE_TEXTURE = 0x2, @@ -1863,7 +1977,8 @@ enum _verbose { VERBOSE_API = 0x40, VERBOSE_TRIANGLE_CHECKS = 0x80, VERBOSE_CULL = 0x100, - VERBOSE_DISPLAY_LIST = 0x200 + VERBOSE_DISPLAY_LIST = 0x200, + VERBOSE_LIGHTING = 0x400 }; diff --git a/xc/extras/Mesa/src/vb.c b/xc/extras/Mesa/src/vb.c index 1677806b6..7dcb64b10 100644 --- a/xc/extras/Mesa/src/vb.c +++ b/xc/extras/Mesa/src/vb.c @@ -271,7 +271,11 @@ struct immediate *gl_immediate_alloc( GLcontext *ctx ) IM->Start = VB_START; IM->Material = 0; IM->MaterialMask = 0; - +#ifdef VMS + for (j=0; j<VB_SIZE ; j++ ) + IM->Normal[j][0] = IM->Normal[j][1] = IM->Normal[j][2] = 0.0; +#endif + if (MESA_VERBOSE&VERBOSE_IMMEDIATE) fprintf(stderr, "alloc immediate %d\n", id); diff --git a/xc/extras/Mesa/src/vbrender.c b/xc/extras/Mesa/src/vbrender.c index ff493f5fc..9ee4fbb8c 100644 --- a/xc/extras/Mesa/src/vbrender.c +++ b/xc/extras/Mesa/src/vbrender.c @@ -164,7 +164,7 @@ static void unfilled_polygon( GLcontext *ctx, j1 = vlist[i+1]; if (edge_ptr[j0] & 0x1) { - edge_ptr[j0] &= ~1; + edge_ptr[j0] &= ~0x1; (*ctx->Driver.LineFunc)( ctx, j0, j1, pv ); } } @@ -174,7 +174,7 @@ static void unfilled_polygon( GLcontext *ctx, j1 = vlist[0]; if (edge_ptr[j0] & 0x2) { - edge_ptr[j0] &= ~2; + edge_ptr[j0] &= ~0x2; (*ctx->Driver.LineFunc)( ctx, j0, j1, pv ); } } @@ -219,7 +219,9 @@ static INLINE void gl_render_clipped_triangle2( GLcontext *ctx, GLuint pv ) { struct vertex_buffer *VB = ctx->VB; - GLubyte mask = (GLubyte) (VB->ClipMask[v1] | VB->ClipMask[v2] | VB->ClipMask[v3]); + GLubyte mask = (GLubyte) (VB->ClipMask[v1] | + VB->ClipMask[v2] | + VB->ClipMask[v3]); GLuint vlist[VB_MAX_CLIPPED_VERTS]; GLuint i, n; @@ -233,7 +235,38 @@ static INLINE void gl_render_clipped_triangle2( GLcontext *ctx, ASSIGN_3V(vlist, v1, v2, v3 ); n = (ctx->poly_clip_tab[VB->ClipPtr->size])( VB, 3, vlist, mask ); - + + for (i=2;i<n;i++) + ctx->TriangleFunc( ctx, *vlist, vlist[i-1], vlist[i], pv ); +} + + +static INLINE void gl_render_clipped_quad2( GLcontext *ctx, + GLuint v1, GLuint v2, GLuint v3, + GLuint v4, + GLuint pv ) +{ + struct vertex_buffer *VB = ctx->VB; + GLubyte mask = (GLubyte) (VB->ClipMask[v1] | + VB->ClipMask[v2] | + VB->ClipMask[v3] | + VB->ClipMask[v4]); + GLuint vlist[VB_MAX_CLIPPED_VERTS]; + GLuint i, n; + + if (!mask) { + ctx->QuadFunc( ctx, v1, v2, v3, v4, pv ); + return; + } + + if (CLIP_ALL_BITS & VB->ClipMask[v1] & + VB->ClipMask[v2] & VB->ClipMask[v3] & + VB->ClipMask[v4]) + return; + + ASSIGN_4V(vlist, v1, v2, v3, v4 ); + n = (ctx->poly_clip_tab[VB->ClipPtr->size])( VB, 4, vlist, mask ); + for (i=2;i<n;i++) ctx->TriangleFunc( ctx, *vlist, vlist[i-1], vlist[i], pv ); } @@ -309,16 +342,14 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1, GLfloat fy = win[v3][1] - win[v1][1]; GLfloat c = ex*fy-ey*fx; GLuint facing; - GLuint tricaps; + GLuint tricaps = ctx->IndirectTriangles; if (c * ctx->backface_sign > 0) return; facing = (c<0.0F) ^ (ctx->Polygon.FrontFace==GL_CW); - tricaps = ctx->IndirectTriangles; - (void) tricaps; /* not needed? */ - if (ctx->IndirectTriangles & DD_TRI_OFFSET) { + if (tricaps & DD_TRI_OFFSET) { GLfloat ez = win[v2][2] - win[v0][2]; GLfloat fz = win[v3][2] - win[v1][2]; GLfloat a = ey*fz-ez*fy; @@ -327,7 +358,7 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1, } - if (ctx->IndirectTriangles & DD_TRI_LIGHT_TWOSIDE) { + if (tricaps & DD_TRI_LIGHT_TWOSIDE) { VB->Specular = VB->Spec[facing]; VB->ColorPtr = VB->Color[facing]; VB->IndexPtr = VB->Index[facing]; @@ -335,7 +366,7 @@ static void render_quad( GLcontext *ctx, GLuint v0, GLuint v1, /* Render the quad! */ - if (ctx->IndirectTriangles & DD_TRI_UNFILLED) { + if (tricaps & DD_TRI_UNFILLED) { GLuint vlist[4]; vlist[0] = v0; vlist[1] = v1; @@ -373,9 +404,7 @@ extern const char *gl_prim_name[]; #define EDGEFLAG_TRI( i2, i1, i, pv, parity) \ do { \ - GLuint e1=i1, e0=i; \ - if (parity) { GLuint t=e1; e1=e0; e0=t; } \ - eflag[i2] = eflag[e1] = 1; eflag[e0] = 2; \ + eflag[i2] = eflag[i1] = 1; eflag[i] = 2; \ } while (0) #define EDGEFLAG_QUAD( i3, i2, i1, i, pv) \ @@ -384,6 +413,21 @@ do { \ } while (0) +#define EDGEFLAG_POLY_TRI_PRE( i2, i1, i, pv) \ +do { \ + eflag[i1] |= (eflag[i1] >> 2) & 1; \ + eflag[i] |= (eflag[i] >> 2) & 2; \ +} while (0) + +#define EDGEFLAG_POLY_TRI_POST( i2, i1, i, pv) \ +do { \ + eflag[i2] = 0; \ + eflag[i1] &= ~(4|1); \ + eflag[i] &= ~(8|2); \ +} while (0) + + + /* Culled and possibly clipped primitives. */ #define RENDER_POINTS( start, count ) \ @@ -455,10 +499,12 @@ do { \ const GLubyte *cullmask = VB->CullMask; \ GLuint vlist[VB_SIZE]; \ GLubyte *eflag = VB->EdgeFlagPtr->data; \ - (void) vlist; (void) eflag; + GLuint *stipplecounter = &VB->ctx->StippleCounter; \ + (void) vlist; (void) eflag; (void) stipplecounter; #define TAG(x) x##_cull #define INIT(x) FLUSH_PRIM(x) +#define RESET_STIPPLE *stipplecounter = 0 #include "render_tmp.h" @@ -492,9 +538,11 @@ do { \ #define LOCAL_VARS \ GLcontext *ctx = VB->ctx; \ GLubyte *eflag = VB->EdgeFlagPtr->data; \ - (void) eflag; + GLuint *stipplecounter = &VB->ctx->StippleCounter; \ + (void) eflag; (void) stipplecounter; #define INIT(x) FLUSH_PRIM(x); +#define RESET_STIPPLE *stipplecounter = 0 #include "render_tmp.h" @@ -510,24 +558,27 @@ do { \ #define RENDER_TRI( i2, i1, i, pv, parity) \ do { \ - GLuint e1=i1, e0=i; \ - if (parity) { GLuint t=e1; e1=e0; e0=t; } \ - gl_render_clipped_triangle2(ctx,i2,e1,e0,pv); \ + GLuint e2=i2, e1=i1; \ + if (parity) { GLuint t=e2; e2=e1; e1=t; } \ + gl_render_clipped_triangle2(ctx,e2,e1,i,pv); \ } while (0) #define RENDER_QUAD( i3, i2, i1, i, pv) \ do { \ - gl_render_clipped_triangle2(ctx,i3,i2,i1,pv); \ - gl_render_clipped_triangle2(ctx,i3,i1,i,pv); \ + gl_render_clipped_quad2(ctx,i3,i2,i1,i,pv); \ } while (0) #define LOCAL_VARS \ GLcontext *ctx = VB->ctx; \ GLubyte *eflag = VB->EdgeFlagPtr->data; \ - (void) eflag; + GLuint *stipplecounter = &VB->ctx->StippleCounter; \ + (void) eflag; (void) stipplecounter; + #define INIT(x) FLUSH_PRIM(x); #define TAG(x) x##_clipped +#define RESET_STIPPLE *stipplecounter = 0 + #include "render_tmp.h" /* Bits: @@ -566,24 +617,25 @@ setup_edgeflag( struct vertex_buffer *VB, switch (prim) { case GL_TRIANGLES: for (i = 0 ; i < n-2 ; i+=3) { - if (flag[i]) flag[i] = 0x5; - if (flag[i+1]) flag[i+1] = 0x5; - if (flag[i+2]) flag[i+2] = 0x6; + if (flag[i]) flag[i] = 0x1; + if (flag[i+1]) flag[i+1] = 0x1; + if (flag[i+2]) flag[i+2] = 0x3; } break; case GL_QUADS: for (i = 0 ; i < n-3 ; i+=4) { - if (flag[i]) flag[i] = 0x5; - if (flag[i+1]) flag[i+1] = 0x5; - if (flag[i+2]) flag[i+2] = 0x5; - if (flag[i+3]) flag[i+3] = 0x6; + if (flag[i]) flag[i] = 0x1; + if (flag[i+1]) flag[i+1] = 0x1; + if (flag[i+2]) flag[i+2] = 0x1; + if (flag[i+3]) flag[i+3] = 0x3; } break; case GL_POLYGON: - for (i = 0 ; i < n-1 ; i++) { - if (flag[i]) flag[i] = 0x5; + if (flag[0]) flag[0] = 0x1; + for (i = 1 ; i < n-1 ; i++) { + if (flag[i]) flag[i] = 0x1<<2; } - if (flag[i]) flag[i] = 0x6; + if (flag[i]) flag[i] = 0x3<<2; break; default: break; @@ -667,12 +719,12 @@ void gl_reduced_prim_change( GLcontext *ctx, GLenum prim ) if (ctx->PB->count > 0) gl_flush_pb(ctx); - ctx->PB->count = 0; - ctx->PB->mono = GL_FALSE; - ctx->PB->primitive = prim; + if (ctx->PB->primitive != prim) { + ctx->PB->primitive = prim; - if (ctx->Driver.ReducedPrimitiveChange) - ctx->Driver.ReducedPrimitiveChange( ctx, prim ); + if (ctx->Driver.ReducedPrimitiveChange) + ctx->Driver.ReducedPrimitiveChange( ctx, prim ); + } } diff --git a/xc/include/GL/Imakefile b/xc/include/GL/Imakefile index 2e18a43cb..2ac6c9e0e 100644 --- a/xc/include/GL/Imakefile +++ b/xc/include/GL/Imakefile @@ -3,9 +3,10 @@ XCOMM $XFree86: xc/include/GL/Imakefile,v 1.8 2000/03/02 16:07:29 martin Exp $ LinkSourceFile(gl.h, ../../extras/Mesa/include/GL) LinkSourceFile(glext.h, ../../extras/Mesa/include/GL) +LinkSourceFile(osmesa.h, ../../extras/Mesa/include/GL) #if BuildGLXLibrary -GLXHEADERS = gl.h glext.h glx.h glxint.h glxmd.h glxproto.h glxtokens.h +GLXHEADERS = gl.h glext.h glx.h glxint.h glxmd.h glxproto.h glxtokens.h osmesa.h #endif HEADERS = $(GLXHEADERS) diff --git a/xc/lib/GL/Imakefile b/xc/lib/GL/Imakefile index a185089e4..c882109e1 100644 --- a/xc/lib/GL/Imakefile +++ b/xc/lib/GL/Imakefile @@ -11,21 +11,20 @@ XCOMM $XFree86: xc/lib/GL/Imakefile,v 1.16 2000/03/02 16:07:30 martin Exp $ #define DoDebugLib DebugLibGlx #define DoProfileLib ProfileLibGlx -#if BuildXF86DRI -DRIDIRS = dri -MESADIRS = mesa/dri mesa/include/GL mesa/src -#endif -SUBDIRS = glx $(DRIDIRS) $(MESADIRS) + LIBNAME = GL + SOREV = $(SOGLREV) #ifdef SharedGLReqs REQUIREDLIBS = SharedGLReqs #endif -MakeSubdirs($(SUBDIRS)) -DependSubdirs($(SUBDIRS)) +#if 0 + LOWSRC = lowpc.c + LOWOBJ = lowpc.o - LIBNAME = GL - SOREV = $(SOGLREV) + HISRC = highpc.c + HIOBJ = highpc.o +#endif GLXOBJS = glx/?*.o GLXUOBJS = glx/unshared/?*.o @@ -40,19 +39,17 @@ DependSubdirs($(SUBDIRS)) DRIPOBJS = dri/profiled/XF86dri.o dri/profiled/dri_glx.o DRIDONES = dri/DONE -#if !GlxUseSGISI -#if GlxBuiltInGamma DRMOBJS = dri/drm/?*.o DRMUOBJS = dri/drm/unshared/?*.o DRMDOBJS = dri/drm/debugger/?*.o DRMPOBJS = dri/drm/profiled/?*.o DRMDONES = dri/drm/DONE - GAMMAOBJS = mesa/src/drv/gamma/?*.o - GAMMAUOBJS = mesa/src/drv/gamma/unshared/?*.o - GAMMADOBJS = mesa/src/drv/gamma/debugger/?*.o - GAMMAPOBJS = mesa/src/drv/gamma/profiled/?*.o - GAMMADONES = mesa/src/drv/gamma/DONE + MESAOBJS = mesa/src/?*.o mesa/src/X86/?*.o + MESAUOBJS = mesa/src/unshared/?*.o mesa/src/X86/unshared/?*.o + MESADOBJS = mesa/src/debugger/?*.o mesa/src/X86/debugger/?*.o + MESAPOBJS = mesa/src/profiled/?*.o mesa/src/X86/profiled/?*.o + MESADONES = mesa/src/DONE mesa/src/X86/DONE DRIMESAOBJS = mesa/dri/?*.o DRIMESAUOBJS = mesa/dri/unshared/?*.o @@ -60,18 +57,34 @@ DRIMESADOBJS = mesa/dri/debugger/?*.o DRIMESAPOBJS = mesa/dri/profiled/?*.o DRIMESADONES = mesa/dri/DONE + COMMONOBJS = mesa/src/drv/common/?*.o + COMMONUOBJS = mesa/src/drv/common/unshared/?*.o + COMMONDOBJS = mesa/src/drv/common/debugger/?*.o + COMMONPOBJS = mesa/src/drv/common/profiled/?*.o + COMMONDONES = mesa/src/drv/common/DONE + + +#if GlxUseSGISI + +XCOMM nothing + +#elif GlxBuiltInGamma + + GAMMAOBJS = mesa/src/drv/gamma/?*.o + GAMMAUOBJS = mesa/src/drv/gamma/unshared/?*.o + GAMMADOBJS = mesa/src/drv/gamma/debugger/?*.o + GAMMAPOBJS = mesa/src/drv/gamma/profiled/?*.o + GAMMADONES = mesa/src/drv/gamma/DONE + DRVOBJS = $(GAMMAOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) DRVUOBJS = $(GAMMAUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) DRVDOBJS = $(GAMMADOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) DRVPOBJS = $(GAMMAPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) DRVDONES = $(GAMMADONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + #elif GlxBuiltInTdfx - DRMOBJS = dri/drm/?*.o - DRMUOBJS = dri/drm/unshared/?*.o - DRMDOBJS = dri/drm/debugger/?*.o - DRMPOBJS = dri/drm/profiled/?*.o - DRMDONES = dri/drm/DONE TDFXOBJS = mesa/src/drv/tdfx/?*.o TDFXUOBJS = mesa/src/drv/tdfx/unshared/?*.o @@ -79,51 +92,131 @@ DRIMESADONES = mesa/dri/DONE TDFXPOBJS = mesa/src/drv/tdfx/profiled/?*.o TDFXDONES = mesa/src/drv/tdfx/DONE - MESAOBJS = mesa/src/?*.o mesa/src/X86/?*.o - MESAUOBJS = mesa/src/unshared/?*.o mesa/src/X86/unshared/?*.o - MESADOBJS = mesa/src/debugger/?*.o mesa/src/X86/debugger/?*.o - MESAPOBJS = mesa/src/profiled/?*.o mesa/src/X86/profiled/?*.o - MESADONES = mesa/src/DONE mesa/src/X86/DONE - - DRIMESAOBJS = mesa/dri/?*.o -DRIMESAUOBJS = mesa/dri/unshared/?*.o -DRIMESADOBJS = mesa/dri/debugger/?*.o -DRIMESAPOBJS = mesa/dri/profiled/?*.o -DRIMESADONES = mesa/dri/DONE - DRVOBJS = $(TDFXOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) DRVUOBJS = $(TDFXUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) DRVDOBJS = $(TDFXDOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) DRVPOBJS = $(TDFXPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) DRVDONES = $(TDFXDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) - REQUIREDLIBS += -lglide3x +REQUIREDLIBS += -lglide3x + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + +#elif GlxBuiltInI810 + + I810OBJS = mesa/src/drv/i810/?*.o + I810UOBJS = mesa/src/drv/i810/unshared/?*.o + I810DOBJS = mesa/src/drv/i810/debugger/?*.o + I810POBJS = mesa/src/drv/i810/profiled/?*.o + I810DONES = mesa/src/drv/i810/DONE + + DRVOBJS = $(I810OBJS) $(COMMONOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) + DRVUOBJS = $(I810UOBJS) $(COMMONUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) + DRVDOBJS = $(I810DOBJS) $(COMMONDOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) + DRVPOBJS = $(I810POBJS) $(COMMONPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) + DRVDONES = $(I810DONES) $(COMMONDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + +#elif GlxBuiltInMga + + MGAOBJS = mesa/src/drv/mga/?*.o + MGAUOBJS = mesa/src/drv/mga/unshared/?*.o + MGADOBJS = mesa/src/drv/mga/debugger/?*.o + MGAPOBJS = mesa/src/drv/mga/profiled/?*.o + MGADONES = mesa/src/drv/mga/DONE + + DRVOBJS = $(MGAOBJS) $(COMMONOBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) + DRVUOBJS = $(MGAUOBJS) $(COMMONUOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) + DRVDOBJS = $(MGADOBJS) $(COMMONDOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) + DRVPOBJS = $(MGAPOBJS) $(COMMONPOBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) + DRVDONES = $(MGADONES) $(COMMONDONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + +#elif GlxBuiltInR128 + + R128OBJS = mesa/src/drv/r128/?*.o + R128UOBJS = mesa/src/drv/r128/unshared/?*.o + R128DOBJS = mesa/src/drv/r128/debugger/?*.o + R128POBJS = mesa/src/drv/r128/profiled/?*.o + R128DONES = mesa/src/drv/r128/DONE + + DRVOBJS = $(R128OBJS) $(MESAOBJS) $(DRIMESAOBJS) $(DRMOBJS) + DRVUOBJS = $(R128UOBJS) $(MESAUOBJS) $(DRIMESAUOBJS) $(DRMUOBJS) + DRVDOBJS = $(R128DOBJS) $(MESADOBJS) $(DRIMESADOBJS) $(DRMDOBJS) + DRVPOBJS = $(R128POBJS) $(MESAPOBJS) $(DRIMESAPOBJS) $(DRMPOBJS) + DRVDONES = $(R128DONES) $(MESADONES) $(DRIMESADONES) $(DRMDONES) + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src + #elif GlxBuiltInMesa + #ifndef GlxDriverUsesMesa - DRVOBJS = mesa/src/?*.o mesa/src/X/?*.o - DRVUOBJS = mesa/src/unshared/?*.o mesa/src/X/unshared/?*.o - DRVDOBJS = mesa/src/debugger/?*.o mesa/src/X/debugger/?*.o - DRVPOBJS = mesa/src/profiled/?*.o mesa/src/X/profiled/?*.o - DRVDONES = mesa/src/DONE mesa/src/X/DONE + DRVOBJS = mesa/src/?*.o + DRVUOBJS = mesa/src/unshared/?*.o + DRVDOBJS = mesa/src/debugger/?*.o + DRVPOBJS = mesa/src/profiled/?*.o + DRVDONES = mesa/src/DONE + + GLXSUBDIRS = glx dri mesa/dri mesa/include/GL mesa/src #endif + +#else + +XCOMM No built-in drivers. This is the usual case. +GLXSUBDIRS = glx dri + #endif + +#else + +XCOMM BuildXF86DRI was not defined. Just build an indirect-only libGL. +GLXSUBDIRS = glx + #endif + + + + +#if BuildXF86DRI +SUBDIRS = $(GLXSUBDIRS) +OTHERSUBDIRS = mesa/dri mesa/include/GL mesa/src +#else +SUBDIRS = glx #endif +MakeSubdirs($(SUBDIRS)) +MakefileSubdirs($(OTHERSUBDIRS)) +DependSubdirs($(SUBDIRS) $(OTHERSUBDIRS)) + + + #ifdef OS2Architecture OBJS = $(LIBNAME).a #else - OBJS = $(GLXOBJS) $(DRIOBJS) $(DRVOBJS) + OBJS = $(LOWOBJ) $(GLXOBJS) $(DRIOBJS) $(DRVOBJS) $(HIOBJ) #endif + #if HasSharedLibraries +#if 1 UOBJS = $(GLXUOBJS) $(DRIUOBJS) $(DRVUOBJS) #else UOBJS = $(OBJS) #endif +#else + UOBJS = $(OBJS) +#endif + DOBJS = $(GLXDOBJS) $(DRIDOBJS) $(DRVDOBJS) POBJS = $(GLXPOBJS) $(DRIPOBJS) $(DRVPOBJS) DONES = $(GLXDONES) $(DRIDONES) $(DRVDONES) +#if 0 +SubdirLibraryRule(highpc.o lowpc.o) +NormalLintTarget(highpc.c lowpc.c) +#endif + #if LocalThreads THREADOBJS = $(THREADS_LIBS) #endif @@ -134,19 +227,39 @@ DRIMESADONES = mesa/dri/DONE #define _LinkBuildLibrary(lib) LinkBuildLibrary(lib) #if NormalLibGlx -NormalDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(UOBJS)) +NormalDepLibraryTarget($(LIBNAME),$(GLXSUBDIRS) $(DONES),$(UOBJS)) InstallLibrary($(LIBNAME),$(USRLIBDIR)) #endif #if SharedLibGlx -SharedDepLibraryTarget($(LIBNAME),$(SOREV),$(SUBDIRS) $(DONES),$(OBJS) $(THREADOBJS),.,.) +SharedDepLibraryTarget($(LIBNAME),$(SOREV),$(GLXSUBDIRS) $(DONES),$(OBJS) $(THREADOBJS),.,.) InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR)) +#if LinkGLToUsrLib && AlternateUsrLibDir +install:: + $(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so + $(LN) $(SHLIBDIR)/lib$(LIBNAME).so $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so + $(RM) $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 + $(LN) $(SHLIBDIR)/lib$(LIBNAME).so.1 $(DESTDIR)$(SYSTEMUSRLIBDIR)/lib$(LIBNAME).so.1 +#endif #endif #if DebugLibGlx -DebuggedDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(DOBJS)) +DebuggedDepLibraryTarget($(LIBNAME),$(GLXSUBDIRS) $(DONES),$(DOBJS)) InstallLibrary($(LIBNAME)_d,$(USRLIBDIR)) #endif #if ProfileLibGlx -ProfiledDepLibraryTarget($(LIBNAME),$(SUBDIRS) $(DONES),$(POBJS)) +ProfiledDepLibraryTarget($(LIBNAME),$(GLXSUBDIRS) $(DONES),$(POBJS)) InstallLibrary($(LIBNAME)_p,$(USRLIBDIR)) #endif + + +XCOMM libGL has now been made, continue with building the drivers. + +#if BuildXF86DRI && !GlxBuiltInGamma && !GlxBuiltInTdfx && !GlxBuiltInI810 && !GlxBuiltInMga && !GlxBuiltInMesa + +DRIVERSUBDIRS = mesa/dri mesa/include/GL mesa/src + +MakeSubdirs($(DRIVERSUBDIRS)) +DependSubdirs($(DRIVERSUBDIRS)) +InstallSubdirs($(DRIVERSUBDIRS)) + +#endif diff --git a/xc/lib/GL/dri/XF86dri.c b/xc/lib/GL/dri/XF86dri.c index a0f2f2d6f..dd0ee56ff 100644 --- a/xc/lib/GL/dri/XF86dri.c +++ b/xc/lib/GL/dri/XF86dri.c @@ -185,6 +185,8 @@ Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString) if (rep.length) { if (!(*busIdString = (char *)Xcalloc(rep.length + 1, 1))) { _XEatData(dpy, ((rep.busIdStringLength+3) & ~3)); + UnlockDisplay(dpy); + SyncHandle(); return False; } _XReadPad(dpy, *busIdString, rep.busIdStringLength); @@ -203,6 +205,7 @@ Bool XF86DRIAuthConnection(dpy, screen, magic) { XExtDisplayInfo *info = find_display (dpy); xXF86DRIAuthConnectionReq *req; + xXF86DRIAuthConnectionReply rep; XF86DRICheckExtension (dpy, info, False); @@ -212,6 +215,12 @@ Bool XF86DRIAuthConnection(dpy, screen, magic) req->driReqType = X_XF86DRIAuthConnection; req->screen = screen; req->magic = magic; + rep.authenticated = 0; + if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) { + UnlockDisplay(dpy); + SyncHandle(); + return False; + } UnlockDisplay(dpy); SyncHandle(); return True; @@ -267,7 +276,7 @@ Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion, *ddxDriverPatchVersion = rep.ddxDriverPatchVersion; if (rep.length) { - if (!(*clientDriverName = (char *)Xcalloc(rep.length + 1, 1))) { + if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) { _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3)); return False; } @@ -384,7 +393,11 @@ Bool XF86DRIDestroyDrawable(dpy, screen, drawable) } Bool XF86DRIGetDrawableInfo(dpy, screen, drawable, - index, stamp, X, Y, W, H, numClipRects, pClipRects) + index, stamp, X, Y, W, H, + numClipRects, pClipRects, + backX, backY, + numBackClipRects, pBackClipRects + ) Display* dpy; int screen; Drawable drawable; @@ -396,10 +409,15 @@ Bool XF86DRIGetDrawableInfo(dpy, screen, drawable, int* H; int* numClipRects; XF86DRIClipRectPtr* pClipRects; + int* backX; + int* backY; + int* numBackClipRects; + XF86DRIClipRectPtr* pBackClipRects; { XExtDisplayInfo *info = find_display (dpy); xXF86DRIGetDrawableInfoReply rep; xXF86DRIGetDrawableInfoReq *req; + int total_rects; XF86DRICheckExtension (dpy, info, False); @@ -409,7 +427,9 @@ Bool XF86DRIGetDrawableInfo(dpy, screen, drawable, req->driReqType = X_XF86DRIGetDrawableInfo; req->screen = screen; req->drawable = drawable; - if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) { + + if (!_XReply(dpy, (xReply *)&rep, 1, xFalse)) + { UnlockDisplay(dpy); SyncHandle(); return False; @@ -421,16 +441,41 @@ Bool XF86DRIGetDrawableInfo(dpy, screen, drawable, *W = (int)rep.drawableWidth; *H = (int)rep.drawableHeight; *numClipRects = rep.numClipRects; + total_rects = *numClipRects; + + *backX = rep.backX; + *backY = rep.backY; + *numBackClipRects = rep.numBackClipRects; + total_rects += *numBackClipRects; + + if (rep.length != (SIZEOF(xXF86DRIGetDrawableInfoReply) - + SIZEOF(xGenericReply) + + total_rects * sizeof(XF86DRIClipRectRec))) { + _XEatData(dpy, rep.length); + return False; + } + - if (rep.length) { - if (!(*pClipRects = (XF86DRIClipRectPtr)Xcalloc(rep.length, 1))) { - _XEatData(dpy, rep.length); - return False; - } - _XRead32(dpy, *pClipRects, rep.length); + if (*numClipRects) { + int len = sizeof(XF86DRIClipRectRec) * (*numClipRects); + + *pClipRects = (XF86DRIClipRectPtr)Xcalloc(len, 1); + if (*pClipRects) + _XRead32(dpy, *pClipRects, len); } else { *pClipRects = NULL; } + + if (*numBackClipRects) { + int len = sizeof(XF86DRIClipRectRec) * (*numBackClipRects); + + *pBackClipRects = (XF86DRIClipRectPtr)Xcalloc(len, 1); + if (*pBackClipRects) + _XRead32(dpy, *pBackClipRects, len); + } else { + *pBackClipRects = NULL; + } + UnlockDisplay(dpy); SyncHandle(); return True; diff --git a/xc/lib/GL/dri/dri_glx.c b/xc/lib/GL/dri/dri_glx.c index 48cdb8437..5b83792f7 100644 --- a/xc/lib/GL/dri/dri_glx.c +++ b/xc/lib/GL/dri/dri_glx.c @@ -75,6 +75,15 @@ static void ErrorMessage(const char *msg) } +static void InfoMessage(const char *msg) +{ + const char *env = getenv("LIBGL_DEBUG"); + if (env && strstr(env, "verbose")) { + fprintf(stderr, "libGL: %s\n", msg); + } +} + + /* * We'll save a pointer to this function when we couldn't find a * direct rendering driver for a given screen. @@ -91,6 +100,109 @@ static void *DummyCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, } + +/* + * Extract the ith directory path out of a colon-separated list of + * paths. + * Input: + * index - index of path to extract (starting at zero) + * paths - the colon-separated list of paths + * dirLen - max length of result to store in <dir> + * Output: + * dir - the extracted directory path, dir[0] will be zero when + * extraction fails. + */ +static void ExtractDir(int index, const char *paths, int dirLen, char *dir) +{ + int i, len; + const char *start, *end; + + /* find ith colon */ + start = paths; + i = 0; + while (i < index) { + if (*start == ':') { + i++; + start++; + } + else if (*start == 0) { + /* end of string and couldn't find ith colon */ + dir[0] = 0; + return; + } + else { + start++; + } + } + + while (*start == ':') + start++; + + /* find next colon, or end of string */ + end = start + 1; + while (*end != ':' && *end != 0) { + end++; + } + + /* copy string between <start> and <end> into result string */ + len = end - start; + if (len > dirLen - 1) + len = dirLen - 1; + strncpy(dir, start, len); + dir[len] = 0; +} + + + +/* + * Try to dlopen() the named driver. This function adds the + * "_dri.so" suffix to the driver name and searches the + * directories specified by the LIBGL_DRIVERS_PATH env var + * in order to find the driver. + * Input: + * driverName - a name like "tdfx", "i810", "mga", etc. + * Return: + * handle from dlopen, or NULL if driver file not found. + */ +static void *OpenDriver(const char *driverName) +{ + char *libPaths = NULL; + int i; + + if (geteuid() == getuid()) { + /* don't allow setuid apps to use LIBGL_DRIVERS_PATH */ + libPaths = getenv("LIBGL_DRIVERS_PATH"); + if (!libPaths) + libPaths = getenv("LIBGL_DRIVERS_DIR"); /* deprecated */ + } + if (!libPaths) + libPaths = DEFAULT_DRIVER_DIR; + + for (i = 0; ; i++) { + char libDir[1000], info[1000], realDriverName[100]; + void *handle; + ExtractDir(i, libPaths, 1000, libDir); + if (!libDir[0]) + return NULL; + sprintf(realDriverName, "%s/%s_dri.so", libDir, driverName); + sprintf(info, "trying %s", realDriverName); + InfoMessage(info); + handle = dlopen(realDriverName, RTLD_NOW | RTLD_GLOBAL); + if (handle) { + return handle; + } + else { + char message[1000]; + snprintf(message, 1000, "dlopen failed: %s", dlerror()); + ErrorMessage(message); + } + } + + return NULL; +} + + + /* * Initialize two arrays: an array of createScreen function pointers * and an array of dlopen library handles. Arrays are indexed by @@ -112,15 +224,18 @@ static void Find_CreateScreenFuncs(Display *dpy, Bool b; int driverMajor, driverMinor, driverPatch; char *driverName = NULL; + void *handle; /* defaults */ createFuncs[scrn] = DummyCreateScreen; libraryHandles[scrn] = NULL; if (!XF86DRIQueryDirectRenderingCapable(dpy, scrn, &directCapable)) { + ErrorMessage("XF86DRIQueryDirectRenderingCapable failed"); continue; } if (!directCapable) { + ErrorMessage("XF86DRIQueryDirectRenderingCapable returned false"); continue; } @@ -138,46 +253,25 @@ static void Find_CreateScreenFuncs(Display *dpy, /* - * dlopen the driver module and save the pointer to its + * Open the driver module and save the pointer to its * __driCreateScreen function. */ - { - char realDriverName[100]; - void *handle; - CreateScreenFunc createScreenFunc; - char *libDir = NULL; - - if (geteuid() == getuid()) { - /* don't allow setuid apps to use LIBGL_DRIVERS_DIR */ - libDir = getenv("LIBGL_DRIVERS_DIR"); - } - if (!libDir) - libDir = DEFAULT_DRIVER_DIR; - - sprintf(realDriverName, "%s/%s_dri.so", libDir, driverName); - /*printf("OPEN %s\n", realDriverName);*/ - handle = dlopen(realDriverName, RTLD_LAZY); - if (!handle) { - char message[1000]; - snprintf(message, 1000, "dlopen failed: %s", dlerror()); - ErrorMessage(message); - continue; - } - - createScreenFunc = (CreateScreenFunc) dlsym(handle, "__driCreateScreen"); - if (createScreenFunc) { - /* success! */ - createFuncs[scrn] = createScreenFunc; - libraryHandles[scrn] = handle; - } - else { - char message[1000]; - snprintf(message, 1000, "driCreateScreen() not defined in %s", realDriverName); - ErrorMessage(message); - dlclose(handle); - } + handle = OpenDriver(driverName); + if (handle) { + CreateScreenFunc createScreenFunc; + createScreenFunc = (CreateScreenFunc) dlsym(handle, "__driCreateScreen"); + if (createScreenFunc) { + /* success! */ + createFuncs[scrn] = createScreenFunc; + libraryHandles[scrn] = handle; + break; /* onto the next screen */ + } + else { + ErrorMessage("driCreateScreen() not defined in driver!"); + dlclose(handle); + } } - } + } /* for scrn */ } #endif /* BUILT_IN_DRI_DRIVER */ @@ -220,9 +314,9 @@ void *driCreateDisplay(Display *dpy, __DRIdisplay *pdisp) return NULL; } - pdpyp->major = major; - pdpyp->minor = minor; - pdpyp->patch = patch; + pdpyp->driMajor = major; + pdpyp->driMinor = minor; + pdpyp->driPatch = patch; pdisp->destroyDisplay = driDestroyDisplay; @@ -269,6 +363,7 @@ register_extensions_on_screen(Display *dpy, int scrNum) int driMajor, driMinor, driPatch; int driverMajor, driverMinor, driverPatch; char *driverName = NULL; + void *handle; /* * Check if the DRI extension is available, check the DRI version, @@ -312,29 +407,16 @@ register_extensions_on_screen(Display *dpy, int scrNum) * dlopen() the driver library file, get a pointer to the driver's * __driRegisterExtensions() function, and call it if it exists. */ - { - char realDriverName[100]; - char *libDir = NULL; - void *handle; - - if (geteuid() == getuid()) { - /* don't allow setuid apps to use LIBGL_DRIVERS_DIR */ - libDir = getenv("LIBGL_DRIVERS_DIR"); - } - if (!libDir) - libDir = DEFAULT_DRIVER_DIR; - - sprintf(realDriverName, "%s/%s_dri.so", libDir, driverName); - /*printf("OPEN %s\n", realDriverName);*/ - handle = dlopen(realDriverName, RTLD_LAZY); - if (handle) { - typedef void *(*RegisterExtFunc)(void); - RegisterExtFunc registerExtFunc = (RegisterExtFunc) dlsym(handle, "__driRegisterExtensions"); - if (registerExtFunc) { - (*registerExtFunc)(); - } - dlclose(handle); + handle = OpenDriver(driverName); + if (handle) { + typedef void *(*RegisterExtFunc)(void); + RegisterExtFunc registerExtFunc = (RegisterExtFunc) dlsym(handle, + "__driRegisterExtensions"); + if (registerExtFunc) { + (*registerExtFunc)(); } + dlclose(handle); + return; } } #endif /* !BUILT_IN_DRI_DRIVER */ @@ -362,8 +444,12 @@ __glXRegisterExtensions(void) __driRegisterExtensions(); #else { - int displayNum; - for (displayNum = 0; ; displayNum++) { + int displayNum, maxDisplays; + if (getenv("LIBGL_MULTIHEAD")) + maxDisplays = 10; /* infinity, really */ + else + maxDisplays = 1; + for (displayNum = 0; displayNum < maxDisplays; displayNum++) { char displayName[200]; Display *dpy; snprintf(displayName, 199, ":%d.0", displayNum); @@ -381,13 +467,10 @@ __glXRegisterExtensions(void) } } } -#endif alreadyCalled = GL_TRUE; +#endif } #endif /* GLX_DIRECT_RENDERING */ - - - diff --git a/xc/lib/GL/dri/dri_glx.h b/xc/lib/GL/dri/dri_glx.h index 21fe733bc..75561685c 100644 --- a/xc/lib/GL/dri/dri_glx.h +++ b/xc/lib/GL/dri/dri_glx.h @@ -41,9 +41,9 @@ struct __DRIdisplayPrivateRec { /* ** XFree86-DRI version information */ - int major; - int minor; - int patch; + int driMajor; + int driMinor; + int driPatch; /* ** Array of library handles [indexed by screen number] diff --git a/xc/lib/GL/dri/xf86dristr.h b/xc/lib/GL/dri/xf86dristr.h index ea8bad041..42e5da785 100644 --- a/xc/lib/GL/dri/xf86dristr.h +++ b/xc/lib/GL/dri/xf86dristr.h @@ -40,7 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define XF86DRINAME "XFree86-DRI" -#define XF86DRI_MAJOR_VERSION 1 /* current version numbers */ +#define XF86DRI_MAJOR_VERSION 3 /* current version numbers */ #define XF86DRI_MINOR_VERSION 0 #define XF86DRI_PATCH_VERSION 0 @@ -122,6 +122,20 @@ typedef struct _XF86DRIAuthConnection { } xXF86DRIAuthConnectionReq; #define sz_xXF86DRIAuthConnectionReq 12 +typedef struct { + BYTE type; + BOOL pad1; + CARD16 sequenceNumber B16; + CARD32 length B32; + CARD32 authenticated B32; + CARD32 pad2 B32; + CARD32 pad3 B32; + CARD32 pad4 B32; + CARD32 pad5 B32; + CARD32 pad6 B32; +} xXF86DRIAuthConnectionReply; +#define zx_xXF86DRIAuthConnectionReply 32 + typedef struct _XF86DRICloseConnection { CARD8 reqType; /* always DRIReqCode */ CARD8 driReqType; /* always X_DRICloseConnection */ @@ -238,9 +252,13 @@ typedef struct { INT16 drawableWidth B16; INT16 drawableHeight B16; CARD32 numClipRects B32; - CARD32 pad6 B32; + INT16 backX B16; + INT16 backY B16; + CARD32 numBackClipRects B32; } xXF86DRIGetDrawableInfoReply; -#define sz_xXF86DRIGetDrawableInfoReply 32 + +#define sz_xXF86DRIGetDrawableInfoReply 36 + typedef struct _XF86DRIGetDeviceInfo { CARD8 reqType; /* always DRIReqCode */ diff --git a/xc/lib/GL/glx/glxcmds.c b/xc/lib/GL/glx/glxcmds.c index 935f9b155..d7462eb2b 100644 --- a/xc/lib/GL/glx/glxcmds.c +++ b/xc/lib/GL/glx/glxcmds.c @@ -49,7 +49,8 @@ static const char GLXClientVersion[] = "1.2"; static const char GLXClientExtensions[] = "GLX_EXT_visual_info " "GLX_EXT_visual_rating " - "GLX_EXT_import_context "; + "GLX_EXT_import_context " + "GLX_ARB_get_proc_address "; /* ** Create a new context. @@ -1191,7 +1192,7 @@ static char *combine_strings( const char *cext_string, const char *sext_string ) s1 = (char *) malloc( slen + 2 ); strcpy( s1, sext_string ); s2 = cext_string; } else { - combo_string = (char *) malloc( clen + 2 ); + combo_string = (char *) Xmalloc( clen + 2 ); s1 = (char *) Xmalloc( clen + 2 ); strcpy( s1, cext_string); s2 = sext_string; } @@ -1498,7 +1499,7 @@ void glXFreeContextEXT(Display *dpy, GLXContext ctx) * GLX 1.3 functions - these are just stubs for now! */ -GLXFBConfig glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems) +GLXFBConfig *glXChooseFBConfig(Display *dpy, int screen, const int *attribList, int *nitems) { (void) dpy; (void) screen; @@ -1575,6 +1576,15 @@ GLXDrawable glXGetCurrentReadDrawable(void) } +GLXFBConfig *glXGetFBConfigs(Display *dpy, int screen, int *nelements) +{ + (void) dpy; + (void) screen; + (void) nelements; + return 0; +} + + int glXGetFBConfigAttrib(Display *dpy, GLXFBConfig config, int attribute, int *value) { (void) dpy; @@ -1640,6 +1650,48 @@ void glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask) /* +** Mesa extension stubs. These will help reduce portability problems. +*/ + +void glXReleaseBuffersMESA( Display *dpy, GLXDrawable d ) +{ + (void) dpy; + (void) d; + /* no-op stub */ +} + + +GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual, + Pixmap pixmap, Colormap cmap ) +{ + (void) dpy; + (void) visual; + (void) pixmap; + (void) cmap; + return 0; +} + + +void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable, + int x, int y, int width, int height ) +{ + (void) dpy; + (void) drawable; + (void) x; + (void) y; + (void) width; + (void) height; +} + + +GLboolean glXSet3DfxModeMESA( GLint mode ) +{ + (void) mode; + return GL_FALSE; +} + + +/* ** glXGetProcAddress support */ @@ -1683,6 +1735,7 @@ static struct name_address_pair GLX_functions[] = { { "glXDestroyWindow", (GLvoid *) glXDestroyWindow }, { "glXGetCurrentReadDrawable", (GLvoid *) glXGetCurrentReadDrawable }, { "glXGetFBConfigAttrib", (GLvoid *) glXGetFBConfigAttrib }, + { "glXGetFBConfigs", (GLvoid *) glXGetFBConfigs }, { "glXGetSelectedEvent", (GLvoid *) glXGetSelectedEvent }, { "glXGetVisualFromFBConfig", (GLvoid *) glXGetVisualFromFBConfig }, { "glXMakeContextCurrent", (GLvoid *) glXMakeContextCurrent }, @@ -1698,6 +1751,12 @@ static struct name_address_pair GLX_functions[] = { { "glXQueryContextInfoEXT", (GLvoid *) glXQueryContextInfoEXT }, { "glXGetProcAddressARB", (GLvoid *) glXGetProcAddressARB }, + /* Mesa extensions */ + { "glXReleaseBuffersMESA", (GLvoid *) glXReleaseBuffersMESA }, + { "glXCreateGLXPixmapMESA", (GLvoid *) glXCreateGLXPixmapMESA }, + { "glXCopySubBufferMESA", (GLvoid *) glXCopySubBufferMESA }, + { "glXSet3DfxModeMESA", (GLvoid *) glXSet3DfxModeMESA }, + { NULL, NULL } /* end of list */ }; diff --git a/xc/lib/GL/mesa/dri/dri_mesa.c b/xc/lib/GL/mesa/dri/dri_mesa.c index 08f3dfcfd..e6435e218 100644 --- a/xc/lib/GL/mesa/dri/dri_mesa.c +++ b/xc/lib/GL/mesa/dri/dri_mesa.c @@ -29,7 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> - * Brian Paul <brian@precisioninsight.com> + * Brian E. Paul <brian@precisioninsight.com> */ #ifdef GLX_DIRECT_RENDERING @@ -39,16 +39,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <Xext.h> #include <extutil.h> #include "glxclient.h" -#include "GL/xmesa.h" #include "xf86dri.h" #include "sarea.h" #include "dri_mesaint.h" #include "dri_xmesaapi.h" - - -#if XMESA_MAJOR_VERSION != 3 || XMESA_MINOR_VERSION != 3 -#error using wrong version of Mesa (need 3.3) -#endif +#include "../src/context.h" +#include "../src/mmath.h" /* Context binding */ @@ -75,6 +71,19 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, static void driMesaDestroyScreen(Display *dpy, int scrn, void *private); + +/* +** Print message to stderr if LIBGL_DEBUG env var is set. +*/ +void +__driMesaMessage(const char *msg) +{ + if (getenv("LIBGL_DEBUG")) { + fprintf(stderr, "libGL error: %s\n", msg); + } +} + + /*****************************************************************/ /* Maintain a list of drawables */ @@ -109,6 +118,8 @@ static __DRIdrawable *__driMesaFindDrawable(GLXDrawable draw) return pdraw; } +#if 0 +/* not used yet */ static void __driMesaRemoveDrawable(__DRIdrawable *pdraw) { int retcode; @@ -122,23 +133,22 @@ static void __driMesaRemoveDrawable(__DRIdrawable *pdraw) drmHashDelete(drawHash, pdp->draw); } } +#endif /*****************************************************************/ -static void driMesaInitAPI(__XMESAapi *XMesaAPI) +static void driMesaInitAPI(__MesaAPI *MesaAPI) { - XMesaAPI->InitDriver = XMesaInitDriver; - XMesaAPI->ResetDriver = XMesaResetDriver; - XMesaAPI->CreateVisual = XMesaCreateVisual; - XMesaAPI->DestroyVisual = XMesaDestroyVisual; - XMesaAPI->CreateContext = XMesaCreateContext; - XMesaAPI->DestroyContext = XMesaDestroyContext; - XMesaAPI->CreateWindowBuffer = XMesaCreateWindowBuffer; - XMesaAPI->CreatePixmapBuffer = XMesaCreatePixmapBuffer; - XMesaAPI->DestroyBuffer = XMesaDestroyBuffer; - XMesaAPI->SwapBuffers = XMesaSwapBuffers; - XMesaAPI->MakeCurrent = XMesaMakeCurrent; - XMesaAPI->UnbindContext = XMesaUnbindContext; + MesaAPI->InitDriver = XMesaInitDriver; + MesaAPI->ResetDriver = XMesaResetDriver; + MesaAPI->CreateVisual = XMesaCreateVisual; + MesaAPI->CreateContext = XMesaCreateContext; + MesaAPI->DestroyContext = XMesaDestroyContext; + MesaAPI->CreateWindowBuffer = XMesaCreateWindowBuffer; + MesaAPI->CreatePixmapBuffer = XMesaCreatePixmapBuffer; + MesaAPI->SwapBuffers = XMesaSwapBuffers; + MesaAPI->MakeCurrent = XMesaMakeCurrent; + MesaAPI->UnbindContext = XMesaUnbindContext; } /*****************************************************************/ @@ -176,7 +186,7 @@ static Bool driMesaUnbindContext(Display *dpy, int scrn, } /* Unbind Mesa's drawable from Mesa's context */ - (*psp->XMesaAPI.UnbindContext)(pcp->xm_ctx); + (*psp->MesaAPI.UnbindContext)(pcp); if (pdp->refcount == 0) { /* ERROR!!! */ @@ -279,7 +289,7 @@ static Bool driMesaBindContext(Display *dpy, int scrn, } /* Bind Mesa's drawable to Mesa's context */ - (*psp->XMesaAPI.MakeCurrent)(pcp->xm_ctx, pdp->xm_buf); + (*psp->MesaAPI.MakeCurrent)(pcp, pdp, pdp); return GL_TRUE; } @@ -307,14 +317,26 @@ void driMesaUpdateDrawableInfo(Display *dpy, int scrn, Xfree(pdp->pClipRects); } + if (pdp->pBackClipRects) { + Xfree(pdp->pBackClipRects); + } + + DRM_SPINUNLOCK(&psp->pSAREA->drawable_lock, psp->drawLockID); if (!XF86DRIGetDrawableInfo(dpy, scrn, pdp->draw, &pdp->index, &pdp->lastStamp, &pdp->x, &pdp->y, &pdp->w, &pdp->h, - &pdp->numClipRects, &pdp->pClipRects)) { + &pdp->numClipRects, &pdp->pClipRects, + &pdp->backX, + &pdp->backY, + &pdp->numBackClipRects, + &pdp->pBackClipRects + )) { pdp->numClipRects = 0; pdp->pClipRects = NULL; + pdp->numBackClipRects = 0; + pdp->pBackClipRects = 0; /* ERROR!!! */ } @@ -332,7 +354,7 @@ static void *driMesaCreateDrawable(Display *dpy, int scrn, GLXDrawable draw, __DRIscreenPrivate *psp; __DRIdrawablePrivate *pdp; int i; - XMesaVisual xm_vis = NULL; + GLvisual *mesaVis = NULL; pdp = (__DRIdrawablePrivate *)Xmalloc(sizeof(__DRIdrawablePrivate)); if (!pdp) { @@ -354,7 +376,9 @@ static void *driMesaCreateDrawable(Display *dpy, int scrn, GLXDrawable draw, pdp->w = 0; pdp->h = 0; pdp->numClipRects = 0; + pdp->numBackClipRects = 0; pdp->pClipRects = NULL; + pdp->pBackClipRects = NULL; pDRIScreen = __glXFindDRIScreen(dpy, scrn); pdp->driScreenPriv = psp = (__DRIscreenPrivate *)pDRIScreen->private; @@ -363,20 +387,19 @@ static void *driMesaCreateDrawable(Display *dpy, int scrn, GLXDrawable draw, for (i = 0; i < psp->numVisuals; i++) { if (vid == psp->visuals[i].vid) { - xm_vis = psp->visuals[i].xm_vis; + mesaVis = psp->visuals[i].mesaVisual; break; } } - if (1 /* NOT_DONE: Determine if it is a pixmap or not */) { - pdp->xm_buf = (*psp->XMesaAPI.CreateWindowBuffer)(xm_vis, draw, pdp); - } else { - XMesaVisual xm_vis = NULL; - XMesaColormap cmap = 0; - pdp->xm_buf = (*psp->XMesaAPI.CreatePixmapBuffer)(xm_vis, draw, cmap, - pdp); + /* XXX pixmap rendering not implemented yet */ + if (1) { + pdp->mesaBuffer = (*psp->MesaAPI.CreateWindowBuffer)(dpy, psp, pdp, mesaVis); + } + else { + pdp->mesaBuffer = (*psp->MesaAPI.CreatePixmapBuffer)(dpy, psp, pdp, mesaVis); } - if (!pdp->xm_buf) { + if (!pdp->mesaBuffer) { (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw); Xfree(pdp); return NULL; @@ -402,7 +425,7 @@ static void driMesaSwapBuffers(Display *dpy, void *private) __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)private; __DRIscreenPrivate *psp = pdp->driScreenPriv; - (*psp->XMesaAPI.SwapBuffers)(pdp->xm_buf); + (*psp->MesaAPI.SwapBuffers)(pdp); } static void driMesaDestroyDrawable(Display *dpy, void *private) @@ -412,7 +435,7 @@ static void driMesaDestroyDrawable(Display *dpy, void *private) int scrn = psp->myNum; if (pdp) { - (*psp->XMesaAPI.DestroyBuffer)(pdp->xm_buf); + gl_destroy_framebuffer(pdp->mesaBuffer); (void)XF86DRIDestroyDrawable(dpy, scrn, pdp->draw); if (pdp->pClipRects) Xfree(pdp->pClipRects); @@ -427,8 +450,6 @@ static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared, { __DRIcontextPrivate *pcp; __DRIcontextPrivate *pshare = (__DRIcontextPrivate *)shared; - XMesaContext shared_xm_ctx = (pshare ? - pshare->xm_ctx : (XMesaContext)NULL); __DRIscreenPrivate *psp; __DRIscreen *pDRIScreen; int i; @@ -443,7 +464,7 @@ static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared, return NULL; } psp->dummyContextPriv.driScreenPriv = psp; - psp->dummyContextPriv.xm_ctx = NULL; + psp->dummyContextPriv.mesaContext = NULL; psp->dummyContextPriv.driDrawablePriv = NULL; /* No other fields should be used! */ } @@ -453,8 +474,9 @@ static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared, return NULL; } + pcp->display = dpy; pcp->driScreenPriv = psp; - pcp->xm_ctx = NULL; + pcp->mesaContext = NULL; pcp->driDrawablePriv = NULL; if (!XF86DRICreateContext(dpy, vis->screen, vis->visual, @@ -463,12 +485,28 @@ static void *driMesaCreateContext(Display *dpy, XVisualInfo *vis, void *shared, return NULL; } - for (i = 0; i < psp->numVisuals; i++) - if (psp->visuals[i].vid == vis->visualid) - pcp->xm_ctx = (*psp->XMesaAPI.CreateContext) - (psp->visuals[i].xm_vis, shared_xm_ctx, pcp); - - if (!pcp->xm_ctx) { + for (i = 0; i < psp->numVisuals; i++) { + if (psp->visuals[i].vid == vis->visualid) { + GLvisual *mesaVis = psp->visuals[i].mesaVisual; + GLcontext *sharedMesaCtx = pshare ? pshare->mesaContext : NULL; + pcp->mesaContext = gl_create_context(mesaVis, + sharedMesaCtx, + NULL, /* set below */ + GL_TRUE); + if (pcp->mesaContext) { + /* Driver now creates its private context data */ + if ((*psp->MesaAPI.CreateContext)(dpy, mesaVis, pcp)) { + pcp->mesaContext->DriverCtx = pcp->driverPrivate; + } + else { + gl_destroy_context(pcp->mesaContext); + pcp->mesaContext = NULL; + } + } + } + } + + if (!pcp->mesaContext) { (void)XF86DRIDestroyContext(dpy, vis->screen, pcp->contextID); Xfree(pcp); return NULL; @@ -487,7 +525,8 @@ static void driMesaDestroyContext(Display *dpy, int scrn, void *private) if (pcp) { (void)XF86DRIDestroyContext(dpy, scrn, pcp->contextID); - (*pcp->driScreenPriv->XMesaAPI.DestroyContext)(pcp->xm_ctx); + (*pcp->driScreenPriv->MesaAPI.DestroyContext)(pcp); + gl_destroy_context(pcp->mesaContext); Xfree(pcp); } } @@ -517,6 +556,7 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, return NULL; } + psp->display = dpy; psp->myNum = scrn; if (!XF86DRIOpenConnection(dpy, scrn, &hSAREA, &BusID)) { @@ -532,7 +572,7 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, psp->drawLockID = 1; psp->fd = drmOpen(NULL,BusID); - if (!psp->fd) { + if (psp->fd < 0) { Xfree(BusID); Xfree(psp); (void)XF86DRICloseConnection(dpy, scrn); @@ -547,6 +587,21 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, return NULL; } + { + drmVersionPtr version = drmGetVersion(psp->fd); + if (version) { + psp->drmMajor = version->version_major; + psp->drmMinor = version->version_minor; + psp->drmPatch = version->version_patchlevel; + drmFreeVersion(version); + } + else { + psp->drmMajor = -1; + psp->drmMinor = -1; + psp->drmPatch = -1; + } + } + if (!XF86DRIAuthConnection(dpy, scrn, magic)) { (void)drmClose(psp->fd); Xfree(psp); @@ -555,9 +610,9 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, } if (!XF86DRIGetClientDriverName(dpy, scrn, - &psp->major, - &psp->minor, - &psp->patch, + &psp->ddxMajor, + &psp->ddxMinor, + &psp->ddxPatch, &driverName)) { (void)drmClose(psp->fd); Xfree(psp); @@ -565,7 +620,7 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, return NULL; } - driMesaInitAPI(&psp->XMesaAPI); + driMesaInitAPI(&psp->MesaAPI); if (!XF86DRIGetDeviceInfo(dpy, scrn, &hFB, @@ -627,22 +682,13 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, for (i = 0; i < numConfigs; i++, config++) { psp->visuals[i].vid = visinfo[i].visualid; - psp->visuals[i].xm_vis = - (*psp->XMesaAPI.CreateVisual)(dpy, - &visinfo[i], - config->rgba, - (config->alphaSize > 0), - config->doubleBuffer, - config->stereo, - GL_TRUE, /* ximage_flag */ - config->depthSize, - config->stencilSize, - config->accumRedSize, - config->level); - if (!psp->visuals[i].xm_vis) { + psp->visuals[i].mesaVisual = + (*psp->MesaAPI.CreateVisual) (dpy, psp, &visinfo[i], config); + + if (!psp->visuals[i].mesaVisual) { /* Free the visuals so far created */ while (--i >= 0) { - (*psp->XMesaAPI.DestroyVisual)(psp->visuals[i].xm_vis); + _mesa_destroy_visual(psp->visuals[i].mesaVisual); } Xfree(psp->visuals); XFree(visinfo); @@ -658,11 +704,10 @@ static void *driMesaCreateScreen(Display *dpy, int scrn, __DRIscreen *psc, XFree(visinfo); /* Initialize the screen specific GLX driver */ - if (psp->XMesaAPI.InitDriver) { - if (!(*psp->XMesaAPI.InitDriver)(psp)) { + if (psp->MesaAPI.InitDriver) { + if (!(*psp->MesaAPI.InitDriver)(psp)) { while (--psp->numVisuals >= 0) { - (*psp->XMesaAPI.DestroyVisual) - (psp->visuals[psp->numVisuals].xm_vis); + _mesa_destroy_visual(psp->visuals[psp->numVisuals].mesaVisual); } Xfree(psp->visuals); (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); @@ -699,11 +744,10 @@ static void driMesaDestroyScreen(Display *dpy, int scrn, void *private) (void)XF86DRIDestroyContext(dpy, scrn, psp->dummyContextPriv.contextID); } - if (psp->XMesaAPI.ResetDriver) - (*psp->XMesaAPI.ResetDriver)(psp); + if (psp->MesaAPI.ResetDriver) + (*psp->MesaAPI.ResetDriver)(psp); while (--psp->numVisuals >= 0) { - (*psp->XMesaAPI.DestroyVisual) - (psp->visuals[psp->numVisuals].xm_vis); + _mesa_destroy_visual(psp->visuals[psp->numVisuals].mesaVisual); } Xfree(psp->visuals); (void)drmUnmap((drmAddress)psp->pSAREA, SAREA_MAX); diff --git a/xc/lib/GL/mesa/dri/dri_mesa.h b/xc/lib/GL/mesa/dri/dri_mesa.h index 4a6870801..42903bf1e 100644 --- a/xc/lib/GL/mesa/dri/dri_mesa.h +++ b/xc/lib/GL/mesa/dri/dri_mesa.h @@ -43,5 +43,8 @@ typedef struct __DRIvisualPrivateRec __DRIvisualPrivate; typedef struct __DRIcontextPrivateRec __DRIcontextPrivate; typedef struct __DRIdrawablePrivateRec __DRIdrawablePrivate; +extern void __driMesaMessage(const char *msg); + #endif + #endif /* _DRI_MESA_H_ */ diff --git a/xc/lib/GL/mesa/dri/dri_mesaint.h b/xc/lib/GL/mesa/dri/dri_mesaint.h index 6b64114d0..9c33dda17 100644 --- a/xc/lib/GL/mesa/dri/dri_mesaint.h +++ b/xc/lib/GL/mesa/dri/dri_mesaint.h @@ -29,6 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> + * Brian E. Paul <brian@precisioninsight.com> * */ @@ -40,10 +41,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <GL/glx.h> #include "xf86dri.h" #include "sarea.h" -#include "GL/xmesa.h" #include "dri_mesa.h" #include "dri_xmesaapi.h" + #define DRI_MESA_VALIDATE_DRAWABLE_INFO(dpy,scrn,pDrawPriv) \ do { \ if (*(pDrawPriv->pStamp) != pDrawPriv->lastStamp) { \ @@ -59,9 +60,9 @@ struct __DRIdrawablePrivateRec { drmDrawable hHWDrawable; /* - ** Mesa's private context information. This structure is opaque. + ** Mesa's private frame buffer information. This structure is opaque. */ - XMesaBuffer xm_buf; + GLframebuffer *mesaBuffer; /* ** X's drawable ID associated with this private drawable. @@ -104,6 +105,16 @@ struct __DRIdrawablePrivateRec { XF86DRIClipRectPtr pClipRects; /* + ** Information about the back and depthbuffer where different + ** from above. + */ + int backX; + int backY; + int backClipRectType; + int numBackClipRects; + XF86DRIClipRectPtr pBackClipRects; + + /* ** Pointer to context to which this drawable is currently bound. */ __DRIcontextPrivate *driContextPriv; @@ -128,7 +139,17 @@ struct __DRIcontextPrivateRec { /* ** Mesa's private context information. This structure is opaque. */ - XMesaContext xm_ctx; + GLcontext *mesaContext; + + /* + ** Device driver's private context data. This structure is opaque. + */ + void *driverPrivate; + + /* + ** This context's display pointer. + */ + Display *display; /* ** Pointer to drawable currently bound to this context. @@ -145,7 +166,7 @@ struct __DRIvisualPrivateRec { /* ** Mesa's private visual information. This structure is opaque. */ - XMesaVisual xm_vis; + GLvisual *mesaVisual; /* ** X's visual ID associated with this private visual. @@ -155,6 +176,11 @@ struct __DRIvisualPrivateRec { struct __DRIscreenPrivateRec { /* + ** Display for this screen + */ + Display *display; + + /* ** Current screen's number */ int myNum; @@ -169,14 +195,21 @@ struct __DRIscreenPrivateRec { /* ** Function pointers associated with Mesa's GLX functions. */ - __XMESAapi XMesaAPI; + __MesaAPI MesaAPI; + + /* + ** DDX / 2D driver version information. + */ + int ddxMajor; + int ddxMinor; + int ddxPatch; /* - ** Core rendering library's driver version information. + ** DRM version information. */ - int major; - int minor; - int patch; + int drmMajor; + int drmMinor; + int drmPatch; /* ** ID used when the client sets the drawable lock. The X server diff --git a/xc/lib/GL/mesa/include/GL/Imakefile b/xc/lib/GL/mesa/include/GL/Imakefile index bc6730a85..da1b03d8d 100644 --- a/xc/lib/GL/mesa/include/GL/Imakefile +++ b/xc/lib/GL/mesa/include/GL/Imakefile @@ -11,3 +11,4 @@ LinkSourceFile(glx.h, ../../../../../extras/Mesa/include/GL) LinkSourceFile(xmesa.h, ../../../../../extras/Mesa/include/GL) LinkSourceFile(xmesa_x.h, ../../../../../extras/Mesa/include/GL) LinkSourceFile(xmesa_xf86.h, ../../../../../extras/Mesa/include/GL) +LinkSourceFile(osmesa.h, ../../../../../extras/Mesa/include/GL) diff --git a/xc/lib/GL/mesa/src/Imakefile b/xc/lib/GL/mesa/src/Imakefile index d93aa3f7e..1d42b4950 100644 --- a/xc/lib/GL/mesa/src/Imakefile +++ b/xc/lib/GL/mesa/src/Imakefile @@ -16,6 +16,9 @@ ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL TDFX_DEFS = -DFX #endif +LinkSourceFile(aatriangle.c, ../../../../extras/Mesa/src) +LinkSourceFile(aatriangle.h, ../../../../extras/Mesa/src) +LinkSourceFile(aatritemp.h, ../../../../extras/Mesa/src) LinkSourceFile(accum.c, ../../../../extras/Mesa/src) LinkSourceFile(accum.h, ../../../../extras/Mesa/src) LinkSourceFile(all.h, ../../../../extras/Mesa/src) @@ -120,6 +123,8 @@ LinkSourceFile(pipeline.c, ../../../../extras/Mesa/src) LinkSourceFile(pipeline.h, ../../../../extras/Mesa/src) LinkSourceFile(pixel.c, ../../../../extras/Mesa/src) LinkSourceFile(pixel.h, ../../../../extras/Mesa/src) +LinkSourceFile(pixeltex.c, ../../../../extras/Mesa/src) +LinkSourceFile(pixeltex.h, ../../../../extras/Mesa/src) LinkSourceFile(points.c, ../../../../extras/Mesa/src) LinkSourceFile(points.h, ../../../../extras/Mesa/src) LinkSourceFile(polygon.c, ../../../../extras/Mesa/src) @@ -156,6 +161,8 @@ LinkSourceFile(texstate.c, ../../../../extras/Mesa/src) LinkSourceFile(texstate.h, ../../../../extras/Mesa/src) LinkSourceFile(texture.c, ../../../../extras/Mesa/src) LinkSourceFile(texture.h, ../../../../extras/Mesa/src) +LinkSourceFile(texutil.c, ../../../../extras/Mesa/src) +LinkSourceFile(texutil.h, ../../../../extras/Mesa/src) LinkSourceFile(trans_tmp.h, ../../../../extras/Mesa/src) LinkSourceFile(translate.c, ../../../../extras/Mesa/src) LinkSourceFile(translate.h, ../../../../extras/Mesa/src) @@ -189,7 +196,8 @@ LinkSourceFile(xform_tmp.h, ../../../../extras/Mesa/src) LinkSourceFile(zoom.c, ../../../../extras/Mesa/src) LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) - CORE_SRCS = accum.c \ + CORE_SRCS = aatriangle.c \ + accum.c \ alpha.c \ alphabuf.c \ attrib.c \ @@ -220,7 +228,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) hash.c \ hint.c \ image.c \ - imaging.o \ + imaging.c \ light.c \ lines.c \ logic.c \ @@ -231,6 +239,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) pb.c \ pipeline.c \ pixel.c \ + pixeltex.c \ points.c \ polygon.c \ quads.c \ @@ -247,6 +256,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) texobj.c \ texstate.c \ texture.c \ + texutil.c \ translate.c \ triangle.c \ varray.c \ @@ -262,7 +272,8 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) xform.c \ zoom.c - CORE_OBJS = accum.o \ + CORE_OBJS = aatriangle.o \ + accum.o \ alpha.o \ alphabuf.o \ attrib.o \ @@ -301,6 +312,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) pb.o \ pipeline.o \ pixel.o \ + pixeltex.o \ points.o \ polygon.o \ quads.o \ @@ -317,6 +329,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) texobj.o \ texstate.o \ texture.o \ + texutil.o \ translate.o \ triangle.o \ varray.o \ @@ -335,8 +348,12 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) #ifdef i386Architecture ASM_SRCS = ASM_OBJS = +#ifdef MesaUse3DNow + ASM_DEFS = -DUSE_MMX_ASM -DUSE_X86_ASM -DUSE_3DNOW_ASM +#else ASM_DEFS = -DUSE_MMX_ASM -DUSE_X86_ASM #endif +#endif DEFINES = $(ALLOC_DEFINES) GlxDefines $(TDFX_DEFS) $(ASM_DEFS) INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) -I../include -I../../dri -I. -I../../../../include @@ -351,9 +368,7 @@ LinkSourceFile(zoom.h, ../../../../extras/Mesa/src) #endif #if GlxBuiltInMesa || GlxDriverUsesMesa || !GlxUseBuiltInDRIDriver -# We have to go into X to make the xmesaP.h symbolic link - MESASUBDIRS = X - + MESASUBDIRS = ASMSUBDIRS = X86 #include <Library.tmpl> @@ -367,17 +382,8 @@ NormalLintTarget($(SRCS)) #define IHaveSubdirs #define PassCDebugFlags -SUBDIRS = $(MESASUBDIRS) $(ASMSUBDIRS) drv +SUBDIRS = $(MESASUBDIRS) $(ASMSUBDIRS) drv OSmesa MakeSubdirs($(SUBDIRS)) DependSubdirs($(SUBDIRS)) - -#if !GlxUseBuiltInDRIDriver && !GlxDriverUsesMesa -LIBNAME = mesa_dri.so -ALL_OBJS = $(CORE_OBJS) X/?*.o X86/?*.o -ALL_DEPS = $(SUBDIRS) DONE X/DONE X86/DONE -SharedDepModuleTarget($(LIBNAME),$(ALL_DEPS),$(ALL_OBJS)) -InstallDynamicModule($(LIBNAME),$(MODULEDIR)/dri,.) -#endif - DependTarget() diff --git a/xc/lib/GL/mesa/src/OSmesa/Imakefile b/xc/lib/GL/mesa/src/OSmesa/Imakefile new file mode 100644 index 000000000..1b8cc928d --- /dev/null +++ b/xc/lib/GL/mesa/src/OSmesa/Imakefile @@ -0,0 +1,249 @@ + +#include <Threads.tmpl> + +#define DoNormalLib NormalLibGlx +#define DoSharedLib SharedLibGlx +#define DoExtraLib SharedLibGlx +#define DoDebugLib DebugLibGlx +#define DoProfileLib ProfileLibGlx + +LinkSourceFile(osmesa.c, ../../../../../extras/Mesa/src/OSmesa) + + +#if Malloc0ReturnsNull +ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL +#endif + +MESA_INCLUDES = -I. -I.. -I../../include -I../../../../../include + + DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) + INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) + + MESASRCS = ../aatriangle.c \ + ../accum.c \ + ../alpha.c \ + ../alphabuf.c \ + ../attrib.c \ + ../bbox.c \ + ../bitmap.c \ + ../blend.c \ + ../buffers.c \ + ../clip.c \ + ../colortab.c \ + ../config.c \ + ../context.c \ + ../copypix.c \ + ../cva.c \ + ../debug_xform.c \ + ../depth.c \ + ../dlist.c \ + ../drawpix.c \ + ../enable.c \ + ../enums.c \ + ../eval.c \ + ../extensions.c \ + ../feedback.c \ + ../fog.c \ + ../get.c \ + ../glapi.c \ + ../glapinoop.c \ + ../glthread.c \ + ../hash.c \ + ../image.c \ + ../imaging.c \ + ../light.c \ + ../lines.c \ + ../logic.c \ + ../masking.c \ + ../matrix.c \ + ../mem.c \ + ../mmath.c \ + ../pb.c \ + ../pipeline.c \ + ../pixel.c \ + ../pixeltex.c \ + ../points.c \ + ../polygon.c \ + ../quads.c \ + ../rastpos.c \ + ../readpix.c \ + ../rect.c \ + ../scissor.c \ + ../shade.c \ + ../span.c \ + ../stages.c \ + ../state.c \ + ../stencil.c \ + ../teximage.c \ + ../texobj.c \ + ../texstate.c \ + ../texture.c \ + ../texutil.c \ + ../translate.c \ + ../triangle.c \ + ../varray.c \ + ../vb.c \ + ../vbcull.c \ + ../vbfill.c \ + ../vbindirect.c \ + ../vbrender.c \ + ../vbxform.c \ + ../vector.c \ + ../vertices.c \ + ../winpos.c \ + ../xform.c \ + ../zoom.c \ + ../X86/common_x86.c \ + osmesa.c + + MESAOBJS = ../aatriangle.o \ + ../accum.o \ + ../alpha.o \ + ../alphabuf.o \ + ../attrib.o \ + ../bbox.o \ + ../bitmap.o \ + ../blend.o \ + ../buffers.o \ + ../clip.o \ + ../colortab.o \ + ../config.o \ + ../context.o \ + ../copypix.o \ + ../cva.o \ + ../debug_xform.o \ + ../depth.o \ + ../dlist.o \ + ../drawpix.o \ + ../enable.o \ + ../enums.o \ + ../eval.o \ + ../extensions.o \ + ../feedback.o \ + ../fog.o \ + ../get.o \ + ../hash.o \ + ../hint.o \ + ../image.o \ + ../imaging.o \ + ../light.o \ + ../lines.o \ + ../logic.o \ + ../masking.o \ + ../matrix.o \ + ../mem.o \ + ../mmath.o \ + ../pb.o \ + ../pipeline.o \ + ../pixel.o \ + ../pixeltex.o \ + ../points.o \ + ../polygon.o \ + ../quads.o \ + ../rastpos.o \ + ../readpix.o \ + ../rect.o \ + ../scissor.o \ + ../shade.o \ + ../span.o \ + ../stages.o \ + ../state.o \ + ../stencil.o \ + ../teximage.o \ + ../texobj.o \ + ../texstate.o \ + ../texture.o \ + ../texutil.o \ + ../translate.o \ + ../triangle.o \ + ../varray.o \ + ../vb.o \ + ../vbcull.o \ + ../vbfill.o \ + ../vbindirect.o \ + ../vbrender.o \ + ../vbxform.o \ + ../vector.o \ + ../vertices.o \ + ../winpos.o \ + ../xform.o \ + ../zoom.o \ + osmesa.o + +#ifdef i386Architecture + X86_SRCS = ../X86/x86.c \ + ../X86/x86a.S \ + ../X86/common_x86.c \ + ../X86/common_x86asm.S \ + ../X86/vertex.S + + X86_OBJS = ../X86/x86.o \ + ../X86/x86a.o \ + ../X86/common_x86.o \ + ../X86/common_x86asm.o \ + ../X86/vertex.o + + MMX_SRCS = ../X86/mmx_blend.S + + MMX_OBJS = ../X86/mmx_blend.o + +XCOMM Disabling 3Dnow code for the time being. +#if 0 + 3DNOW_SRCS = ../X86/3dnow.c \ + ../X86/3dnow_norm_raw.S \ + ../X86/3dnow_xform_masked1.S \ + ../X86/3dnow_xform_masked2.S \ + ../X86/3dnow_xform_masked3.S \ + ../X86/3dnow_xform_masked4.S \ + ../X86/3dnow_xform_raw1.S \ + ../X86/3dnow_xform_raw2.S \ + ../X86/3dnow_xform_raw3.S \ + ../X86/3dnow_xform_raw4.S \ + ../X86/vertex_3dnow.S + + 3DNOW_OBJS = ../X86/3dnow.o \ + ../X86/3dnow_norm_raw.o \ + ../X86/3dnow_xform_masked1.o \ + ../X86/3dnow_xform_masked2.o \ + ../X86/3dnow_xform_masked3.o \ + ../X86/3dnow_xform_masked4.o \ + ../X86/3dnow_xform_raw1.o \ + ../X86/3dnow_xform_raw2.o \ + ../X86/3dnow_xform_raw3.o \ + ../X86/3dnow_xform_raw4.o \ + ../X86/vertex_3dnow.o +#endif + +#endif + + ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) + ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) + + SRCS = $(MESASRCS) $(ASMSRCS) + OBJS = $(MESAOBJS) $(ASMOBJS) + UOBJS = $(MESAOBJS) $(ASMOBJS) + DONES = DONE + +#if !GlxUseBuiltInDRIDriver + REQUIREDLIBS += -L../../.. -lGL +#endif + +#include <Library.tmpl> + +LibraryObjectRule() + +SubdirLibraryRule($(OBJS)) +NormalLintTarget($(SRCS)) + +LIBNAME = OSMesa +SOREV = 3.3 + + +/*NormalDepLibraryTarget($(LIBNAME), $(DONES), $(UOBJS))*/ +/*InstallLibrary($(LIBNAME),$(USRLIBDIR))*/ + +SharedDepLibraryTarget($(LIBNAME),$(SOREV), $(DONES), $(OBJS), ., .) +InstallSharedLibrary($(LIBNAME),$(SOREV),$(SHLIBDIR)) + + +DependTarget() diff --git a/xc/lib/GL/mesa/src/drv/gamma/Imakefile b/xc/lib/GL/mesa/src/drv/gamma/Imakefile index 05e35561e..7ad8c621b 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/Imakefile +++ b/xc/lib/GL/mesa/src/drv/gamma/Imakefile @@ -1,4 +1,5 @@ -XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile,v 1.8 2000/03/02 16:07:35 martin Exp $ + +#include <Threads.tmpl> #define DoNormalLib NormalLibGlx #define DoSharedLib SharedLibGlx @@ -6,28 +7,35 @@ XCOMM $XFree86: xc/lib/GL/mesa/src/drv/gamma/Imakefile,v 1.8 2000/03/02 16:07:35 #define DoDebugLib DebugLibGlx #define DoProfileLib ProfileLibGlx -LinkSourceFile(xmesaP.h, ../../../../../../extras/Mesa/src/X) -LinkSourceFile(glapi.h, ../../../../../../extras/Mesa/src) - - #if Malloc0ReturnsNull ALLOC_DEFINES = -DMALLOC_0_RETURNS_NULL #endif #if BuildXF86DRI - DRI_DEFINES = GlxDefines + DRI_DEFINES = GlxDefines -DDRIVERTS DRI_INCLUDES = -I../../../../dri -I../../../../glx \ -I../../../dri \ -I$(TOP)/include -I$(TOP)/include/GL \ -I$(XF86OSSRC) -I$(SERVERSRC)/GL/dri \ -I$(XF86DRIVERSRC)/glint \ - -I../../../include -I../.. -I../../X + -I../../../include -I../.. -I../../X -I../common \ + -I$(XF86OSSRC)/linux/drm/kernel #endif MESA_INCLUDES = -I. -I.. -I../../include + + DEFINES = $(ALLOC_DEFINES) $(DRI_DEFINES) - INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) + INCLUDES = -I$(XLIBSRC) -I$(EXTINCSRC) $(MESA_INCLUDES) $(DRI_INCLUDES) + +#if 0 + LOSRC = ../../../../lowpc.c + LOOBJ = ../../../../lowpc.o + + HISRC = ../../../../highpc.c + HIOBJ = ../../../../highpc.o +#endif DRISRCS = ../../../dri/dri_mesa.c \ ../../../../dri/dri_tmm.c @@ -46,16 +54,216 @@ MESA_INCLUDES = -I. -I.. -I../../include ../../../../dri/drm/xf86drmSL.o GAMMASRCS = gamma_gl.c gamma_xmesa.c gamma_init.c gamma_matrix.c \ - gamma_inithw.c gamma_texture.c + gamma_inithw.c gamma_texture.c /* gamma_dlist.c */ GAMMAOBJS = gamma_gl.o gamma_xmesa.o gamma_init.o gamma_matrix.o \ - gamma_inithw.o gamma_texture.o + gamma_inithw.o gamma_texture.o /* gamma_dlist.o */ + + MESASRCS = ../../aatriangle.c \ + ../../accum.c \ + ../../alpha.c \ + ../../alphabuf.c \ + ../../attrib.c \ + ../../bbox.c \ + ../../bitmap.c \ + ../../blend.c \ + ../../buffers.c \ + ../../clip.c \ + ../../colortab.c \ + ../../config.c \ + ../../context.c \ + ../../copypix.c \ + ../../cva.c \ + ../../debug_xform.c \ + ../../depth.c \ + ../../dlist.c \ + ../../drawpix.c \ + ../../enable.c \ + ../../enums.c \ + ../../eval.c \ + ../../extensions.c \ + ../../feedback.c \ + ../../fog.c \ + ../../get.c \ + ../../glapi.c \ + ../../glapinoop.c \ + ../../glthread.c \ + ../../hash.c \ + ../../image.c \ + ../../imaging.c \ + ../../light.c \ + ../../lines.c \ + ../../logic.c \ + ../../masking.c \ + ../../matrix.c \ + ../../mem.c \ + ../../mmath.c \ + ../../pb.c \ + ../../pipeline.c \ + ../../pixel.c \ + ../../pixeltex.c \ + ../../points.c \ + ../../polygon.c \ + ../../quads.c \ + ../../rastpos.c \ + ../../readpix.c \ + ../../rect.c \ + ../../scissor.c \ + ../../shade.c \ + ../../span.c \ + ../../stages.c \ + ../../state.c \ + ../../stencil.c \ + ../../teximage.c \ + ../../texobj.c \ + ../../texstate.c \ + ../../texture.c \ + ../../texutil.c \ + ../../translate.c \ + ../../triangle.c \ + ../../varray.c \ + ../../vb.c \ + ../../vbcull.c \ + ../../vbfill.c \ + ../../vbindirect.c \ + ../../vbrender.c \ + ../../vbxform.c \ + ../../vector.c \ + ../../vertices.c \ + ../../winpos.c \ + ../../xform.c \ + ../../zoom.c \ + ../../X86/common_x86.c + + MESAOBJS = ../../aatriangle.o \ + ../../accum.o \ + ../../alpha.o \ + ../../alphabuf.o \ + ../../attrib.o \ + ../../bbox.o \ + ../../bitmap.o \ + ../../blend.o \ + ../../buffers.o \ + ../../clip.o \ + ../../colortab.o \ + ../../config.o \ + ../../context.o \ + ../../copypix.o \ + ../../cva.o \ + ../../debug_xform.o \ + ../../depth.o \ + ../../dlist.o \ + ../../drawpix.o \ + ../../enable.o \ + ../../enums.o \ + ../../eval.o \ + ../../extensions.o \ + ../../feedback.o \ + ../../fog.o \ + ../../get.o \ + ../../hash.o \ + ../../hint.o \ + ../../image.o \ + ../../imaging.o \ + ../../light.o \ + ../../lines.o \ + ../../logic.o \ + ../../masking.o \ + ../../matrix.o \ + ../../mem.o \ + ../../mmath.o \ + ../../pb.o \ + ../../pipeline.o \ + ../../pixel.o \ + ../../pixeltex.o \ + ../../points.o \ + ../../polygon.o \ + ../../quads.o \ + ../../rastpos.o \ + ../../readpix.o \ + ../../rect.o \ + ../../scissor.o \ + ../../shade.o \ + ../../span.o \ + ../../stages.o \ + ../../state.o \ + ../../stencil.o \ + ../../teximage.o \ + ../../texobj.o \ + ../../texstate.o \ + ../../texture.o \ + ../../texutil.o \ + ../../translate.o \ + ../../triangle.o \ + ../../varray.o \ + ../../vb.o \ + ../../vbcull.o \ + ../../vbfill.o \ + ../../vbindirect.o \ + ../../vbrender.o \ + ../../vbxform.o \ + ../../vector.o \ + ../../vertices.o \ + ../../winpos.o \ + ../../xform.o \ + ../../zoom.o + +#ifdef i386Architecture + X86_SRCS = ../../X86/x86.c \ + ../../X86/x86a.S \ + ../../X86/common_x86.c \ + ../../X86/common_x86asm.S \ + ../../X86/vertex.S -XCOMM SRCS = $(DRISRCS) $(DRMSRCS) $(GAMMASRCS) -XCOMM OBJS = $(DRIOBJS) $(DRMOBJS) $(GAMMAOBJS) + X86_OBJS = ../../X86/x86.o \ + ../../X86/x86a.o \ + ../../X86/common_x86.o \ + ../../X86/common_x86asm.o \ + ../../X86/vertex.o - SRCS = $(GAMMASRCS) - OBJS = $(DRIOBJS) $(DRMOBJS) $(GAMMAOBJS) + MMX_SRCS = ../../X86/mmx_blend.S + + MMX_OBJS = ../../X86/mmx_blend.o + +XCOMM Disabling 3Dnow code for the time being. +#if 0 + 3DNOW_SRCS = ../../X86/3dnow.c \ + ../../X86/3dnow_norm_raw.S \ + ../../X86/3dnow_xform_masked1.S \ + ../../X86/3dnow_xform_masked2.S \ + ../../X86/3dnow_xform_masked3.S \ + ../../X86/3dnow_xform_masked4.S \ + ../../X86/3dnow_xform_raw1.S \ + ../../X86/3dnow_xform_raw2.S \ + ../../X86/3dnow_xform_raw3.S \ + ../../X86/3dnow_xform_raw4.S \ + ../../X86/vertex_3dnow.S + + 3DNOW_OBJS = ../../X86/3dnow.o \ + ../../X86/3dnow_norm_raw.o \ + ../../X86/3dnow_xform_masked1.o \ + ../../X86/3dnow_xform_masked2.o \ + ../../X86/3dnow_xform_masked3.o \ + ../../X86/3dnow_xform_masked4.o \ + ../../X86/3dnow_xform_raw1.o \ + ../../X86/3dnow_xform_raw2.o \ + ../../X86/3dnow_xform_raw3.o \ + ../../X86/3dnow_xform_raw4.o \ + ../../X86/vertex_3dnow.o +#endif + +#endif + + ASMSRCS = $(X86_SRCS) $(MMX_SRCS) $(3DNOW_SRCS) + ASMOBJS = $(X86_OBJS) $(MMX_OBJS) $(3DNOW_OBJS) + + SRCS = $(LOWSRC) $(DRISRCS) $(DRMSRCS) $(MESASRCS) $(ASMSRCS) $(GAMMASRCS) $(HISRC) + OBJS = $(LOWOBJ) $(DRIOBJS) $(DRMOBJS) $(MESAOBJS) $(ASMOBJS) $(GAMMAOBJS) $(HIOBJ) + +REQUIREDLIBS += -lm +#if !GlxBuiltInGamma +REQUIREDLIBS += -L../../../.. -lGL +#endif #if !GlxUseBuiltInDRIDriver diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c index 3bd2fd0f3..47d1139a5 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_gl.c @@ -30,13 +30,16 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Authors: * Kevin E. Martin <kevin@precisioninsight.com> * Brian Paul <brian@precisioninsight.com> + * Alan Hourihane <Alan.Hourihane@btinternet.com> */ #ifdef GLX_DIRECT_RENDERING +#include <Xarch.h> #include <math.h> #include "gamma_gl.h" #include "gamma_init.h" +#include "glint_dri.h" #ifdef RANDOMIZE_COLORS #include <stdlib.h> #endif @@ -114,7 +117,7 @@ void _gamma_Begin(GLenum mode) DEBUG_GLCMDS(("Begin: %04x\n", (int)mode)); if ((gCCPriv->Begin & B_PrimType_Mask) != B_PrimType_Null) { - /* ERROR!!! */ + DEBUG_ERROR(("Begin: Error\n")); return; } @@ -177,8 +180,9 @@ void _gamma_BindTexture(GLenum target, GLuint texture) gCCPriv->curTexObj = gammaTOFind(texture); /* Make the new texture images resident */ - if (!driTMMMakeImagesResident(gCCPriv->tmm, MIPMAP_LEVELS, - gCCPriv->curTexObj->image, addrs)) { + if (driTMMMakeImagesResident(gCCPriv->tmm, MIPMAP_LEVELS, + gCCPriv->curTexObj->image, addrs) < 0) { + DEBUG_ERROR(("BindTexture: unable\n")); /* NOT_DONE: Handle error */ } @@ -358,10 +362,12 @@ void _gamma_CallLists(GLsizei n, GLenum type, const GLvoid *lists) void _gamma_Clear(GLbitfield mask) { + int temp; unsigned int depth = 0; int do_clear = 0; + GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)gCC->driScreenPriv->pDevPriv; #ifdef DO_VALIDATE - __DRIscreenPrivate *driScrnPriv = gCC->driContextPriv->driScreenPriv; + __DRIscreenPrivate *driScrnPriv = gCC->driScreenPriv; #endif DEBUG_GLCMDS(("Clear: %04x\n", (int)mask)); @@ -437,11 +443,12 @@ void _gamma_Clear(GLbitfield mask) gCCPriv->FrameCount &= 0xff; #endif + temp = (gCCPriv->LBReadMode & LBPartialProdMask) | LBWindowOriginBot; + /* UGH - move this later ! */ + if (gDRIPriv->numMXDevices == 2) temp |= LBScanLineInt2; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); - WRITE(gCCPriv->buf, LBReadMode, - ((gCCPriv->LBReadMode & LBPartialProdMask) | - LBScanLineInt2 | - LBWindowOriginBot)); + WRITE(gCCPriv->buf, LBReadMode, temp); /* Force FCP to be written */ CHECK_DMA_BUFFER(gCC, gCCPriv, 1); @@ -627,34 +634,48 @@ void _gamma_ClipPlane(GLenum plane, const GLdouble *equation) void _gamma_Color3b(GLbyte red, GLbyte green, GLbyte blue) { + GLfloat r,g,b; + DEBUG_GLCMDS(("Color3b: %d %d %d\n", red, green, blue)); + + r = BYTE_TO_FLOAT(red); + g = BYTE_TO_FLOAT(green); + b = BYTE_TO_FLOAT(blue); + + _gamma_Color3f(r,g,b); } void _gamma_Color3bv(const GLbyte *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Color3bv: %d %d %d\n", v[0], v[1], v[2])); + + p[0] = BYTE_TO_FLOAT(v[0]); + p[1] = BYTE_TO_FLOAT(v[1]); + p[2] = BYTE_TO_FLOAT(v[2]); + + _gamma_Color3f(p[0],p[1],p[2]); } void _gamma_Color3d(GLdouble red, GLdouble green, GLdouble blue) { DEBUG_GLCMDS(("Color3d: %f %f %f\n", red, green, blue)); + + _gamma_Color3f((GLfloat)red,(GLfloat)green,(GLfloat)blue); } void _gamma_Color3dv(const GLdouble *v) { DEBUG_GLCMDS(("Color3dv: %f %f %f\n", v[0], v[1], v[2])); + + _gamma_Color3fv((GLfloat*)v); } void _gamma_Color3f(GLfloat red, GLfloat green, GLfloat blue) { DEBUG_GLCMDS(("Color3f: %f %f %f\n", red, green, blue)); -#ifdef RANDOMIZE_COLORS - red = (random() / (double)RAND_MAX); - green = (random() / (double)RAND_MAX); - blue = (random() / (double)RAND_MAX); -#endif - CHECK_DMA_BUFFER(gCC, gCCPriv, 3); WRITEF(gCCPriv->buf, Cb, blue); WRITEF(gCCPriv->buf, Cg, green); @@ -665,107 +686,188 @@ void _gamma_Color3fv(const GLfloat *v) { DEBUG_GLCMDS(("Color3fv: %f %f %f\n", v[0], v[1], v[2])); -#ifdef RANDOMIZE_COLORS - { - float r, g, b; - r = (random() / (double)RAND_MAX); - g = (random() / (double)RAND_MAX); - b = (random() / (double)RAND_MAX); - CHECK_DMA_BUFFER(gCC, gCCPriv, 3); - WRITEF(gCCPriv->buf, Cb, b); - WRITEF(gCCPriv->buf, Cg, g); - WRITEF(gCCPriv->buf, Cr3, r); - } -#else CHECK_DMA_BUFFER(gCC, gCCPriv, 3); WRITEF(gCCPriv->buf, Cb, v[2]); WRITEF(gCCPriv->buf, Cg, v[1]); WRITEF(gCCPriv->buf, Cr3, v[0]); -#endif } void _gamma_Color3i(GLint red, GLint green, GLint blue) { + GLfloat r,g,b; + DEBUG_GLCMDS(("Color3i: %d %d %d\n", (int)red, (int)green, (int)blue)); + + r = INT_TO_FLOAT(red); + g = INT_TO_FLOAT(green); + b = INT_TO_FLOAT(blue); + + _gamma_Color3f(r,g,b); } void _gamma_Color3iv(const GLint *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Color3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2])); + + p[0] = INT_TO_FLOAT(v[0]); + p[1] = INT_TO_FLOAT(v[1]); + p[2] = INT_TO_FLOAT(v[2]); + + _gamma_Color3f(p[0],p[1],p[2]); } void _gamma_Color3s(GLshort red, GLshort green, GLshort blue) { + GLfloat r,g,b; + DEBUG_GLCMDS(("Color3s: %d %d %d\n", red, green, blue)); + + r = SHORT_TO_FLOAT(red); + g = SHORT_TO_FLOAT(green); + b = SHORT_TO_FLOAT(blue); + + _gamma_Color3f(r,g,b); } void _gamma_Color3sv(const GLshort *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Color3sv: %d %d %d\n", v[0], v[1], v[2])); + + p[0] = SHORT_TO_FLOAT(v[0]); + p[1] = SHORT_TO_FLOAT(v[1]); + p[2] = SHORT_TO_FLOAT(v[2]); + + _gamma_Color3f(p[0],p[1],p[2]); } void _gamma_Color3ub(GLubyte red, GLubyte green, GLubyte blue) { + GLuint c; + DEBUG_GLCMDS(("Color3ub: %d %d %d\n", red, green, blue)); + + c = (blue << 16) | (green << 8) | red; + + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, PackedColor3, c); } void _gamma_Color3ubv(const GLubyte *v) { + GLuint c; + DEBUG_GLCMDS(("Color3ubv: %d %d %d\n", v[0], v[1], v[2])); + + c = (v[2] << 16) | (v[1] << 8) | v[0]; + + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, PackedColor3, c); } void _gamma_Color3ui(GLuint red, GLuint green, GLuint blue) { + GLfloat r,g,b; + DEBUG_GLCMDS(("Color3ui: %d %d %d\n", (unsigned int)red, (unsigned int)green, (unsigned int)blue)); + + r = UINT_TO_FLOAT(red); + g = UINT_TO_FLOAT(green); + b = UINT_TO_FLOAT(blue); + + _gamma_Color3f(r,g,b); } void _gamma_Color3uiv(const GLuint *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Color3uiv: %d %d %d\n", (unsigned int)v[0], (unsigned int)v[1], (unsigned int)v[2])); + + p[0] = UINT_TO_FLOAT(v[0]); + p[1] = UINT_TO_FLOAT(v[1]); + p[2] = UINT_TO_FLOAT(v[2]); + + _gamma_Color3f(p[0],p[1],p[2]); } void _gamma_Color3us(GLushort red, GLushort green, GLushort blue) { + GLfloat r,g,b; + DEBUG_GLCMDS(("Color3us: %d %d %d\n", red, green, blue)); + + r = USHORT_TO_FLOAT(red); + g = USHORT_TO_FLOAT(green); + b = USHORT_TO_FLOAT(blue); + + _gamma_Color3f(r,g,b); } void _gamma_Color3usv(const GLushort *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Color3usv: %d %d %d\n", v[0], v[1], v[2])); + + p[0] = USHORT_TO_FLOAT(v[0]); + p[1] = USHORT_TO_FLOAT(v[1]); + p[2] = USHORT_TO_FLOAT(v[2]); + + _gamma_Color3f(p[0],p[1],p[2]); } void _gamma_Color4b(GLbyte red, GLbyte green, GLbyte blue, GLbyte alpha) { + GLfloat r,g,b,a; + DEBUG_GLCMDS(("Color4b: %d %d %d %d\n", red, green, blue, alpha)); + + r = BYTE_TO_FLOAT(red); + g = BYTE_TO_FLOAT(green); + b = BYTE_TO_FLOAT(blue); + a = BYTE_TO_FLOAT(alpha); + + _gamma_Color4f(r,g,b,a); } void _gamma_Color4bv(const GLbyte *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("Color4bv: %d %d %d %d\n", v[0], v[1], v[2], v[3])); + + p[0] = BYTE_TO_FLOAT(v[0]); + p[1] = BYTE_TO_FLOAT(v[1]); + p[2] = BYTE_TO_FLOAT(v[2]); + p[3] = BYTE_TO_FLOAT(v[3]); + + _gamma_Color4f(p[0],p[1],p[2],p[3]); } void _gamma_Color4d(GLdouble red, GLdouble green, GLdouble blue, GLdouble alpha) { DEBUG_GLCMDS(("Color4d: %f %f %f %f\n", red, green, blue, alpha)); + + _gamma_Color4f((GLfloat)red,(GLfloat)green,(GLfloat)blue,(GLfloat)alpha); } void _gamma_Color4dv(const GLdouble *v) { DEBUG_GLCMDS(("Color4dv: %f %f %f %f\n", v[0], v[1], v[2], v[3])); + + _gamma_Color4fv((GLfloat*)v); } void _gamma_Color4f(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) { DEBUG_GLCMDS(("Color4f: %f %f %f %f\n", red, green, blue, alpha)); -#ifdef RANDOMIZE_COLORS - red = (random() / (double)RAND_MAX); - green = (random() / (double)RAND_MAX); - blue = (random() / (double)RAND_MAX); -#endif - CHECK_DMA_BUFFER(gCC, gCCPriv, 4); WRITEF(gCCPriv->buf, Ca, alpha); WRITEF(gCCPriv->buf, Cb, blue); @@ -777,47 +879,69 @@ void _gamma_Color4fv(const GLfloat *v) { DEBUG_GLCMDS(("Color4fv: %f %f %f %f\n", v[0], v[1], v[2], v[3])); -#ifdef RANDOMIZE_COLORS - { - float r, g, b; - r = (random() / (double)RAND_MAX); - g = (random() / (double)RAND_MAX); - b = (random() / (double)RAND_MAX); - CHECK_DMA_BUFFER(gCC, gCCPriv, 4); - WRITEF(gCCPriv->buf, Ca, v[3]); - WRITEF(gCCPriv->buf, Cb, b); - WRITEF(gCCPriv->buf, Cg, g); - WRITEF(gCCPriv->buf, Cr3, r); - } -#else CHECK_DMA_BUFFER(gCC, gCCPriv, 4); WRITEF(gCCPriv->buf, Ca, v[3]); WRITEF(gCCPriv->buf, Cb, v[2]); WRITEF(gCCPriv->buf, Cg, v[1]); WRITEF(gCCPriv->buf, Cr4, v[0]); -#endif } void _gamma_Color4i(GLint red, GLint green, GLint blue, GLint alpha) { + GLfloat r,g,b,a; + DEBUG_GLCMDS(("Color4i: %d %d %d %d\n", (int)red, (int)green, (int)blue, (int)alpha)); + + r = INT_TO_FLOAT(red); + g = INT_TO_FLOAT(green); + b = INT_TO_FLOAT(blue); + a = INT_TO_FLOAT(alpha); + + _gamma_Color4f(r,g,b,a); } void _gamma_Color4iv(const GLint *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("Color4iv: %d %d %d %d\n", (int)v[0], (int)v[1], (int)v[2], (int)v[3])); + + p[0] = INT_TO_FLOAT(v[0]); + p[1] = INT_TO_FLOAT(v[1]); + p[2] = INT_TO_FLOAT(v[2]); + p[3] = INT_TO_FLOAT(v[3]); + + _gamma_Color4f(p[0],p[1],p[2],p[3]); } void _gamma_Color4s(GLshort red, GLshort green, GLshort blue, GLshort alpha) { + GLfloat r,g,b,a; + DEBUG_GLCMDS(("Color4s: %d %d %d %d\n", red, green, blue, alpha)); + + r = SHORT_TO_FLOAT(red); + g = SHORT_TO_FLOAT(green); + b = SHORT_TO_FLOAT(blue); + a = SHORT_TO_FLOAT(alpha); + + _gamma_Color4f(r,g,b,a); } void _gamma_Color4sv(const GLshort *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("Color4sv: %d %d %d %d\n", v[0], v[1], v[2], v[3])); + + p[0] = SHORT_TO_FLOAT(v[0]); + p[1] = SHORT_TO_FLOAT(v[1]); + p[2] = SHORT_TO_FLOAT(v[2]); + p[3] = SHORT_TO_FLOAT(v[3]); + + _gamma_Color4f(p[0],p[1],p[2],p[3]); } void _gamma_Color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) @@ -826,11 +950,7 @@ void _gamma_Color4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) DEBUG_GLCMDS(("Color4ub: %d %d %d %d\n", red, green, blue, alpha)); -#ifdef RANDOMIZE_COLORS - c = (random() / (double)RAND_MAX) * 16777216; -#else c = (alpha << 24) | (blue << 16) | (green << 8) | red; -#endif CHECK_DMA_BUFFER(gCC, gCCPriv, 1); WRITE(gCCPriv->buf, PackedColor4, c); @@ -842,17 +962,7 @@ void _gamma_Color4ubv(const GLubyte *v) DEBUG_GLCMDS(("Color4ubv: %d %d %d %d\n", v[0], v[1], v[2], v[3])); -#ifdef RANDOMIZE_COLORS - c = (random() / (double)RAND_MAX) * 16777216; -#else -/* NOT_DONE: Is there a standard define for endianness? */ -#define IS_LITTLE_ENDIAN 1 -#if IS_LITTLE_ENDIAN - c = *((GLuint *)v); -#else c = (v[3] << 24) | (v[2] << 16) | (v[1] << 8) | v[0]; -#endif -#endif CHECK_DMA_BUFFER(gCC, gCCPriv, 1); WRITE(gCCPriv->buf, PackedColor4, c); @@ -860,26 +970,62 @@ void _gamma_Color4ubv(const GLubyte *v) void _gamma_Color4ui(GLuint red, GLuint green, GLuint blue, GLuint alpha) { + GLfloat r,g,b,a; + DEBUG_GLCMDS(("Color4ui: %d %d %d %d\n", (unsigned int)red, (unsigned int)green, (unsigned int)blue, (unsigned int)alpha)); + + r = UINT_TO_FLOAT(red); + g = UINT_TO_FLOAT(green); + b = UINT_TO_FLOAT(blue); + a = UINT_TO_FLOAT(alpha); + + _gamma_Color4f(r,g,b,a); } void _gamma_Color4uiv(const GLuint *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("Color4uiv: %d %d %d %d\n", (unsigned int)v[0], (unsigned int)v[1], (unsigned int)v[2], (unsigned int)v[3])); + + p[0] = UINT_TO_FLOAT(v[0]); + p[1] = UINT_TO_FLOAT(v[1]); + p[2] = UINT_TO_FLOAT(v[2]); + p[3] = UINT_TO_FLOAT(v[3]); + + _gamma_Color4f(p[0],p[1],p[2],p[3]); } void _gamma_Color4us(GLushort red, GLushort green, GLushort blue, GLushort alpha) { + GLfloat r,g,b,a; + DEBUG_GLCMDS(("Color4us: %d %d %d %d\n", red, green, blue, alpha)); + + r = USHORT_TO_FLOAT(red); + g = USHORT_TO_FLOAT(green); + b = USHORT_TO_FLOAT(blue); + a = USHORT_TO_FLOAT(alpha); + + _gamma_Color4f(r,g,b,a); } void _gamma_Color4usv(const GLushort *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("Color4usv: %d %d %d %d\n", v[0], v[1], v[2], v[3])); + + p[0] = USHORT_TO_FLOAT(v[0]); + p[1] = USHORT_TO_FLOAT(v[1]); + p[2] = USHORT_TO_FLOAT(v[2]); + p[3] = USHORT_TO_FLOAT(v[3]); + + _gamma_Color4f(p[0],p[1],p[2],p[3]); } void _gamma_ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) @@ -890,6 +1036,43 @@ void _gamma_ColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean void _gamma_ColorMaterial(GLenum face, GLenum mode) { DEBUG_GLCMDS(("ColorMaterial: %04x %04x\n", (int)face, (int)mode)); + + gCCPriv->MaterialMode &= ~MaterialModeEnable; + gCCPriv->ColorMaterialMode = ColorMaterialModeDisable; + + switch (face) { + case GL_FRONT: + gCCPriv->ColorMaterialMode |= ColorMaterialModeFront; + break; + case GL_BACK: + gCCPriv->ColorMaterialMode |= ColorMaterialModeBack; + break; + case GL_FRONT_AND_BACK: + gCCPriv->ColorMaterialMode |= ColorMaterialModeFrontAndBack; + break; + } + + switch (mode) { + case GL_AMBIENT: + gCCPriv->ColorMaterialMode |= ColorMaterialModeAmbient; + break; + case GL_EMISSION: + gCCPriv->ColorMaterialMode |= ColorMaterialModeEmission; + break; + case GL_DIFFUSE: + gCCPriv->ColorMaterialMode |= ColorMaterialModeDiffuse; + break; + case GL_SPECULAR: + gCCPriv->ColorMaterialMode |= ColorMaterialModeSpecular; + break; + case GL_AMBIENT_AND_DIFFUSE: + gCCPriv->ColorMaterialMode |= ColorMaterialModeAmbAndDiff; + break; + } + + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, ColorMaterialMode, gCCPriv->ColorMaterialMode); + WRITE(gCCPriv->buf, MaterialMode, gCCPriv->MaterialMode); } void _gamma_ColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) @@ -938,9 +1121,6 @@ void _gamma_CullFace(GLenum mode) gCCPriv->GeometryMode &= ~GM_PolyCullMask; -#ifdef CULL_ALL_PRIMS - gCCPriv->GeometryMode |= GM_PolyCullBoth; -#else switch (mode) { case GL_FRONT: gCCPriv->GeometryMode |= GM_PolyCullFront; @@ -955,7 +1135,7 @@ void _gamma_CullFace(GLenum mode) /* ERROR!! */ break; } -#endif + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode); } @@ -980,7 +1160,8 @@ void _gamma_DeleteTextures(GLsizei n, const GLuint *textures) for (i = 0; i < n; i++) { gammaTexObj *t = gammaTOFind(textures[i]); - if (!driTMMDeleteImages(gCCPriv->tmm, MIPMAP_LEVELS, t->image)) { + if (driTMMDeleteImages(gCCPriv->tmm, MIPMAP_LEVELS, t->image) < 0) { + DEBUG_ERROR(("DeleteTextures: unable\n")); /* NOT_DONE: Handle error */ } gammaTODelete(textures[i]); @@ -1068,11 +1249,9 @@ void _gamma_Disable(GLenum cap) switch (cap) { case GL_CULL_FACE: -#ifdef CULL_ALL_PRIMS gCCPriv->GeometryMode &= ~GM_PolyCullEnable; CHECK_DMA_BUFFER(gCC, gCCPriv, 1); WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode); -#endif break; case GL_DEPTH_TEST: if (gCCPriv->Flags & GAMMA_DEPTH_BUFFER) { @@ -1106,6 +1285,35 @@ void _gamma_Disable(GLenum cap) WRITE(gCCPriv->buf, FBReadMode, (gCCPriv->FBReadMode | gCCPriv->AB_FBReadMode)); break; + case GL_COLOR_MATERIAL: + gCCPriv->ColorMaterialMode &= ~ColorMaterialModeEnable; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, ColorMaterialMode, gCCPriv->ColorMaterialMode); + break; + case GL_FOG: + gCCPriv->Begin &= ~B_FogEnable; + gCCPriv->GeometryMode &= ~GM_FogEnable; + gCCPriv->DeltaMode &= ~DM_FogEnable; + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode); + WRITE(gCCPriv->buf, DeltaMode, gCCPriv->DeltaMode); + WRITE(gCCPriv->buf, FogMode, FogModeDisable); + break; + case GL_LIGHTING: + gCCPriv->LightingMode &= ~LightingModeEnable; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, LightingMode, gCCPriv->LightingMode); + break; + case GL_LIGHT0: + gCCPriv->Light0Mode &= ~LNM_On; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, Light0Mode, gCCPriv->Light0Mode); + break; + case GL_LIGHT1: + gCCPriv->Light1Mode &= ~LNM_On; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, Light1Mode, gCCPriv->Light1Mode); + break; case GL_TEXTURE_2D: gCCPriv->Texture2DEnabled = GL_FALSE; gCCPriv->Begin &= ~B_TextureEnable; @@ -1227,6 +1435,35 @@ void _gamma_Enable(GLenum cap) WRITE(gCCPriv->buf, FBReadMode, (gCCPriv->FBReadMode | gCCPriv->AB_FBReadMode)); break; + case GL_COLOR_MATERIAL: + gCCPriv->ColorMaterialMode |= ColorMaterialModeEnable; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, ColorMaterialMode, gCCPriv->ColorMaterialMode); + break; + case GL_FOG: + gCCPriv->Begin |= B_FogEnable; + gCCPriv->GeometryMode |= GM_FogEnable; + gCCPriv->DeltaMode |= DM_FogEnable; + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode); + WRITE(gCCPriv->buf, DeltaMode, gCCPriv->DeltaMode); + WRITE(gCCPriv->buf, FogMode, FogModeEnable); + break; + case GL_LIGHTING: + gCCPriv->LightingMode |= LightingModeEnable | 16<<6; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, LightingMode, gCCPriv->LightingMode); + break; + case GL_LIGHT0: + gCCPriv->Light0Mode |= LNM_On; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, Light0Mode, gCCPriv->Light0Mode); + break; + case GL_LIGHT1: + gCCPriv->Light1Mode |= LNM_On; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, Light1Mode, gCCPriv->Light1Mode); + break; case GL_TEXTURE_2D: gCCPriv->Texture2DEnabled = GL_TRUE; #ifndef TURN_OFF_TEXTURES @@ -1294,34 +1531,42 @@ void _gamma_EvalCoord1d(GLdouble u) void _gamma_EvalCoord1dv(const GLdouble *u) { + DEBUG_GLCMDS(("EvalCoord1dv: %f\n", *u)); } void _gamma_EvalCoord1f(GLfloat u) { + DEBUG_GLCMDS(("EvalCoord1f: %f\n", u)); } void _gamma_EvalCoord1fv(const GLfloat *u) { + DEBUG_GLCMDS(("EvalCoord1fv: %f\n", *u)); } void _gamma_EvalCoord2d(GLdouble u, GLdouble v) { + DEBUG_GLCMDS(("EvalCoord2d: %f %f\n", u, v)); } void _gamma_EvalCoord2dv(const GLdouble *u) { + DEBUG_GLCMDS(("EvalCoord2dv: %f %f\n", u[0], u[1])); } void _gamma_EvalCoord2f(GLfloat u, GLfloat v) { + DEBUG_GLCMDS(("EvalCoord2f: %f %f\n", u, v)); } void _gamma_EvalCoord2fv(const GLfloat *u) { + DEBUG_GLCMDS(("EvalCoord1fv: %f %f\n", u[0], u[1])); } void _gamma_EvalMesh1(GLenum mode, GLint i1, GLint i2) { + DEBUG_GLCMDS(("EvalMesh1: %d %d %d\n", mode, i1, i2)); } void _gamma_EvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2) @@ -1358,16 +1603,55 @@ void _gamma_Flush(void) void _gamma_Fogf(GLenum pname, GLfloat param) { DEBUG_GLCMDS(("Fogf: %04x %f\n", (int)pname, param)); + + switch (pname) { + case GL_FOG_DENSITY: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, FogDensity, param); + break; + } } void _gamma_Fogfv(GLenum pname, const GLfloat *params) { + int color; + DEBUG_GLCMDS(("Fogfv: %04x %f\n", (int)pname, *params)); + + switch (pname) { + case GL_FOG_COLOR: + color = ((int)params[3]<<24) | ((int)params[2]<<16) | + ((int)params[1]<<8) | ((int)params[0]); + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, FogColor, color); + break; + } } void _gamma_Fogi(GLenum pname, GLint param) { DEBUG_GLCMDS(("Fogi: %04x %d\n", (int)pname, (int)param)); + + gCCPriv->GeometryMode &= ~GM_FogMask; + + switch (pname) { + case GL_FOG_MODE: + switch (param) { + case GL_EXP: + gCCPriv->GeometryMode |= GM_FogExp; + break; + case GL_EXP2: + gCCPriv->GeometryMode |= GM_FogExpSquared; + break; + case GL_LINEAR: + gCCPriv->GeometryMode |= GM_FogLinear; + break; + } + break; + } + + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode); } void _gamma_Fogiv(GLenum pname, const GLint *params) @@ -1378,6 +1662,16 @@ void _gamma_Fogiv(GLenum pname, const GLint *params) void _gamma_FrontFace(GLenum mode) { DEBUG_GLCMDS(("FrontFace: %04x\n", (int)mode)); + + gCCPriv->GeometryMode &= ~GM_FFMask; + + if (mode == GL_CCW) + gCCPriv->GeometryMode |= GM_FrontFaceCCW; + else + gCCPriv->GeometryMode |= GM_FrontFaceCW; + + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode); } void _gamma_Frustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar) @@ -1463,14 +1757,24 @@ void _gamma_GetFloatv(GLenum val, GLfloat *f) void _gamma_GetIntegerv(GLenum val, GLint *i) { DEBUG_GLCMDS(("GetIntegerv: %04x\n", (int)val)); + + switch (val) { + case GL_MAX_TEXTURE_SIZE: + *i = 2048; + break; + } } void _gamma_GetLightfv(GLenum light, GLenum pname, GLfloat *params) { + DEBUG_GLCMDS(("GetLightfv: %04x %04x %f\n", + (int)light, (int)pname, *params)); } void _gamma_GetLightiv(GLenum light, GLenum pname, GLint *params) { + DEBUG_GLCMDS(("GetLightiv: %04x %04x %d\n", + (int)light, (int)pname, *params)); } void _gamma_GetMapdv(GLenum target, GLenum query, GLdouble *v) @@ -1517,7 +1821,7 @@ void _gamma_GetPolygonStipple(GLubyte *mask) const GLubyte *_gamma_GetString(GLenum name) { static unsigned char vendor[] = "Precision Insight, Inc."; - static unsigned char renderer[] = "DRI Glint-Gamma 20000228"; + static unsigned char renderer[] = "DRI Glint-Gamma 20000605"; static unsigned char version[] = "1.1"; static unsigned char ext[] = ""; @@ -1654,6 +1958,12 @@ GLboolean _gamma_IsEnabled(GLenum cap) { DEBUG_GLCMDS(("IsEnabled: %04x\n", (int)cap)); + switch (cap) { + case GL_LIGHTING: + return ((gCCPriv->LightingMode & LightingModeEnable)?GL_TRUE:GL_FALSE); + break; + } + return GL_TRUE; } @@ -1673,10 +1983,44 @@ GLboolean _gamma_IsTexture(GLuint texture) void _gamma_LightModelf(GLenum pname, GLfloat param) { + DEBUG_GLCMDS(("LightModelf: %04x %f\n", + (int)pname, param)); } void _gamma_LightModelfv(GLenum pname, const GLfloat *params) { + DEBUG_GLCMDS(("LightModelfv: %04x %f\n", + (int)pname, *params)); + + switch (pname) { + case GL_LIGHT_MODEL_AMBIENT: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + /* We don't do alpha */ + WRITEF(gCCPriv->buf, SceneAmbientColorBlue, params[2]); + WRITEF(gCCPriv->buf, SceneAmbientColorGreen, params[1]); + WRITEF(gCCPriv->buf, SceneAmbientColorRed, params[0]); + break; + case GL_LIGHT_MODEL_LOCAL_VIEWER: + if ((int)params[0] != 0) + gCCPriv->LightingMode |= LightingModeLocalViewer; + else + gCCPriv->LightingMode &= ~LightingModeLocalViewer; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, LightingMode, gCCPriv->LightingMode); + break; + case GL_LIGHT_MODEL_TWO_SIDE: + if ((int)params[0] != 0) { + gCCPriv->LightingMode |= LightingModeTwoSides; + gCCPriv->MaterialMode |= MaterialModeTwoSides; + } else { + gCCPriv->LightingMode &= ~LightingModeTwoSides; + gCCPriv->MaterialMode &= ~MaterialModeTwoSides; + } + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, LightingMode, gCCPriv->LightingMode); + WRITE(gCCPriv->buf, MaterialMode, gCCPriv->MaterialMode); + break; + } } void _gamma_LightModeli(GLenum pname, GLint param) @@ -1689,10 +2033,173 @@ void _gamma_LightModeliv(GLenum pname, const GLint *params) void _gamma_Lightf(GLenum light, GLenum pname, GLfloat param) { + DEBUG_GLCMDS(("Lightf: %04x %04x %f\n", + (int)light, (int)pname, param)); } void _gamma_Lightfv(GLenum light, GLenum pname, const GLfloat *params) { + GLfloat l,x,y,z; + DEBUG_GLCMDS(("Lightfv: %04x %04x %f\n", + (int)light, (int)pname, *params)); + + switch(light) { + case GL_LIGHT0: + switch (pname) { + case GL_AMBIENT: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + /* We don't do alpha */ + WRITEF(gCCPriv->buf, Light0AmbientIntensityBlue, params[2]); + WRITEF(gCCPriv->buf, Light0AmbientIntensityGreen, params[1]); + WRITEF(gCCPriv->buf, Light0AmbientIntensityRed, params[0]); + break; + case GL_DIFFUSE: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + /* We don't do alpha */ + WRITEF(gCCPriv->buf, Light0DiffuseIntensityBlue, params[2]); + WRITEF(gCCPriv->buf, Light0DiffuseIntensityGreen, params[1]); + WRITEF(gCCPriv->buf, Light0DiffuseIntensityRed, params[0]); + break; + case GL_SPECULAR: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + /* We don't do alpha */ + WRITEF(gCCPriv->buf, Light0SpecularIntensityBlue, params[2]); + WRITEF(gCCPriv->buf, Light0SpecularIntensityGreen, params[1]); + WRITEF(gCCPriv->buf, Light0SpecularIntensityRed, params[0]); + break; + case GL_POSITION: + /* Normalize <x,y,z> */ + x = params[0]; y = params[1]; z = params[2]; + l = sqrt(x*x + y*y + z*z); + x /= l; + y /= l; + z /= l; + if ((int)params[3] != 0) { + gCCPriv->Light0Mode |= Light0ModeAttenuation; + gCCPriv->Light0Mode |= Light0ModeLocal; + } else { + gCCPriv->Light0Mode &= ~Light0ModeAttenuation; + gCCPriv->Light0Mode &= ~Light0ModeLocal; + } + CHECK_DMA_BUFFER(gCC, gCCPriv, 5); + WRITE(gCCPriv->buf, Light0Mode, gCCPriv->Light0Mode); + WRITEF(gCCPriv->buf, Light0PositionW, params[3]); + WRITEF(gCCPriv->buf, Light0PositionZ, z); + WRITEF(gCCPriv->buf, Light0PositionY, y); + WRITEF(gCCPriv->buf, Light0PositionX, x); + break; + case GL_SPOT_DIRECTION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, Light0SpotlightDirectionZ, params[3]); + WRITEF(gCCPriv->buf, Light0SpotlightDirectionY, params[2]); + WRITEF(gCCPriv->buf, Light0SpotlightDirectionX, params[1]); + /* WRITEF(gCCPriv->buf, Light0SpotlightDirectionW, params[0]); */ + break; + case GL_SPOT_EXPONENT: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, Light0SpotlightExponent, params[0]); + break; + case GL_SPOT_CUTOFF: + if ((int)params[0] != -1) + gCCPriv->Light0Mode |= Light0ModeSpotLight; + else + gCCPriv->Light0Mode &= ~Light0ModeSpotLight; + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, Light0Mode, gCCPriv->Light0Mode); + WRITEF(gCCPriv->buf, Light0CosSpotlightCutoffAngle, params[0]); + break; + case GL_CONSTANT_ATTENUATION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, Light0ConstantAttenuation, params[0]); + break; + case GL_LINEAR_ATTENUATION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, Light0LinearAttenuation, params[0]); + break; + case GL_QUADRATIC_ATTENUATION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, Light0QuadraticAttenuation, params[0]); + break; + } + break; + case GL_LIGHT1: + switch (pname) { + case GL_AMBIENT: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + /* We don't do alpha */ + WRITEF(gCCPriv->buf, Light1AmbientIntensityBlue, params[2]); + WRITEF(gCCPriv->buf, Light1AmbientIntensityGreen, params[1]); + WRITEF(gCCPriv->buf, Light1AmbientIntensityRed, params[0]); + break; + case GL_DIFFUSE: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + /* We don't do alpha */ + WRITEF(gCCPriv->buf, Light1DiffuseIntensityBlue, params[2]); + WRITEF(gCCPriv->buf, Light1DiffuseIntensityGreen, params[1]); + WRITEF(gCCPriv->buf, Light1DiffuseIntensityRed, params[0]); + break; + case GL_SPECULAR: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + /* We don't do alpha */ + WRITEF(gCCPriv->buf, Light1SpecularIntensityBlue, params[2]); + WRITEF(gCCPriv->buf, Light1SpecularIntensityGreen, params[1]); + WRITEF(gCCPriv->buf, Light1SpecularIntensityRed, params[0]); + break; + case GL_POSITION: + /* Normalize <x,y,z> */ + x = params[0]; y = params[1]; z = params[2]; + l = sqrt(x*x + y*y + z*z); + x /= l; + y /= l; + z /= l; + if ((int)params[3] != 0) { + gCCPriv->Light1Mode |= Light1ModeAttenuation; + gCCPriv->Light1Mode |= Light1ModeLocal; + } else { + gCCPriv->Light0Mode &= ~Light0ModeAttenuation; + gCCPriv->Light0Mode &= ~Light0ModeLocal; + } + CHECK_DMA_BUFFER(gCC, gCCPriv, 5); + WRITE(gCCPriv->buf, Light1Mode, gCCPriv->Light1Mode); + WRITEF(gCCPriv->buf, Light1PositionW, params[3]); + WRITEF(gCCPriv->buf, Light1PositionZ, z); + WRITEF(gCCPriv->buf, Light1PositionY, y); + WRITEF(gCCPriv->buf, Light1PositionX, x); + break; + case GL_SPOT_DIRECTION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, Light1SpotlightDirectionZ, params[3]); + WRITEF(gCCPriv->buf, Light1SpotlightDirectionY, params[2]); + WRITEF(gCCPriv->buf, Light1SpotlightDirectionX, params[1]); + /* WRITEF(gCCPriv->buf, Light1SpotlightDirectionW, params[0]); */ + break; + case GL_SPOT_EXPONENT: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, Light1SpotlightExponent, params[0]); + break; + case GL_SPOT_CUTOFF: + if ((int)params[0] != -1) + gCCPriv->Light1Mode |= Light1ModeSpotLight; + else + gCCPriv->Light1Mode &= ~Light1ModeSpotLight; + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, Light1Mode, gCCPriv->Light1Mode); + WRITEF(gCCPriv->buf, Light1CosSpotlightCutoffAngle, params[0]); + break; + case GL_CONSTANT_ATTENUATION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, Light1ConstantAttenuation, params[0]); + break; + case GL_LINEAR_ATTENUATION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, Light1LinearAttenuation, params[0]); + break; + case GL_QUADRATIC_ATTENUATION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, Light1QuadraticAttenuation, params[0]); + break; + } + } } void _gamma_Lighti(GLenum light, GLenum pname, GLint param) @@ -1817,6 +2324,104 @@ void _gamma_Materialfv(GLenum face, GLenum pname, const GLfloat *params) { DEBUG_GLCMDS(("Materialfv: %04x %04x %f\n", (int)face, (int)pname, *params)); + + gCCPriv->MaterialMode |= MaterialModeEnable; + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, MaterialMode, gCCPriv->MaterialMode); + + if ((face == GL_FRONT) || (face == GL_FRONT_AND_BACK)) { + switch (pname) { + case GL_AMBIENT: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, FrontAmbientColorBlue, params[2]); + WRITEF(gCCPriv->buf, FrontAmbientColorGreen, params[1]); + WRITEF(gCCPriv->buf, FrontAmbientColorRed, params[0]); + break; + case GL_DIFFUSE: + CHECK_DMA_BUFFER(gCC, gCCPriv, 4); + WRITEF(gCCPriv->buf, FrontAlpha, params[3]); + WRITEF(gCCPriv->buf, FrontDiffuseColorBlue, params[2]); + WRITEF(gCCPriv->buf, FrontDiffuseColorGreen, params[1]); + WRITEF(gCCPriv->buf, FrontDiffuseColorRed, params[0]); + break; + case GL_SPECULAR: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, FrontSpecularColorBlue, params[2]); + WRITEF(gCCPriv->buf, FrontSpecularColorGreen, params[1]); + WRITEF(gCCPriv->buf, FrontSpecularColorRed, params[0]); + break; + case GL_EMISSION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, FrontEmissiveColorBlue, params[2]); + WRITEF(gCCPriv->buf, FrontEmissiveColorGreen, params[1]); + WRITEF(gCCPriv->buf, FrontEmissiveColorRed, params[0]); + break; + case GL_SHININESS: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, FrontSpecularExponent, params[0]); + break; + case GL_AMBIENT_AND_DIFFUSE: + CHECK_DMA_BUFFER(gCC, gCCPriv, 7); + WRITEF(gCCPriv->buf, FrontAmbientColorBlue, params[2]); + WRITEF(gCCPriv->buf, FrontAmbientColorGreen, params[1]); + WRITEF(gCCPriv->buf, FrontAmbientColorRed, params[0]); + WRITEF(gCCPriv->buf, FrontAlpha, params[3]); + WRITEF(gCCPriv->buf, FrontDiffuseColorBlue, params[2]); + WRITEF(gCCPriv->buf, FrontDiffuseColorGreen, params[1]); + WRITEF(gCCPriv->buf, FrontDiffuseColorRed, params[0]); + break; + case GL_COLOR_INDEXES: + /* NOT_DONE */ + break; + } + } + + if ((face == GL_BACK) || (face == GL_FRONT_AND_BACK)) { + switch (pname) { + case GL_AMBIENT: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, BackAmbientColorBlue, params[2]); + WRITEF(gCCPriv->buf, BackAmbientColorGreen, params[1]); + WRITEF(gCCPriv->buf, BackAmbientColorRed, params[0]); + break; + case GL_DIFFUSE: + CHECK_DMA_BUFFER(gCC, gCCPriv, 4); + WRITEF(gCCPriv->buf, BackAlpha, params[3]); + WRITEF(gCCPriv->buf, BackDiffuseColorBlue, params[2]); + WRITEF(gCCPriv->buf, BackDiffuseColorGreen, params[1]); + WRITEF(gCCPriv->buf, BackDiffuseColorRed, params[0]); + break; + case GL_SPECULAR: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, BackSpecularColorBlue, params[2]); + WRITEF(gCCPriv->buf, BackSpecularColorGreen, params[1]); + WRITEF(gCCPriv->buf, BackSpecularColorRed, params[0]); + break; + case GL_EMISSION: + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, BackEmissiveColorBlue, params[2]); + WRITEF(gCCPriv->buf, BackEmissiveColorGreen, params[1]); + WRITEF(gCCPriv->buf, BackEmissiveColorRed, params[0]); + break; + case GL_SHININESS: + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITEF(gCCPriv->buf, BackSpecularExponent, params[0]); + break; + case GL_AMBIENT_AND_DIFFUSE: + CHECK_DMA_BUFFER(gCC, gCCPriv, 7); + WRITEF(gCCPriv->buf, BackAmbientColorBlue, params[2]); + WRITEF(gCCPriv->buf, BackAmbientColorGreen, params[1]); + WRITEF(gCCPriv->buf, BackAmbientColorRed, params[0]); + WRITEF(gCCPriv->buf, BackAlpha, params[3]); + WRITEF(gCCPriv->buf, BackDiffuseColorBlue, params[2]); + WRITEF(gCCPriv->buf, BackDiffuseColorGreen, params[1]); + WRITEF(gCCPriv->buf, BackDiffuseColorRed, params[0]); + break; + case GL_COLOR_INDEXES: + /* NOT_DONE */ + break; + } + } } void _gamma_Materiali(GLenum face, GLenum pname, GLint param) @@ -1837,9 +2442,9 @@ void _gamma_MatrixMode(GLenum mode) switch (mode) { case GL_TEXTURE: - /* Eanble the Texture transform */ + /* Enable the Texture transform */ CHECK_DMA_BUFFER(gCC, gCCPriv, 1); - WRITE(gCCPriv->buf, TransformModeOr, 0x00000010); + WRITE(gCCPriv->buf, TransformModeOr, XM_XformTexture); case GL_MODELVIEW: case GL_PROJECTION: gCCPriv->MatrixMode = mode; @@ -1878,52 +2483,87 @@ void _gamma_NewList(GLuint list, GLenum mode) void _gamma_Normal3b(GLbyte nx, GLbyte ny, GLbyte nz) { + GLfloat x,y,z; + DEBUG_GLCMDS(("Normal3b: %d %d %d\n", nx, ny, nz)); + + _gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz); } void _gamma_Normal3bv(const GLbyte *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Normal3bv: %d %d %d\n", v[0], v[1], v[2])); + + _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); } void _gamma_Normal3d(GLdouble nx, GLdouble ny, GLdouble nz) { DEBUG_GLCMDS(("Normal3d: %f %f %f\n", nx, ny, nz)); + + _gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz); } void _gamma_Normal3dv(const GLdouble *v) { DEBUG_GLCMDS(("Normal3dv: %f %f %f\n", v[0], v[1], v[2])); + + _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); } void _gamma_Normal3f(GLfloat nx, GLfloat ny, GLfloat nz) { DEBUG_GLCMDS(("Normal3f: %f %f %f\n", nx, ny, nz)); + + CHECK_DMA_BUFFER(gCC, gCCPriv, 3); + WRITEF(gCCPriv->buf, Nz, nz); + WRITEF(gCCPriv->buf, Ny, ny); + WRITEF(gCCPriv->buf, Nx, nx); } void _gamma_Normal3fv(const GLfloat *v) { DEBUG_GLCMDS(("Normal3fv: %f %f %f\n", v[0], v[1], v[2])); + + _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); } void _gamma_Normal3i(GLint nx, GLint ny, GLint nz) { + GLfloat x,y,z; + DEBUG_GLCMDS(("Normal3i: %d %d %d\n", (int)nx, (int)ny, (int)nz)); + + _gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz); } void _gamma_Normal3iv(const GLint *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Normal3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2])); + + _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); } void _gamma_Normal3s(GLshort nx, GLshort ny, GLshort nz) { + GLfloat x,y,z; + DEBUG_GLCMDS(("Normal3s: %d %d %d\n", nx, ny, nz)); + + _gamma_Normal3f((GLfloat)nx,(GLfloat)ny,(GLfloat)nz); } void _gamma_Normal3sv(const GLshort *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Normal3sv: %d %d %d\n", v[0], v[1], v[2])); + + _gamma_Normal3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); } void _gamma_NormalPointer(GLenum type, GLsizei stride, const GLvoid *pointer) @@ -2020,6 +2660,56 @@ void _gamma_PointSize(GLfloat size) void _gamma_PolygonMode(GLenum face, GLenum mode) { DEBUG_GLCMDS(("PolygonMode: %04x %04x\n", (int)face, (int)mode)); + + gCCPriv->GeometryMode &= ~GM_FB_PolyMask; + + switch (mode) { + case GL_FILL: + switch (face) { + case GL_FRONT: + gCCPriv->GeometryMode |= GM_FrontPolyFill; + break; + case GL_BACK: + gCCPriv->GeometryMode |= GM_BackPolyFill; + break; + case GL_FRONT_AND_BACK: + gCCPriv->GeometryMode |= GM_FrontPolyFill; + gCCPriv->GeometryMode |= GM_BackPolyFill; + break; + } + break; + case GL_LINE: + switch (face) { + case GL_FRONT: + gCCPriv->GeometryMode |= GM_FrontPolyLine; + break; + case GL_BACK: + gCCPriv->GeometryMode |= GM_BackPolyLine; + break; + case GL_FRONT_AND_BACK: + gCCPriv->GeometryMode |= GM_FrontPolyLine; + gCCPriv->GeometryMode |= GM_BackPolyLine; + break; + } + break; + case GL_POINT: + switch (face) { + case GL_FRONT: + gCCPriv->GeometryMode |= GM_FrontPolyPoint; + break; + case GL_BACK: + gCCPriv->GeometryMode |= GM_BackPolyPoint; + break; + case GL_FRONT_AND_BACK: + gCCPriv->GeometryMode |= GM_FrontPolyPoint; + gCCPriv->GeometryMode |= GM_BackPolyPoint; + break; + } + break; + } + + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, GeometryMode, gCCPriv->GeometryMode); } void _gamma_PolygonOffset(GLfloat factor, GLfloat units) @@ -2272,6 +2962,15 @@ void _gamma_Rectdv(const GLdouble *v1, const GLdouble *v2) void _gamma_Rectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { DEBUG_GLCMDS(("Rectf: %f %f %f %f\n", x1, y1, x2, y2)); + + /* This should be done with Gamma's Rectangle engine - later */ + + _gamma_Begin(GL_POLYGON); + _gamma_Vertex2f(x1,y1); + _gamma_Vertex2f(x2,y1); + _gamma_Vertex2f(x2,y2); + _gamma_Vertex2f(x1,y2); + _gamma_End(); } void _gamma_Rectfv(const GLfloat *v1, const GLfloat *v2) @@ -2474,51 +3173,87 @@ void _gamma_StencilOp(GLenum fail, GLenum zfail, GLenum zpass) void _gamma_TexCoord1d(GLdouble s) { DEBUG_GLCMDS(("TexCoord1d: %f\n", s)); + + _gamma_TexCoord1f((GLfloat)s); } void _gamma_TexCoord1dv(const GLdouble *v) { DEBUG_GLCMDS(("TexCoord1dv: %f\n", *v)); + + _gamma_TexCoord1fv((GLfloat*)v); } void _gamma_TexCoord1f(GLfloat s) { DEBUG_GLCMDS(("TexCoord1f: %f\n", s)); + + WRITEF(gCCPriv->buf, Ts1, s); } void _gamma_TexCoord1fv(const GLfloat *v) { DEBUG_GLCMDS(("TexCoord1fv: %f\n", *v)); + + WRITEF(gCCPriv->buf, Ts1, v[0]); } void _gamma_TexCoord1i(GLint s) { + GLfloat x; + DEBUG_GLCMDS(("TexCoord1i: %d\n", (int)s)); + + x = INT_TO_FLOAT(s); + + _gamma_TexCoord1f(x); } void _gamma_TexCoord1iv(const GLint *v) { + GLfloat p[1]; + DEBUG_GLCMDS(("TexCoord1iv: %d\n", (int)*v)); + + p[0] = INT_TO_FLOAT(v[0]); + + _gamma_TexCoord1fv(p); } void _gamma_TexCoord1s(GLshort s) { + GLfloat x; + DEBUG_GLCMDS(("TexCoord1s: %d\n", s)); + + x = SHORT_TO_FLOAT(s); + + _gamma_TexCoord1f(x); } void _gamma_TexCoord1sv(const GLshort *v) { + GLfloat p[1]; + DEBUG_GLCMDS(("TexCoord1sv: %d\n", *v)); + + p[0] = SHORT_TO_FLOAT(v[0]); + + _gamma_TexCoord1fv(p); } void _gamma_TexCoord2d(GLdouble s, GLdouble t) { DEBUG_GLCMDS(("TexCoord2d: %f %f\n", s, t)); + + _gamma_TexCoord2f((GLfloat)s,(GLfloat)t); } void _gamma_TexCoord2dv(const GLdouble *v) { DEBUG_GLCMDS(("TexCoord2dv: %f %f\n", v[0], v[1])); + + _gamma_TexCoord2fv((GLfloat*)v); } void _gamma_TexCoord2f(GLfloat s, GLfloat t) @@ -2533,107 +3268,240 @@ void _gamma_TexCoord2f(GLfloat s, GLfloat t) void _gamma_TexCoord2fv(const GLfloat *v) { DEBUG_GLCMDS(("TexCoord2fv: %f %f\n", v[0], v[1])); + + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITEF(gCCPriv->buf, Tt2, v[1]); + WRITEF(gCCPriv->buf, Ts2, v[0]); } void _gamma_TexCoord2i(GLint s, GLint t) { + GLfloat x,y; + DEBUG_GLCMDS(("TexCoord2i: %d %d\n", (int)s, (int)t)); + + x = INT_TO_FLOAT(s); + y = INT_TO_FLOAT(t); + + _gamma_TexCoord2f(x,y); } void _gamma_TexCoord2iv(const GLint *v) { + GLfloat p[2]; + DEBUG_GLCMDS(("TexCoord2iv: %d %d\n", (int)v[0], (int)v[1])); + + p[0] = INT_TO_FLOAT(v[0]); + p[1] = INT_TO_FLOAT(v[1]); + + _gamma_TexCoord2fv(p); } void _gamma_TexCoord2s(GLshort s, GLshort t) { + GLfloat x,y; + DEBUG_GLCMDS(("TexCoord2s: %d %d\n", s, t)); + + x = SHORT_TO_FLOAT(s); + y = SHORT_TO_FLOAT(t); + + _gamma_TexCoord2f(x,y); } void _gamma_TexCoord2sv(const GLshort *v) { + GLfloat p[2]; + DEBUG_GLCMDS(("TexCoord2sv: %d %d\n", v[0], v[1])); + + p[0] = SHORT_TO_FLOAT(v[0]); + p[1] = SHORT_TO_FLOAT(v[1]); + + _gamma_TexCoord2fv(p); } void _gamma_TexCoord3d(GLdouble s, GLdouble t, GLdouble r) { DEBUG_GLCMDS(("TexCoord3d: %f %f %f\n", s, t, r)); + + _gamma_TexCoord3f((GLfloat)s,(GLfloat)t,(GLfloat)r); } void _gamma_TexCoord3dv(const GLdouble *v) { DEBUG_GLCMDS(("TexCoord3dv: %f %f %f\n", v[0], v[1], v[2])); + + _gamma_TexCoord3fv((GLfloat*)v); } void _gamma_TexCoord3f(GLfloat s, GLfloat t, GLfloat r) { DEBUG_GLCMDS(("TexCoord3f: %f %f %f\n", s, t, r)); + + _gamma_TexCoord4f(s,t,r,1.0f); } void _gamma_TexCoord3fv(const GLfloat *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("TexCoord3fv: %f %f %f\n", v[0], v[1], v[2])); + + p[0] = v[0]; + p[1] = v[1]; + p[2] = v[2]; + p[3] = 1.0f; + + _gamma_TexCoord4fv(p); } void _gamma_TexCoord3i(GLint s, GLint t, GLint r) { + GLfloat x,y,z; + DEBUG_GLCMDS(("TexCoord3i: %d %d %d\n", (int)s, (int)t, (int)r)); + + x = INT_TO_FLOAT(s); + y = INT_TO_FLOAT(t); + z = INT_TO_FLOAT(r); + + _gamma_TexCoord4f(x,y,z,1.0f); } void _gamma_TexCoord3iv(const GLint *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("TexCoord3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2])); + + p[0] = INT_TO_FLOAT(v[0]); + p[1] = INT_TO_FLOAT(v[1]); + p[2] = INT_TO_FLOAT(v[2]); + p[3] = 1.0f; + + _gamma_TexCoord4fv(p); } void _gamma_TexCoord3s(GLshort s, GLshort t, GLshort r) { + GLfloat x,y,z; + DEBUG_GLCMDS(("TexCoord3s: %d %d %d\n", s, t, r)); + + x = SHORT_TO_FLOAT(s); + y = SHORT_TO_FLOAT(t); + z = SHORT_TO_FLOAT(r); + + _gamma_TexCoord4f(x,y,z,1.0f); } void _gamma_TexCoord3sv(const GLshort *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("TexCoord3sv: %d %d %d\n", v[0], v[1], v[2])); + + p[0] = SHORT_TO_FLOAT(v[0]); + p[1] = SHORT_TO_FLOAT(v[1]); + p[2] = SHORT_TO_FLOAT(v[2]); + p[3] = 1.0f; + + _gamma_TexCoord4fv(p); } void _gamma_TexCoord4d(GLdouble s, GLdouble t, GLdouble r, GLdouble q) { DEBUG_GLCMDS(("TexCoord4d: %f %f %f %f\n", s, t, r, q)); + + _gamma_TexCoord4f((GLfloat)s,(GLfloat)t,(GLfloat)r,(GLfloat)q); } void _gamma_TexCoord4dv(const GLdouble *v) { DEBUG_GLCMDS(("TexCoord4dv: %f %f %f %f\n", v[0], v[1], v[2], v[3])); + + _gamma_TexCoord4fv((GLfloat*)v); } void _gamma_TexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q) { DEBUG_GLCMDS(("TexCoord4f: %f %f %f %f\n", s, t, r, q)); + + CHECK_DMA_BUFFER(gCC, gCCPriv, 4); + WRITEF(gCCPriv->buf, Tq4, q); + WRITEF(gCCPriv->buf, Tr4, r); + WRITEF(gCCPriv->buf, Tt4, t); + WRITEF(gCCPriv->buf, Ts4, s); } void _gamma_TexCoord4fv(const GLfloat *v) { DEBUG_GLCMDS(("TexCoord4fv: %f %f %f %f\n", v[0], v[1], v[2], v[3])); + + CHECK_DMA_BUFFER(gCC, gCCPriv, 4); + WRITEF(gCCPriv->buf, Tq4, v[3]); + WRITEF(gCCPriv->buf, Tr4, v[2]); + WRITEF(gCCPriv->buf, Tt4, v[1]); + WRITEF(gCCPriv->buf, Ts4, v[0]); } void _gamma_TexCoord4i(GLint s, GLint t, GLint r, GLint q) { + GLfloat x,y,z,a; + DEBUG_GLCMDS(("TexCoord4i: %d %d %d %d\n", (int)s, (int)t, (int)r, (int)q)); + + x = INT_TO_FLOAT(s); + y = INT_TO_FLOAT(t); + z = INT_TO_FLOAT(r); + a = INT_TO_FLOAT(q); + + _gamma_TexCoord4f(x,y,z,a); } void _gamma_TexCoord4iv(const GLint *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("TexCoord4iv: %d %d %d %d\n", (int)v[0], (int)v[1], (int)v[2], (int)v[3])); + + p[0] = INT_TO_FLOAT(v[0]); + p[1] = INT_TO_FLOAT(v[1]); + p[2] = INT_TO_FLOAT(v[2]); + p[3] = INT_TO_FLOAT(v[3]); + + _gamma_TexCoord4fv(p); } void _gamma_TexCoord4s(GLshort s, GLshort t, GLshort r, GLshort q) { + GLfloat x,y,z,a; + DEBUG_GLCMDS(("TexCoord4s: %d %d %d %d\n", s, t, r, q)); + + x = SHORT_TO_FLOAT(s); + y = SHORT_TO_FLOAT(t); + z = SHORT_TO_FLOAT(r); + a = SHORT_TO_FLOAT(q); + + _gamma_TexCoord4f(s,t,r,q); } void _gamma_TexCoord4sv(const GLshort *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("TexCoord4sv: %d %d %d %d\n", v[0], v[1], v[2], v[3])); + + p[0] = SHORT_TO_FLOAT(v[0]); + p[1] = SHORT_TO_FLOAT(v[1]); + p[2] = SHORT_TO_FLOAT(v[2]); + p[3] = SHORT_TO_FLOAT(v[3]); + + _gamma_TexCoord4fv(p); } void _gamma_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) @@ -2678,6 +3546,33 @@ void _gamma_TexEnvfv(GLenum target, GLenum pname, const GLfloat *params) { DEBUG_GLCMDS(("TexEnvfv: %04x %04x %f\n", (int)target, (int)pname, *params)); + + if (target != GL_TEXTURE_ENV) { + /* ERROR !! */ + } + + switch (pname) { + case GL_TEXTURE_ENV_MODE: + gCCPriv->curTexObj->TextureColorMode &= ~TCM_ApplicationMask; + switch ((int)params[0]) { + case GL_MODULATE: + gCCPriv->curTexObj->TextureColorMode |= TCM_Modulate; + break; + case GL_DECAL: + gCCPriv->curTexObj->TextureColorMode |= TCM_Decal; + break; + case GL_BLEND: + gCCPriv->curTexObj->TextureColorMode |= TCM_Blend; + break; + case GL_REPLACE: + gCCPriv->curTexObj->TextureColorMode |= TCM_Replace; + break; + } + } + + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, TextureColorMode, + gCCPriv->curTexObj->TextureColorMode); } void _gamma_TexEnvi(GLenum target, GLenum pname, GLint param) @@ -2745,10 +3640,12 @@ void _gamma_TexImage2D(GLenum target, GLint level, GLint components, GLsizei wid if (target == GL_TEXTURE_1D) { /* NOT_DONE */ + DEBUG_ERROR(("TexImage2D: 1D requested - ERROR\n")); } else if (target == GL_TEXTURE_2D) { /* NOT_DONE: The follow are not currently supported... */ - if (border != 0 || format != GL_RGBA || type != GL_UNSIGNED_BYTE || + if (border != 0 /* || format != GL_RGBA */ || type != GL_UNSIGNED_BYTE || (components != 3 && components != 4)) { + DEBUG_ERROR(("TexImage2D: 2D op not supported - ERROR\n")); return; } @@ -2790,7 +3687,11 @@ void _gamma_TexImage2D(GLenum target, GLint level, GLint components, GLsizei wid break; } +#if X_BYTE_ORDER == X_LITTLE_ENDIAN t->TextureFormat = (TF_LittleEndian | +#else + t->TextureFormat = (TF_BigEndian | +#endif TF_ColorOrder_BGR | TF_Compnents_4 | TF_OutputFmt_Texel); @@ -2804,14 +3705,17 @@ void _gamma_TexImage2D(GLenum target, GLint level, GLint components, GLsizei wid t->image[level] = driTMMInsertImage(gCCPriv->tmm, width, height, 1<<l2d, image, NULL); + if (!t->image[level]) { /* NOT_DONE: Handle error */ + DEBUG_ERROR(("TexImage2D: unable1\n")); } /* Make the new image resident (and all of the other mipmaps) */ - if (!driTMMMakeImagesResident(gCCPriv->tmm, MIPMAP_LEVELS, - t->image, addrs)) { + if (driTMMMakeImagesResident(gCCPriv->tmm, MIPMAP_LEVELS, + t->image, addrs) < 0) { /* NOT_DONE: Handle error */ + DEBUG_ERROR(("TexImage2D: unable2\n")); } for (i = 0; i < MIPMAP_LEVELS; i++) @@ -3010,6 +3914,123 @@ void _gamma_TexParameterfv(GLenum target, GLenum pname, const GLfloat *params) { DEBUG_GLCMDS(("TexParameterfv: %04x %04x %f\n", (int)target, (int)pname, *params)); + + if (target == GL_TEXTURE_1D) { + /* NOT_DONE */ + } else if (target == GL_TEXTURE_2D) { + switch (pname) { + case GL_TEXTURE_MAG_FILTER: + gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_Mag_Mask; + switch ((int)params[0]) { + case GL_NEAREST: + gCCPriv->curTexObj2D->TextureReadMode |= + TRM_Mag_Nearest; + break; + case GL_LINEAR: + gCCPriv->curTexObj2D->TextureReadMode |= + TRM_Mag_Linear; + break; + default: + break; + } + + CHECK_DMA_BUFFER(gCC, gCCPriv, 1); + WRITE(gCCPriv->buf, TextureReadMode, + gCCPriv->curTexObj2D->TextureReadMode); + break; + case GL_TEXTURE_MIN_FILTER: + gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_Min_Mask; + gCCPriv->curTexObj2D->TextureReadMode |= TRM_MipMapEnable; + gCCPriv->curTexObj2D->TextureAddressMode |= TAM_LODEnable; + switch ((int)params[0]) { + case GL_NEAREST: + gCCPriv->curTexObj2D->TextureReadMode |= + TRM_Min_Nearest; + gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_MipMapEnable; + gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_LODEnable; + break; + case GL_LINEAR: + gCCPriv->curTexObj2D->TextureReadMode |= + TRM_Min_Linear; + gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_MipMapEnable; + gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_LODEnable; + break; + case GL_NEAREST_MIPMAP_NEAREST: + gCCPriv->curTexObj2D->TextureReadMode |= + TRM_Min_NearestMMNearest; + break; + case GL_LINEAR_MIPMAP_NEAREST: + gCCPriv->curTexObj2D->TextureReadMode |= + TRM_Min_NearestMMLinear; + break; + case GL_NEAREST_MIPMAP_LINEAR: + gCCPriv->curTexObj2D->TextureReadMode |= + TRM_Min_LinearMMNearest; + break; + case GL_LINEAR_MIPMAP_LINEAR: + gCCPriv->curTexObj2D->TextureReadMode |= + TRM_Min_LinearMMLinear; + break; + default: + break; + } + + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, TextureReadMode, + gCCPriv->curTexObj2D->TextureReadMode); + WRITE(gCCPriv->buf, TextureAddressMode, + gCCPriv->curTexObj2D->TextureAddressMode); + break; + case GL_TEXTURE_WRAP_S: + gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_SWrap_Mask; + gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_UWrap_Mask; + switch ((int)params[0]) { + case GL_CLAMP: + gCCPriv->curTexObj2D->TextureAddressMode |= TAM_SWrap_Clamp; + gCCPriv->curTexObj2D->TextureReadMode |= TRM_UWrap_Clamp; + break; + case GL_REPEAT: + gCCPriv->curTexObj2D->TextureAddressMode |= TAM_SWrap_Repeat; + gCCPriv->curTexObj2D->TextureReadMode |= TRM_UWrap_Repeat; + break; + default: + break; + } + + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, TextureReadMode, + gCCPriv->curTexObj2D->TextureReadMode); + WRITE(gCCPriv->buf, TextureAddressMode, + gCCPriv->curTexObj2D->TextureAddressMode); + break; + case GL_TEXTURE_WRAP_T: + gCCPriv->curTexObj2D->TextureAddressMode &= ~TAM_TWrap_Mask; + gCCPriv->curTexObj2D->TextureReadMode &= ~TRM_VWrap_Mask; + switch ((int)params[0]) { + case GL_CLAMP: + gCCPriv->curTexObj2D->TextureAddressMode |= TAM_TWrap_Clamp; + gCCPriv->curTexObj2D->TextureReadMode |= TRM_VWrap_Clamp; + break; + case GL_REPEAT: + gCCPriv->curTexObj2D->TextureAddressMode |= TAM_TWrap_Repeat; + gCCPriv->curTexObj2D->TextureReadMode |= TRM_VWrap_Repeat; + break; + default: + break; + } + + CHECK_DMA_BUFFER(gCC, gCCPriv, 2); + WRITE(gCCPriv->buf, TextureReadMode, + gCCPriv->curTexObj2D->TextureReadMode); + WRITE(gCCPriv->buf, TextureAddressMode, + gCCPriv->curTexObj2D->TextureAddressMode); + break; + default: + break; + } + } else { + /* ERROR !! */ + } } void _gamma_TexParameteri(GLenum target, GLenum pname, GLint param) @@ -3054,8 +4075,8 @@ void _gamma_TexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffs ** format for the image that it is replacing. */ - if (!driTMMSubImage(gCCPriv->tmm, gCCPriv->curTexObj2D->image[level], - xoffset, yoffset, width, height, image)) { + if (driTMMSubImage(gCCPriv->tmm, gCCPriv->curTexObj2D->image[level], + xoffset, yoffset, width, height, image) < 0) { /* NOT_DONE: Handle error */ } } else { @@ -3089,7 +4110,7 @@ void _gamma_Translatef(GLfloat x, GLfloat y, GLfloat z) GLfloat m[16]; int i; - DEBUG_GLCMDS(("Tranlatef: %f %f %f\n", x, y, z)); + DEBUG_GLCMDS(("Translatef: %f %f %f\n", x, y, z)); for (i = 0; i < 16; i++) if (i % 5 == 0) @@ -3108,26 +4129,21 @@ void _gamma_Translatef(GLfloat x, GLfloat y, GLfloat z) void _gamma_Vertex2d(GLdouble x, GLdouble y) { DEBUG_GLCMDS(("Vertex2d: %f %f\n", x, y)); + + _gamma_Vertex2f((GLfloat)x,(GLfloat)y); } void _gamma_Vertex2dv(const GLdouble *v) { DEBUG_GLCMDS(("Vertex2dv: %f %f\n", v[0], v[1])); + + _gamma_Vertex2f((GLfloat)v[0],(GLfloat)v[1]); } void _gamma_Vertex2f(GLfloat x, GLfloat y) { DEBUG_GLCMDS(("Vertex2f: %f %f\n", x, y)); -#ifdef RANDOMIZE_COLORS - { - GLuint c; - c = (random() / (double)RAND_MAX) * 16777216; - CHECK_DMA_BUFFER(gCC, gCCPriv, 1); - WRITE(gCCPriv->buf, PackedColor4, c); - } -#endif - CHECK_DMA_BUFFER(gCC, gCCPriv, 2); WRITEF(gCCPriv->buf, Vy, y); WRITEF(gCCPriv->buf, Vx2, x); @@ -3136,51 +4152,64 @@ void _gamma_Vertex2f(GLfloat x, GLfloat y) void _gamma_Vertex2fv(const GLfloat *v) { DEBUG_GLCMDS(("Vertex2fv: %f %f\n", v[0], v[1])); + + _gamma_Vertex2f(v[0],v[1]); } void _gamma_Vertex2i(GLint x, GLint y) { + GLfloat a,b; + DEBUG_GLCMDS(("Vertex2i: %d %d\n", (int)x, (int)y)); + + _gamma_Vertex2f((GLfloat)x,(GLfloat)y); } void _gamma_Vertex2iv(const GLint *v) { + GLfloat p[2]; + DEBUG_GLCMDS(("Vertex2iv: %d %d\n", (int)v[0], (int)v[1])); + + _gamma_Vertex2f((GLfloat)v[0],(GLfloat)v[1]); } void _gamma_Vertex2s(GLshort x, GLshort y) { + GLfloat a,b; + DEBUG_GLCMDS(("Vertex2s: %d %d\n", x, y)); + + _gamma_Vertex2f((GLfloat)x,(GLfloat)y); } void _gamma_Vertex2sv(const GLshort *v) { + GLfloat p[2]; + DEBUG_GLCMDS(("Vertex2sv: %d %d\n", v[0], v[1])); + + _gamma_Vertex2f((GLfloat)v[0],(GLfloat)v[1]); } void _gamma_Vertex3d(GLdouble x, GLdouble y, GLdouble z) { DEBUG_GLCMDS(("Vertex3d: %f %f %f\n", x, y, z)); + + _gamma_Vertex3f((GLfloat)x,(GLfloat)y,(GLfloat)z); } void _gamma_Vertex3dv(const GLdouble *v) { DEBUG_GLCMDS(("Vertex2fv: %f %f %f\n", v[0], v[1], v[2])); + + _gamma_Vertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); } void _gamma_Vertex3f(GLfloat x, GLfloat y, GLfloat z) { DEBUG_GLCMDS(("Vertex3f: %f %f %f\n", x, y, z)); -#ifdef RANDOMIZE_COLORS - { - GLuint c; - c = (random() / (double)RAND_MAX) * 16777216; - CHECK_DMA_BUFFER(gCC, gCCPriv, 1); - WRITE(gCCPriv->buf, PackedColor4, c); - } -#endif - CHECK_DMA_BUFFER(gCC, gCCPriv, 3); WRITEF(gCCPriv->buf, Vz, z); WRITEF(gCCPriv->buf, Vy, y); @@ -3191,80 +4220,112 @@ void _gamma_Vertex3fv(const GLfloat *v) { DEBUG_GLCMDS(("Vertex3fv: %f %f %f\n", v[0], v[1], v[2])); -#ifdef RANDOMIZE_COLORS - { - GLuint c; - c = (random() / (double)RAND_MAX) * 16777216; - CHECK_DMA_BUFFER(gCC, gCCPriv, 1); - WRITE(gCCPriv->buf, PackedColor4, c); - } -#endif - - CHECK_DMA_BUFFER(gCC, gCCPriv, 3); - WRITEF(gCCPriv->buf, Vz, v[2]); - WRITEF(gCCPriv->buf, Vy, v[1]); - WRITEF(gCCPriv->buf, Vx3, v[0]); + _gamma_Vertex3f(v[0],v[1],v[2]); } void _gamma_Vertex3i(GLint x, GLint y, GLint z) { + GLfloat a,b,c; + DEBUG_GLCMDS(("Vertex3i: %d %d %d\n", (int)x, (int)y, (int)z)); + + _gamma_Vertex3f((GLfloat)x,(GLfloat)y,(GLfloat)z); } void _gamma_Vertex3iv(const GLint *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Vertex3iv: %d %d %d\n", (int)v[0], (int)v[1], (int)v[2])); + + _gamma_Vertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); } void _gamma_Vertex3s(GLshort x, GLshort y, GLshort z) { + GLfloat a,b,c; + DEBUG_GLCMDS(("Vertex3s: %d %d %d\n", x, y, z)); + + _gamma_Vertex3f((GLfloat)x,(GLfloat)y,(GLfloat)z); } void _gamma_Vertex3sv(const GLshort *v) { + GLfloat p[3]; + DEBUG_GLCMDS(("Vertex3sv: %d %d %d\n", v[0], v[1], v[2])); + + _gamma_Vertex3f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2]); } void _gamma_Vertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w) { DEBUG_GLCMDS(("Vertex4d: %f %f %f %f\n", x, y, z, w)); + + _gamma_Vertex4f((GLfloat)x,(GLfloat)y,(GLfloat)z,(GLfloat)w); } void _gamma_Vertex4dv(const GLdouble *v) { DEBUG_GLCMDS(("Vertex4dv: %f %f %f %f\n", v[0], v[1], v[2], v[3])); + + _gamma_Vertex4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]); } void _gamma_Vertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) { DEBUG_GLCMDS(("Vertex4f: %f %f %f %f\n", x, y, z, w)); + + CHECK_DMA_BUFFER(gCC, gCCPriv, 4); + WRITEF(gCCPriv->buf, Vw, w); + WRITEF(gCCPriv->buf, Vz, z); + WRITEF(gCCPriv->buf, Vy, y); + WRITEF(gCCPriv->buf, Vx4, x); } void _gamma_Vertex4fv(const GLfloat *v) { DEBUG_GLCMDS(("Vertex4fv: %f %f %f %f\n", v[0], v[1], v[2], v[3])); + + _gamma_Vertex4f(v[0],v[1],v[2],v[3]); } void _gamma_Vertex4i(GLint x, GLint y, GLint z, GLint w) { + GLfloat a,b,c,d; + DEBUG_GLCMDS(("Vertex4i: %d %d %d %d\n", (int)x, (int)y, (int)z, (int)w)); + + _gamma_Vertex4f((GLfloat)x,(GLfloat)y,(GLfloat)z,(GLfloat)w); } void _gamma_Vertex4iv(const GLint *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("Vertex4iv: %d %d %d %d\n", (int)v[0], (int)v[1], (int)v[2], (int)v[3])); + + _gamma_Vertex4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]); } void _gamma_Vertex4s(GLshort x, GLshort y, GLshort z, GLshort w) { + GLfloat a,b,c,d; + DEBUG_GLCMDS(("Vertex4s: %d %d %d %d\n", x, y, z, w)); + + _gamma_Vertex4f((GLfloat)x,(GLfloat)y,(GLfloat)z,(GLfloat)w); } void _gamma_Vertex4sv(const GLshort *v) { + GLfloat p[4]; + DEBUG_GLCMDS(("Vertex4sv: %d %d %d %d\n", v[0], v[1], v[2], v[3])); + + _gamma_Vertex4f((GLfloat)v[0],(GLfloat)v[1],(GLfloat)v[2],(GLfloat)v[3]); } void _gamma_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) @@ -3280,10 +4341,10 @@ void _gamma_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) DEBUG_GLCMDS(("Viewport: %d %d %d %d\n", (int)x, (int)y, (int)width, (int)height)); - gCCPriv->x = gCC->driContextPriv->driDrawablePriv->x + x; - gCCPriv->y = gCC->driContextPriv->driScreenPriv->fbHeight - - (gCC->driContextPriv->driDrawablePriv->y + - gCC->driContextPriv->driDrawablePriv->h) + y; + gCCPriv->x = gCC->driDrawablePriv->x + x; + gCCPriv->y = gCC->driScreenPriv->fbHeight - + (gCC->driDrawablePriv->y + + gCC->driDrawablePriv->h) + y; gCCPriv->w = width; gCCPriv->h = height; @@ -3296,16 +4357,21 @@ void _gamma_Viewport(GLint x, GLint y, GLsizei width, GLsizei height) oy = y + sy; CHECK_DMA_BUFFER(gCC, gCCPriv, 4); - WRITEF(gCCPriv->buf, ViewPortOffsetX, ox); - WRITEF(gCCPriv->buf, ViewPortOffsetY, oy); WRITEF(gCCPriv->buf, ViewPortScaleX, sx); WRITEF(gCCPriv->buf, ViewPortScaleY, sy); + WRITEF(gCCPriv->buf, ViewPortOffsetX, ox); + WRITEF(gCCPriv->buf, ViewPortOffsetY, oy); +#if 1 /* Err - this shouldn't be needed, but something isn't flushing */ + FLUSH_DMA_BUFFER(gCC,gCCPriv); +#endif } static GLint generic_noop(void) { + DEBUG_GLCMDS(("OOPS GENERIC NOOP CALLED\n")); + return 0; } diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h index ce804d018..e8fd5a0df 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_init.h @@ -43,7 +43,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "gamma_regs.h" #include "gamma_macros.h" #include "gamma_texture.h" -#include "xmesaP.h" typedef struct { int regionCount; /* Count of register regions */ @@ -109,6 +108,12 @@ typedef struct { int AB_FBReadMode; int AB_FBReadMode_Save; int DeltaMode; + int ColorMaterialMode; + int MaterialMode; + int LightingMode; + int Light0Mode; + int Light1Mode; + int ScissorMode; int Window; /* GID part probably should be in draw priv */ gammaTexObj *curTexObj; @@ -140,8 +145,8 @@ extern void gammaLoadHWMatrix(void); extern void gammaInitHW(gammaContextPrivate *gcp); extern float IdentityMatrix[16]; -extern XMesaContext nullCC; -extern XMesaContext gCC; +extern __DRIcontextPrivate *nullCC; +extern __DRIcontextPrivate *gCC; extern gammaContextPrivate *gCCPriv; #endif diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c index edb1d3da0..87d68278b 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_inithw.c @@ -29,27 +29,32 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> + * Alan Hourihane <Alan.Hourihane@btinternet.com> * */ #ifdef GLX_DIRECT_RENDERING #include "gamma_init.h" +#include "glint_dri.h" void gammaInitHW(gammaContextPrivate *gcp) { __DRIscreenPrivate *driScrnPriv = gcp->gammaScrnPriv->driScrnPriv; + GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv; - /* Set up each MX's ScanLineOwnership for OpenGL */ - CHECK_DMA_BUFFER(nullCC, gcp, 4); - WRITE(gcp->buf, BroadcastMask, 1); - WRITE(gcp->buf, ScanLineOwnership, 5); /* Use bottom left as [0,0] */ - WRITE(gcp->buf, BroadcastMask, 2); - WRITE(gcp->buf, ScanLineOwnership, 1); /* Use bottom left as [0,0] */ + if (gDRIPriv->numMXDevices == 2) { + /* Set up each MX's ScanLineOwnership for OpenGL */ + CHECK_DMA_BUFFER(nullCC, gcp, 4); + WRITE(gcp->buf, BroadcastMask, 1); + WRITE(gcp->buf, ScanLineOwnership, 5); /* Use bottom left as [0,0] */ + WRITE(gcp->buf, BroadcastMask, 2); + WRITE(gcp->buf, ScanLineOwnership, 1); /* Use bottom left as [0,0] */ - /* Broadcast to both MX's */ - CHECK_DMA_BUFFER(nullCC, gcp, 1); - WRITE(gcp->buf, BroadcastMask, 3); + /* Broadcast to both MX's */ + CHECK_DMA_BUFFER(nullCC, gcp, 1); + WRITE(gcp->buf, BroadcastMask, 3); + } /* Set MXs to known state */ CHECK_DMA_BUFFER(nullCC, gcp, 27); @@ -82,6 +87,7 @@ void gammaInitHW(gammaContextPrivate *gcp) WRITE(gcp->buf, PixelSize, 0); /* Set Gamma to known state */ + CHECK_DMA_BUFFER(nullCC, gcp, 10); WRITE(gcp->buf, TriangleMode, 0); WRITE(gcp->buf, GeometryMode, 0); WRITE(gcp->buf, NormalizeMode, 0); @@ -136,7 +142,10 @@ void gammaInitHW(gammaContextPrivate *gcp) WRITE(gcp->buf, AlphaTestMode, gcp->AlphaTestMode); WRITE(gcp->buf, AlphaBlendMode, gcp->AlphaBlendMode); WRITE(gcp->buf, DitherMode, DitherModeEnable | DM_ColorOrder_RGB); - WRITE(gcp->buf, RasterizerMode, RM_MultiGLINT | RM_BiasCoordNearHalf); + if (gDRIPriv->numMXDevices == 2) + WRITE(gcp->buf, RasterizerMode, RM_MultiGLINT | RM_BiasCoordNearHalf); + else + WRITE(gcp->buf, RasterizerMode, RM_BiasCoordNearHalf); WRITE(gcp->buf, GLINTWindow, gcp->Window); WRITE(gcp->buf, FastClearDepth, 0xffffffff); WRITE(gcp->buf, GLINTDepth, 0xffffffff); @@ -242,7 +251,7 @@ void gammaInitHW(gammaContextPrivate *gcp) CHECK_DMA_BUFFER(nullCC, gcp, 5); WRITE(gcp->buf, GeometryMode, gcp->GeometryMode); WRITE(gcp->buf, NormalizeMode, NormalizeModeDisable); - WRITE(gcp->buf, LightingMode, LightingModeDisable); + WRITE(gcp->buf, LightingMode, gcp->LightingMode); WRITE(gcp->buf, ColorMaterialMode, ColorMaterialModeDisable); WRITE(gcp->buf, MaterialMode, MaterialModeDisable); @@ -251,18 +260,18 @@ void gammaInitHW(gammaContextPrivate *gcp) WRITE(gcp->buf, BackSpecularExponent, 0); /* fixed point */ CHECK_DMA_BUFFER(nullCC, gcp, 29); - WRITEF(gcp->buf, FrontAmbientColorRed, 0.0); - WRITEF(gcp->buf, FrontAmbientColorGreen, 0.0); - WRITEF(gcp->buf, FrontAmbientColorBlue, 0.0); - WRITEF(gcp->buf, BackAmbientColorRed, 0.0); - WRITEF(gcp->buf, BackAmbientColorGreen, 0.0); - WRITEF(gcp->buf, BackAmbientColorBlue, 0.0); - WRITEF(gcp->buf, FrontDiffuseColorRed, 0.0); - WRITEF(gcp->buf, FrontDiffuseColorGreen, 0.0); - WRITEF(gcp->buf, FrontDiffuseColorBlue, 0.0); - WRITEF(gcp->buf, BackDiffuseColorRed, 0.0); - WRITEF(gcp->buf, BackDiffuseColorGreen, 0.0); - WRITEF(gcp->buf, BackDiffuseColorBlue, 0.0); + WRITEF(gcp->buf, FrontAmbientColorRed, 0.2); + WRITEF(gcp->buf, FrontAmbientColorGreen, 0.2); + WRITEF(gcp->buf, FrontAmbientColorBlue, 0.2); + WRITEF(gcp->buf, BackAmbientColorRed, 0.2); + WRITEF(gcp->buf, BackAmbientColorGreen, 0.2); + WRITEF(gcp->buf, BackAmbientColorBlue, 0.2); + WRITEF(gcp->buf, FrontDiffuseColorRed, 0.8); + WRITEF(gcp->buf, FrontDiffuseColorGreen, 0.8); + WRITEF(gcp->buf, FrontDiffuseColorBlue, 0.8); + WRITEF(gcp->buf, BackDiffuseColorRed, 0.8); + WRITEF(gcp->buf, BackDiffuseColorGreen, 0.8); + WRITEF(gcp->buf, BackDiffuseColorBlue, 0.8); WRITEF(gcp->buf, FrontSpecularColorRed, 0.0); WRITEF(gcp->buf, FrontSpecularColorGreen, 0.0); WRITEF(gcp->buf, FrontSpecularColorBlue, 0.0); @@ -275,11 +284,11 @@ void gammaInitHW(gammaContextPrivate *gcp) WRITEF(gcp->buf, BackEmissiveColorRed, 0.0); WRITEF(gcp->buf, BackEmissiveColorGreen, 0.0); WRITEF(gcp->buf, BackEmissiveColorBlue, 0.0); - WRITEF(gcp->buf, SceneAmbientColorRed, 0.0); - WRITEF(gcp->buf, SceneAmbientColorGreen, 0.0); - WRITEF(gcp->buf, SceneAmbientColorBlue, 0.0); - WRITEF(gcp->buf, FrontAlpha, 0.0); - WRITEF(gcp->buf, BackAlpha, 0.0); + WRITEF(gcp->buf, SceneAmbientColorRed, 0.2); + WRITEF(gcp->buf, SceneAmbientColorGreen, 0.2); + WRITEF(gcp->buf, SceneAmbientColorBlue, 0.2); + WRITEF(gcp->buf, FrontAlpha, 1.0); + WRITEF(gcp->buf, BackAlpha, 1.0); CHECK_DMA_BUFFER(nullCC, gcp, 8); WRITE(gcp->buf, PointMode, (PM_AntialiasDisable | @@ -319,28 +328,28 @@ void gammaInitHW(gammaContextPrivate *gcp) WRITE(gcp->buf, Light14Mode, LNM_Off); WRITE(gcp->buf, Light15Mode, LNM_Off); - CHECK_DMA_BUFFER(nullCC, gcp, 21); - WRITEF(gcp->buf, FrontAmbientColorRed, 1.0); - WRITEF(gcp->buf, FrontAmbientColorGreen, 1.0); - WRITEF(gcp->buf, FrontAmbientColorBlue, 1.0); - WRITEF(gcp->buf, BackAmbientColorRed, 1.0); - WRITEF(gcp->buf, BackAmbientColorGreen, 1.0); - WRITEF(gcp->buf, BackAmbientColorBlue, 1.0); - WRITEF(gcp->buf, FrontDiffuseColorRed, 1.0); - WRITEF(gcp->buf, FrontDiffuseColorGreen, 1.0); - WRITEF(gcp->buf, FrontDiffuseColorBlue, 1.0); - WRITEF(gcp->buf, BackDiffuseColorRed, 1.0); - WRITEF(gcp->buf, BackDiffuseColorGreen, 1.0); - WRITEF(gcp->buf, BackDiffuseColorBlue, 1.0); - WRITEF(gcp->buf, FrontSpecularColorRed, 0.0); - WRITEF(gcp->buf, FrontSpecularColorGreen, 0.0); - WRITEF(gcp->buf, FrontSpecularColorBlue, 0.0); - WRITEF(gcp->buf, BackSpecularColorRed, 0.0); - WRITEF(gcp->buf, BackSpecularColorGreen, 0.0); - WRITEF(gcp->buf, BackSpecularColorBlue, 0.0); - WRITEF(gcp->buf, SceneAmbientColorRed, 0.0); - WRITEF(gcp->buf, SceneAmbientColorGreen, 0.0); - WRITEF(gcp->buf, SceneAmbientColorBlue, 0.0); + CHECK_DMA_BUFFER(nullCC, gcp, 22); + WRITEF(gcp->buf, Light0AmbientIntensityBlue, 0.0); + WRITEF(gcp->buf, Light0AmbientIntensityGreen, 0.0); + WRITEF(gcp->buf, Light0AmbientIntensityRed, 0.0); + WRITEF(gcp->buf, Light0DiffuseIntensityBlue, 1.0); + WRITEF(gcp->buf, Light0DiffuseIntensityGreen, 1.0); + WRITEF(gcp->buf, Light0DiffuseIntensityRed, 1.0); + WRITEF(gcp->buf, Light0SpecularIntensityBlue, 1.0); + WRITEF(gcp->buf, Light0SpecularIntensityGreen, 1.0); + WRITEF(gcp->buf, Light0SpecularIntensityRed, 1.0); + WRITEF(gcp->buf, Light0SpotlightDirectionZ, 0.0); + WRITEF(gcp->buf, Light0SpotlightDirectionY, 0.0); + WRITEF(gcp->buf, Light0SpotlightDirectionX, -1.0); + WRITEF(gcp->buf, Light0SpotlightExponent, 0.0); + WRITEF(gcp->buf, Light0PositionZ, 0.0); + WRITEF(gcp->buf, Light0PositionY, 0.0); + WRITEF(gcp->buf, Light0PositionX, 1.0); + WRITEF(gcp->buf, Light0PositionW, 0.0); + WRITEF(gcp->buf, Light0CosSpotlightCutoffAngle, -1.0); + WRITEF(gcp->buf, Light0ConstantAttenuation, 1.0); + WRITEF(gcp->buf, Light0LinearAttenuation, 0.0); + WRITEF(gcp->buf, Light0QuadraticAttenuation,0.0); CHECK_DMA_BUFFER(nullCC, gcp, 6); WRITEF(gcp->buf, ViewPortScaleX, (gcp->w)/2.0); diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c index f6c166609..17220fbb4 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_matrix.c @@ -163,9 +163,7 @@ void gammaLoadHWMatrix(void) WRITEF(gCCPriv->buf, ModelViewMatrix13, gCCPriv->ModelView[13]); WRITEF(gCCPriv->buf, ModelViewMatrix14, gCCPriv->ModelView[14]); WRITEF(gCCPriv->buf, ModelViewMatrix15, gCCPriv->ModelView[15]); - /* Fall through to load ModelViewProjectionMatrix */ #endif - case GL_PROJECTION: CHECK_DMA_BUFFER(gCC, gCCPriv, 16); WRITEF(gCCPriv->buf, diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h b/xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h index 3dd4b8783..b13dbdba5 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_regs.h @@ -163,6 +163,10 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define FBWriteModeEnable 0x00000001 #define FBW_UploadColorData 0x00000008 +/* FogMode */ +#define FogModeDisable 0x00000000 +#define FogModeEnable 0x00000001 + /* LBWriteMode */ #define LBWriteModeDisable 0x00000000 #define LBWriteModeEnable 0x00000001 @@ -391,14 +395,17 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define GM_FogLinear 0x00000000 #define GM_FogExp 0x00000004 #define GM_FogExpSquared 0x00000008 +#define GM_FogMask 0x0000000C #define GM_FrontPolyPoint 0x00000000 #define GM_FrontPolyLine 0x00000010 #define GM_FrontPolyFill 0x00000020 #define GM_BackPolyPoint 0x00000000 #define GM_BackPolyLine 0x00000040 #define GM_BackPolyFill 0x00000080 +#define GM_FB_PolyMask 0x000000F0 #define GM_FrontFaceCW 0x00000000 #define GM_FrontFaceCCW 0x00000100 +#define GM_FFMask 0x00000100 #define GM_PolyCullDisable 0x00000000 #define GM_PolyCullEnable 0x00000200 #define GM_PolyCullFront 0x00000000 @@ -480,18 +487,44 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* LightingMode */ #define LightingModeDisable 0x00000000 #define LightingModeEnable 0x00000001 +#define LightingModeTwoSides 0x00000002 +#define LightingModeLocalViewer 0x00000008 + +/* Light0Mode */ +#define Light0ModeDisable 0x00000000 +#define Light0ModeEnable 0x00000001 +#define Light0ModeSpotLight 0x00000002 +#define Light0ModeAttenuation 0x00000004 +#define Light0ModeLocal 0x00000008 + +/* Light0Mode */ +#define Light1ModeDisable 0x00000000 +#define Light1ModeEnable 0x00000001 +#define Light1ModeSpotLight 0x00000002 +#define Light1ModeAttenuation 0x00000004 +#define Light1ModeLocal 0x00000008 /* ColorMaterialMode */ #define ColorMaterialModeDisable 0x00000000 #define ColorMaterialModeEnable 0x00000001 +#define ColorMaterialModeFront 0x00000000 +#define ColorMaterialModeBack 0x00000002 +#define ColorMaterialModeFrontAndBack 0x00000004 +#define ColorMaterialModeEmission 0x00000000 +#define ColorMaterialModeAmbient 0x00000008 +#define ColorMaterialModeDiffuse 0x00000010 +#define ColorMaterialModeSpecular 0x00000018 +#define ColorMaterialModeAmbAndDiff 0x00000020 +#define ColorMaterialModeMask 0x0000003e /* MaterialMode */ #define MaterialModeDisable 0x00000000 #define MaterialModeEnable 0x00000001 +#define MaterialModeTwoSides 0x00000080 /* DeltaMode */ #define DM_Target300SX 0x00000000 -#define DM_Target300TXMX 0x00000001 +#define DM_Target500TXMX 0x00000001 #define DM_Depth16 0x00000004 #define DM_Depth24 0x00000008 #define DM_Depth32 0x0000000c diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c index 14a993969..ffa437ed2 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_texture.c @@ -34,6 +34,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef GLX_DIRECT_RENDERING +#include <Xarch.h> #include <X11/Xlibint.h> #include "gamma_init.h" #include <string.h> @@ -74,7 +75,11 @@ void gammaTOInit(gammaTexObj *t) t->TextureFilterMode = (TextureFilterModeDisable); +#if X_BYTE_ORDER == X_LITTLE_ENDIAN t->TextureFormat = (TF_LittleEndian | +#else + t->TextureFormat = (TF_BigEndian | +#endif TF_16Bit_565 | TF_ColorOrder_RGB | TF_Compnents_4 | diff --git a/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c b/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c index 1f968e39b..b199bc073 100644 --- a/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/gamma/gamma_xmesa.c @@ -30,131 +30,123 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * Authors: * Kevin E. Martin <kevin@precisioninsight.com> * Brian Paul <brian@precisioninsight.com> + * Alan Hourihane <Alan.Hourihane@btinternet.com> */ #ifdef GLX_DIRECT_RENDERING #include <X11/Xlibint.h> #include "gamma_init.h" +#include "gamma_gl.h" #include "glapi.h" +#include "glint_dri.h" +#include "context.h" +#include "mmath.h" -XMesaContext nullCC = NULL; -XMesaContext gCC = NULL; +__DRIcontextPrivate *nullCC = NULL; +__DRIcontextPrivate *gCC = NULL; gammaContextPrivate *gCCPriv = NULL; static struct _glapi_table *Dispatch = NULL; -static int count_bits(unsigned int n) -{ - int bits = 0; - - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} -GLboolean XMesaInitDriver(__DRIscreenPrivate *driScrnPriv) +GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) { gammaScreenPrivate *gsp; + /* Check the DRI version */ + { + int major, minor, patch; + if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) { + if (major != 3 || minor != 0 || patch < 0) { + char msg[1000]; + sprintf(msg, "gamma DRI driver expected DRI version 3.0.x but got version %d.%d.%d", major, minor, patch); + __driMesaMessage(msg); + return GL_FALSE; + } + } + } + + /* Check that the DDX driver version is compatible */ + if (sPriv->ddxMajor != 1 || + sPriv->ddxMinor != 0 || + sPriv->ddxPatch < 0) { + char msg[1000]; + sprintf(msg, "gamma DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch); + __driMesaMessage(msg); + return GL_FALSE; + } + + /* Check that the DRM driver version is compatible */ + if (sPriv->drmMajor != 1 || + sPriv->drmMinor != 0 || + sPriv->drmPatch < 0) { + char msg[1000]; + sprintf(msg, "gamm DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); + __driMesaMessage(msg); + return GL_FALSE; + } + /* Allocate the private area */ gsp = (gammaScreenPrivate *)Xmalloc(sizeof(gammaScreenPrivate)); if (!gsp) { return GL_FALSE; } - gsp->driScrnPriv = driScrnPriv; + gsp->driScrnPriv = sPriv; - driScrnPriv->private = (void *)gsp; + sPriv->private = (void *)gsp; - if (!gammaMapAllRegions(driScrnPriv)) { - Xfree(driScrnPriv->private); + if (!gammaMapAllRegions(sPriv)) { + Xfree(sPriv->private); return GL_FALSE; } return GL_TRUE; } -void XMesaResetDriver(__DRIscreenPrivate *driScrnPriv) +void XMesaResetDriver(__DRIscreenPrivate *sPriv) { - gammaUnmapAllRegions(driScrnPriv); - Xfree(driScrnPriv->private); + gammaUnmapAllRegions(sPriv); + Xfree(sPriv->private); + sPriv->private = NULL; } -XMesaVisual XMesaCreateVisual(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_size, - GLint level) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - XMesaVisual v; - - /* Only RGB visuals are supported on the GMX2000 */ - if (!rgb_flag) { - return NULL; - } - - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) { - return NULL; - } - - v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); - if(!v->visinfo) { - Xfree(v); - return NULL; - } - memcpy(v->visinfo, visinfo, sizeof(*visinfo)); - - v->display = display; - v->level = level; - - v->gl_visual = (GLvisual *)Xmalloc(sizeof(GLvisual)); - if (!v->gl_visual) { - Xfree(v->visinfo); - XFree(v); - return NULL; - } - - v->gl_visual->RGBAflag = rgb_flag; - v->gl_visual->DBflag = db_flag; - v->gl_visual->StereoFlag = stereo_flag; - - v->gl_visual->RedBits = count_bits(visinfo->red_mask); - v->gl_visual->GreenBits = count_bits(visinfo->green_mask); - v->gl_visual->BlueBits = count_bits(visinfo->blue_mask); - v->gl_visual->AlphaBits = 0; /* Not currently supported */ - - v->gl_visual->AccumBits = accum_size; - v->gl_visual->DepthBits = depth_size; - v->gl_visual->StencilBits = stencil_size; - - return v; + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual( config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */ ); } -void XMesaDestroyVisual(XMesaVisual v) -{ - Xfree(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); -} -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) +GLboolean XMesaCreateContext( Display *dpy, + GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv ) { int i; - XMesaContext c; gammaContextPrivate *cPriv; __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv; gammaScreenPrivate *gPriv = (gammaScreenPrivate *)driScrnPriv->private; + GLINTDRIPtr gDRIPriv = (GLINTDRIPtr)driScrnPriv->pDevPriv; if (!Dispatch) { GLuint size = _glapi_get_dispatch_table_size() * sizeof(GLvoid *); @@ -162,20 +154,9 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, _gamma_init_dispatch(Dispatch); } - c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); - if (!c) { - return NULL; - } - - c->driContextPriv = driContextPriv; - c->xm_visual = v; - c->xm_buffer = NULL; /* Set by MakeCurrent */ - c->display = v->display; - cPriv = (gammaContextPrivate *)Xmalloc(sizeof(gammaContextPrivate)); if (!cPriv) { - Xfree(c); - return NULL; + return GL_FALSE; } cPriv->hHWContext = driContextPriv->hHWContext; @@ -216,27 +197,26 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, cPriv->ModelViewProj[i] = cPriv->Texture[i] = 0.0; - /* - ** NOT_DONE: The 0xe4 in LBReadMode and FBReadMode refers to the - ** partial products for the 640x480 mode. We will need to look up - ** the partial products in a table (c.f., glint_driver.c) to support - ** other FB sizes. - */ cPriv->LBReadMode = (LBReadSrcDisable | LBReadDstDisable | LBDataTypeDefault | LBWindowOriginBot | - LBScanLineInt2 | - 0xe4); /* NOT_DONE: 640x480 partial products */ + gDRIPriv->pprod); cPriv->FBReadMode = (FBReadSrcDisable | FBReadDstDisable | FBDataTypeDefault | FBWindowOriginBot | - FBScanLineInt2 | - 0xe4); /* NOT_DONE: 640x480 partial products */ - - cPriv->FBWindowBase = driScrnPriv->fbWidth * (driScrnPriv->fbHeight/2 - 1); - cPriv->LBWindowBase = driScrnPriv->fbWidth * (driScrnPriv->fbHeight/2 - 1); + gDRIPriv->pprod); + + if (gDRIPriv->numMXDevices == 2) { + cPriv->LBReadMode |= LBScanLineInt2; + cPriv->FBReadMode |= FBScanLineInt2; + cPriv->FBWindowBase =driScrnPriv->fbWidth*(driScrnPriv->fbHeight/2 - 1); + cPriv->LBWindowBase =driScrnPriv->fbWidth*(driScrnPriv->fbHeight/2 - 1); + } else { + cPriv->FBWindowBase = driScrnPriv->fbWidth * driScrnPriv->fbHeight; + cPriv->LBWindowBase = driScrnPriv->fbWidth * driScrnPriv->fbHeight; + } cPriv->Begin = (B_AreaStippleDisable | B_LineStippleDisable | @@ -328,7 +308,7 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, 4, 1, gammaTOLoad, gammaTOLoadSub); - + cPriv->curTexObj = gammaTOFind(0); cPriv->curTexObj1D = cPriv->curTexObj; cPriv->curTexObj2D = cPriv->curTexObj; @@ -338,17 +318,17 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, #ifdef FORCE_DEPTH32 cPriv->DepthSize = 32; #else - cPriv->DepthSize = v->gl_visual->DepthBits; + cPriv->DepthSize = mesaVis->DepthBits; #endif cPriv->zNear = 0.0; cPriv->zFar = 1.0; cPriv->Flags = GAMMA_FRONT_BUFFER; - cPriv->Flags |= (v->gl_visual->DBflag ? GAMMA_BACK_BUFFER : 0); + cPriv->Flags |= (mesaVis->DBflag ? GAMMA_BACK_BUFFER : 0); cPriv->Flags |= (cPriv->DepthSize > 0 ? GAMMA_DEPTH_BUFFER : 0); cPriv->EnabledFlags = GAMMA_FRONT_BUFFER; - cPriv->EnabledFlags |= (v->gl_visual->DBflag ? GAMMA_BACK_BUFFER : 0); + cPriv->EnabledFlags |= (mesaVis->DBflag ? GAMMA_BACK_BUFFER : 0); cPriv->DepthMode = (DepthModeDisable | DM_WriteMask | @@ -356,7 +336,7 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, cPriv->DeltaMode = (DM_SubPixlCorrectionEnable | DM_SmoothShadingEnable | - DM_Target300TXMX); + DM_Target500TXMX); switch (cPriv->DepthSize) { case 16: @@ -374,36 +354,68 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, cPriv->gammaScrnPriv = gPriv; - c->private = (void *)cPriv; + cPriv->LightingMode = LightingModeDisable; + cPriv->Light0Mode = LNM_Off; + cPriv->Light1Mode = LNM_Off; + + cPriv->MaterialMode = MaterialModeDisable; + + cPriv->ScissorMode = UserScissorDisable | ScreenScissorDisable; + + driContextPriv->driverPrivate = cPriv; /* Initialize the HW to a known state */ gammaInitHW(cPriv); - return c; + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { + gammaContextPrivate *cPriv; + cPriv = (gammaContextPrivate *) driContextPriv->driverPrivate; + if (cPriv) { + /* XXX free driver context data? */ + } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, - __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); } -void XMesaDestroyBuffer(XMesaBuffer b) + +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer b) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { /* ** NOT_DONE: This assumes buffer is currently bound to a context. @@ -420,11 +432,9 @@ void XMesaSwapBuffers(XMesaBuffer b) if (gCCPriv->EnabledFlags & GAMMA_BACK_BUFFER) { int src, dst, x0, y0, x1, h; int i; - __DRIdrawablePrivate *driDrawPriv = - gCC->driContextPriv->driDrawablePriv; int nRect = driDrawPriv->numClipRects; XF86DRIClipRectPtr pRect = driDrawPriv->pClipRects; - __DRIscreenPrivate *driScrnPriv = gCC->driContextPriv->driScreenPriv; + __DRIscreenPrivate *driScrnPriv = gCC->driScreenPriv; #ifdef DO_VALIDATE DRM_SPINLOCK(&driScrnPriv->pSAREA->drawable_lock, @@ -487,19 +497,23 @@ void XMesaSwapBuffers(XMesaBuffer b) } } -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) { - if (c) { - gCC = c; - gCCPriv = (gammaContextPrivate *)c->private; + if (driContextPriv) { + gCC = driContextPriv; + gCCPriv = (gammaContextPrivate *) driContextPriv->driverPrivate; gCCPriv->Window &= ~W_GIDMask; - gCCPriv->Window |= (gCC->driContextPriv->driDrawablePriv->index << 5); + gCCPriv->Window |= (driDrawPriv->index << 5); CHECK_DMA_BUFFER(gCC, gCCPriv, 1); WRITE(gCCPriv->buf, GLINTWindow, gCCPriv->Window); _glapi_set_dispatch(Dispatch); + + _gamma_Viewport(0, 0, driDrawPriv->w, driDrawPriv->h); } else { gCC = NULL; gCCPriv = NULL; @@ -508,7 +522,7 @@ GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) } -GLboolean XMesaUnbindContext( XMesaContext c ) +GLboolean XMesaUnbindContext( __DRIcontextPrivate *driContextPriv ) { /* XXX not 100% sure what's supposed to be done here */ return GL_TRUE; diff --git a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c index 50b7e0689..e5d95583b 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810_xmesa.c @@ -46,10 +46,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "i810state.h" #include "i810tex.h" #include "i810span.h" -#include "i810depth.h" #include "i810tris.h" -#include "i810swap.h" #include "i810pipeline.h" +#include "i810ioctl.h" #include "i810_dri.h" @@ -57,36 +56,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef I810_DEBUG int I810_DEBUG = (0 - | DEBUG_ALWAYS_SYNC - | DEBUG_VERBOSE_RING - | DEBUG_VERBOSE_OUTREG +/* | DEBUG_ALWAYS_SYNC */ +/* | DEBUG_VERBOSE_RING */ +/* | DEBUG_VERBOSE_OUTREG */ /* | DEBUG_VERBOSE_MSG */ /* | DEBUG_NO_OUTRING */ /* | DEBUG_NO_OUTREG */ /* | DEBUG_VERBOSE_API */ /* | DEBUG_VERBOSE_2D */ /* | DEBUG_VERBOSE_DRI */ - | DEBUG_VALIDATE_RING +/* | DEBUG_VALIDATE_RING */ +/* | DEBUG_VERBOSE_IOCTL */ ); #endif static i810ContextPtr i810Ctx = 0; -i810Glx_t i810glx; -static int count_bits(unsigned int n) -{ - int bits = 0; - - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} - -/* These functions are accessed by dlsym from dri_mesa_init.c: +/* These functions are accessed externally to the driver: * * XMesaInitDriver * XMesaResetDriver @@ -100,28 +88,74 @@ static int count_bits(unsigned int n) * XMesaSwapBuffers * XMesaMakeCurrent * - * So this is kind of the public interface to the driver. The driver - * uses the X11 mesa driver context as a kind of wrapper around its - * own driver context - but there isn't much justificiation for doing - * it that way - the DRI might as well use a (void *) to refer to the - * driver contexts. Nothing in the X context really gets used. */ +static drmBufMapPtr i810_create_empty_buffers(void) +{ + drmBufMapPtr retval; + + retval = (drmBufMapPtr)Xmalloc(sizeof(drmBufMap)); + if(retval == NULL) return NULL; + memset(retval, 0, sizeof(drmBufMap)); + retval->list = (drmBufPtr)Xmalloc(sizeof(drmBuf) * I810_DMA_BUF_NR); + if(retval->list == NULL) { + Xfree(retval); + return NULL; + } + memset(retval->list, 0, sizeof(drmBuf) * I810_DMA_BUF_NR); + /* + fprintf(stderr, "retval : %p, retval->list : %p\n", retval, retval->list); + */ + return retval; +} + GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) { i810ScreenPrivate *i810Screen; I810DRIPtr gDRIPriv = (I810DRIPtr)sPriv->pDevPriv; + /* Check the DRI version */ + { + int major, minor, patch; + if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) { + if (major != 3 || minor != 0 || patch < 0) { + char msg[1000]; + sprintf(msg, "i810 DRI driver expected DRI version 3.0.x but got version %d.%d.%d", major, minor, patch); + __driMesaMessage(msg); + return GL_FALSE; + } + } + } + + /* Check that the DDX driver version is compatible */ + if (sPriv->ddxMajor != 1 || + sPriv->ddxMinor != 0 || + sPriv->ddxPatch < 0) { + char msg[1000]; + sprintf(msg, "i810 DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch); + __driMesaMessage(msg); + return GL_FALSE; + } + + /* Check that the DRM driver version is compatible */ + if (sPriv->drmMajor != 1 || + sPriv->drmMinor != 0 || + sPriv->drmPatch < 0) { + char msg[1000]; + sprintf(msg, "i810 DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); + __driMesaMessage(msg); + return GL_FALSE; + } + /* Allocate the private area */ i810Screen = (i810ScreenPrivate *)Xmalloc(sizeof(i810ScreenPrivate)); - if (!i810Screen) return GL_FALSE; + if (!i810Screen) + return GL_FALSE; i810Screen->driScrnPriv = sPriv; sPriv->private = (void *)i810Screen; - i810Screen->regs.handle=gDRIPriv->regs; - i810Screen->regs.size=gDRIPriv->regsSize; i810Screen->deviceID=gDRIPriv->deviceID; i810Screen->width=gDRIPriv->width; i810Screen->height=gDRIPriv->height; @@ -137,39 +171,66 @@ GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) i810Screen->backOffset=gDRIPriv->backOffset; i810Screen->depthOffset=gDRIPriv->depthOffset; - i810Screen->auxPitch = gDRIPriv->auxPitch; - i810Screen->auxPitchBits = gDRIPriv->auxPitchBits; + i810Screen->backPitch = gDRIPriv->auxPitch; + i810Screen->backPitchBits = gDRIPriv->auxPitchBits; i810Screen->textureOffset=gDRIPriv->textureOffset; i810Screen->textureSize=gDRIPriv->textureSize; i810Screen->logTextureGranularity = gDRIPriv->logTextureGranularity; - if (0) fprintf(stderr, "Tex heap size %x, granularity %x bytes\n", i810Screen->textureSize, 1<<(i810Screen->logTextureGranularity)); + + i810Screen->bufs = i810_create_empty_buffers(); + if(i810Screen->bufs == NULL) + { + Xfree(i810Screen); + return GL_FALSE; + } + i810Screen->back.handle = gDRIPriv->backbuffer; + i810Screen->back.size = gDRIPriv->backbufferSize; + if (drmMap(sPriv->fd, - i810Screen->regs.handle, - i810Screen->regs.size, - &i810Screen->regs.map) != 0) + i810Screen->back.handle, + i810Screen->back.size, + (drmAddress *)&i810Screen->back.map) != 0) { Xfree(i810Screen); + sPriv->private = NULL; return GL_FALSE; } - /* Ditch i810glx in favor of i810Screen? - */ - memset(&i810glx, 0, sizeof(i810glx)); + i810Screen->depth.handle = gDRIPriv->depthbuffer; + i810Screen->depth.size = gDRIPriv->depthbufferSize; + + if (drmMap(sPriv->fd, + i810Screen->depth.handle, + i810Screen->depth.size, + (drmAddress *)&i810Screen->depth.map) != 0) + { + Xfree(i810Screen); + drmUnmap(i810Screen->back.map, i810Screen->back.size); + sPriv->private = NULL; + return GL_FALSE; + } + + i810Screen->tex.handle = gDRIPriv->textures; + i810Screen->tex.size = gDRIPriv->textureSize; + + if (drmMap(sPriv->fd, + i810Screen->tex.handle, + i810Screen->tex.size, + (drmAddress *)&i810Screen->tex.map) != 0) + { + Xfree(i810Screen); + drmUnmap(i810Screen->back.map, i810Screen->back.size); + drmUnmap(i810Screen->depth.map, i810Screen->depth.size); + sPriv->private = NULL; + return GL_FALSE; + } - i810glx.LpRing.mem.Start = gDRIPriv->ringOffset; - i810glx.LpRing.mem.Size = gDRIPriv->ringSize; - i810glx.LpRing.mem.End = gDRIPriv->ringOffset + gDRIPriv->ringSize; - i810glx.LpRing.virtual_start = sPriv->pFB + i810glx.LpRing.mem.Start; - i810glx.LpRing.tail_mask = i810glx.LpRing.mem.Size - 1; - i810glx.MMIOBase = i810Screen->regs.map; - i810glx.texVirtual = sPriv->pFB + i810Screen->textureOffset; - i810DDFastPathInit(); i810DDTrifuncInit(); i810DDSetupInit(); @@ -183,111 +244,78 @@ void XMesaResetDriver(__DRIscreenPrivate *sPriv) { i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private; - drmUnmap(i810Screen->regs.map, i810Screen->regs.size); + /* Need to unmap all the bufs and maps here: + */ + drmUnmap(i810Screen->back.map, i810Screen->back.size); + drmUnmap(i810Screen->depth.map, i810Screen->depth.size); + drmUnmap(i810Screen->tex.map, i810Screen->tex.size); + Xfree(i810Screen); + sPriv->private = NULL; } -/* Accessed by dlsym from dri_mesa_init.c - */ -XMesaVisual XMesaCreateVisual(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_size, - GLint level) -{ - XMesaVisual v; - - /* Only RGB visuals are supported on the I810 boards */ - if (!rgb_flag) return 0; - - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) return 0; - - v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); - if(!v->visinfo) { - Xfree(v); - return 0; - } - memcpy(v->visinfo, visinfo, sizeof(*visinfo)); - - v->display = display; - v->level = level; - - v->gl_visual = (GLvisual *)Xmalloc(sizeof(GLvisual)); - if (!v->gl_visual) { - Xfree(v->visinfo); - XFree(v); - return 0; - } - - v->gl_visual->RGBAflag = rgb_flag; - v->gl_visual->DBflag = db_flag; - v->gl_visual->StereoFlag = stereo_flag; - v->gl_visual->RedBits = count_bits(visinfo->red_mask); - v->gl_visual->GreenBits = count_bits(visinfo->green_mask); - v->gl_visual->BlueBits = count_bits(visinfo->blue_mask); - v->gl_visual->AlphaBits = 0; /* Not currently supported */ - - v->gl_visual->AccumBits = accum_size; - v->gl_visual->DepthBits = depth_size; - v->gl_visual->StencilBits = stencil_size; - - return v; -} - -void XMesaDestroyVisual(XMesaVisual v) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - Xfree(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual( config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */ ); } -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) + +GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv ) { - GLcontext *ctx; - XMesaContext c; + GLcontext *ctx = driContextPriv->mesaContext; i810ContextPtr imesa; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; i810ScreenPrivate *i810Screen = (i810ScreenPrivate *)sPriv->private; - I810SAREAPriv *saPriv=(I810SAREAPriv*)(((char*)sPriv->pSAREA)+ - sizeof(XF86DRISAREARec)); - - GLcontext *shareCtx = 0; + drm_i810_sarea_t *saPriv=(drm_i810_sarea_t *)(((char*)sPriv->pSAREA)+ + sizeof(XF86DRISAREARec)); - c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); - if (!c) { - return 0; - } - - imesa = (i810ContextPtr)Xmalloc(sizeof(i810Context)); + imesa = (i810ContextPtr)Xcalloc(sizeof(i810Context), 1); if (!imesa) { - Xfree(c); - return 0; + return GL_FALSE; } - c->driContextPriv = driContextPriv; - c->xm_visual = v; - c->xm_buffer = 0; /* Set by MakeCurrent */ - c->display = v->display; - c->private = (void *)imesa; - if (share_list) - shareCtx=((i810ContextPtr)(share_list->private))->glCtx; + /* Set the maximum texture size small enough that we can guarentee + * that both texture units can bind a maximal texture and have them + * in memory at once. + */ + if (i810Screen->textureSize < 2*1024*1024) { + ctx->Const.MaxTextureLevels = 9; + ctx->Const.MaxTextureSize = 1<<8; + } else if (i810Screen->textureSize < 8*1024*1024) { + ctx->Const.MaxTextureLevels = 10; + ctx->Const.MaxTextureSize = 1<<9; + } else { + ctx->Const.MaxTextureLevels = 11; + ctx->Const.MaxTextureSize = 1<<10; + } - ctx = imesa->glCtx = gl_create_context(v->gl_visual, shareCtx, - (void*)imesa, GL_TRUE); /* Dri stuff */ - imesa->display = v->display; + imesa->display = dpy; imesa->hHWContext = driContextPriv->hHWContext; imesa->driFd = sPriv->fd; imesa->driHwLock = &sPriv->pSAREA->lock; @@ -295,10 +323,7 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, imesa->i810Screen = i810Screen; imesa->driScreen = sPriv; imesa->sarea = saPriv; - - imesa->glBuffer = gl_create_framebuffer(v->gl_visual); - - imesa->needClip=1; + imesa->glBuffer = NULL; imesa->texHeap = mmInit( 0, i810Screen->textureSize ); @@ -315,17 +340,21 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, imesa->TextureMode = ctx->Texture.Unit[0].EnvMode; imesa->CurrentTexObj[0] = 0; imesa->CurrentTexObj[1] = 0; + + ctx->DriverCtx = (void *) imesa; + imesa->glCtx = ctx; i810DDExtensionsInit( ctx ); i810DDInitStateFuncs( ctx ); i810DDInitTextureFuncs( ctx ); i810DDInitSpanFuncs( ctx ); - i810DDInitDepthFuncs( ctx ); i810DDInitDriverFuncs( ctx ); + i810DDInitIoctlFuncs( ctx ); ctx->Driver.TriangleCaps = (DD_TRI_CULL| DD_TRI_LIGHT_TWOSIDE| + DD_TRI_STIPPLE| DD_TRI_OFFSET); /* Ask mesa to clip fog coordinates for us. @@ -346,18 +375,19 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, i810DDInitState( imesa ); - return c; + driContextPriv->driverPrivate = (void *) imesa; + + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { - i810ContextPtr imesa = (i810ContextPtr) c->private; + i810ContextPtr imesa = (i810ContextPtr) driContextPriv->driverPrivate; if (imesa) { i810TextureObjectPtr next_t, t; gl_destroy_context(imesa->glCtx); - gl_destroy_framebuffer(imesa->glBuffer); foreach_s (t, next_t, &(imesa->TexObjList)) i810DestroyTexObj(imesa, t); @@ -366,58 +396,53 @@ void XMesaDestroyContext(XMesaContext c) i810DestroyTexObj(imesa, t); Xfree(imesa); - - c->private = 0; } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); } -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -void XMesaDestroyBuffer(XMesaBuffer b) +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer bogus) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { + /* XXX should do swap according to the buffer, not the context! */ i810ContextPtr imesa = i810Ctx; FLUSH_VB( imesa->glCtx, "swap buffers" ); i810SwapBuffers(imesa); } -static void i810InitClipRects( i810ContextPtr imesa ) -{ - switch (imesa->numClipRects) { - case 0: - imesa->ClipSetup[I810_CLIPREG_SC] = ( GFX_OP_SCISSOR | - SC_UPDATE_SCISSOR ); - imesa->ClipSetup[I810_CLIPREG_SCI1] = 0; - imesa->ClipSetup[I810_CLIPREG_SCI2] = 0; - imesa->needClip = 0; - imesa->dirty |= I810_EMIT_CLIPRECT; - break; - case 1: - imesa->needClip = 0; - i810EmitScissorValues( imesa, 0, 0 ); - imesa->dirty |= I810_EMIT_CLIPRECT; - break; - default: - imesa->needClip=1; - break; - } -} - void i810XMesaSetFrontClipRects( i810ContextPtr imesa ) @@ -426,12 +451,12 @@ void i810XMesaSetFrontClipRects( i810ContextPtr imesa ) imesa->numClipRects = dPriv->numClipRects; imesa->pClipRects = dPriv->pClipRects; + imesa->dirty |= I810_UPLOAD_CLIPRECTS; imesa->drawX = dPriv->x; imesa->drawY = dPriv->y; - imesa->drawOffset = imesa->i810Screen->fbOffset; + imesa->drawMap = imesa->driScreen->pFB; i810EmitDrawingRectangle( imesa ); - i810InitClipRects( imesa ); } @@ -440,7 +465,7 @@ void i810XMesaSetBackClipRects( i810ContextPtr imesa ) __DRIdrawablePrivate *dPriv = imesa->driDrawable; int i; - if (dPriv->numAuxClipRects == 0) + if (dPriv->numBackClipRects == 0) { if (I810_DEBUG & DEBUG_VERBOSE_DRI) fprintf(stderr, "FRONT_CLIPRECTS, %d rects\n", @@ -452,18 +477,18 @@ void i810XMesaSetBackClipRects( i810ContextPtr imesa ) imesa->drawY = dPriv->y; } else { if (I810_DEBUG & DEBUG_VERBOSE_DRI) - fprintf(stderr, "AUX_RECTS, %d rects\n", - dPriv->numAuxClipRects); + fprintf(stderr, "BACK_RECTS, %d rects\n", + dPriv->numBackClipRects); - imesa->numClipRects = dPriv->numAuxClipRects; - imesa->pClipRects = dPriv->pAuxClipRects; - imesa->drawX = dPriv->auxX; - imesa->drawY = dPriv->auxY; + imesa->numClipRects = dPriv->numBackClipRects; + imesa->pClipRects = dPriv->pBackClipRects; + imesa->drawX = dPriv->backX; + imesa->drawY = dPriv->backY; } - imesa->drawOffset = imesa->i810Screen->backOffset; + imesa->drawMap = imesa->i810Screen->back.map; i810EmitDrawingRectangle( imesa ); - i810InitClipRects( imesa ); + imesa->dirty |= I810_UPLOAD_CLIPRECTS; if (I810_DEBUG & DEBUG_VERBOSE_DRI) for (i = 0 ; i < imesa->numClipRects ; i++) @@ -478,6 +503,9 @@ void i810XMesaSetBackClipRects( i810ContextPtr imesa ) static void i810XMesaWindowMoved( i810ContextPtr imesa ) { + if (0) + fprintf(stderr, "i810XMesaWindowMoved\n\n"); + switch (imesa->glCtx->Color.DriverDrawBuffer) { case GL_FRONT_LEFT: i810XMesaSetFrontClipRects( imesa ); @@ -486,38 +514,43 @@ static void i810XMesaWindowMoved( i810ContextPtr imesa ) i810XMesaSetBackClipRects( imesa ); break; default: - fprintf(stderr, "fallback buffer\n"); + /*fprintf(stderr, "fallback buffer\n");*/ break; } - } -/* This looks buggy to me - the 'b' variable isn't used anywhere... - * Hmm - It seems that the drawable is already hooked in to - * driDrawablePriv. - */ -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) { + i810ContextPtr i810 = (i810ContextPtr) driContextPriv->driverPrivate; + if (i810) + i810->dirty = ~0; - if (c->private==(void *)i810Ctx) return GL_TRUE; - - if (c) { - __DRIdrawablePrivate *dPriv = c->driContextPriv->driDrawablePriv; - - i810Ctx = (i810ContextPtr)c->private; + return GL_TRUE; +} - gl_make_current(i810Ctx->glCtx, i810Ctx->glBuffer); - i810Ctx->driDrawable = dPriv; +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) +{ + if (driContextPriv) { + i810Ctx = (i810ContextPtr) driContextPriv->driverPrivate; + + gl_make_current2(i810Ctx->glCtx, driDrawPriv->mesaBuffer, + driReadPriv->mesaBuffer); + + + i810Ctx->driDrawable = driDrawPriv; i810Ctx->dirty = ~0; - + i810XMesaWindowMoved( i810Ctx ); - + if (!i810Ctx->glCtx->Viewport.Width) - gl_Viewport(i810Ctx->glCtx, 0, 0, dPriv->w, dPriv->h); - - } else { + gl_Viewport(i810Ctx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); + } + else + { gl_make_current(0,0); i810Ctx = NULL; } @@ -525,15 +558,26 @@ GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) } -void i810XMesaUpdateState( i810ContextPtr imesa ) +void i810GetLock( i810ContextPtr imesa, GLuint flags ) { __DRIdrawablePrivate *dPriv = imesa->driDrawable; __DRIscreenPrivate *sPriv = imesa->driScreen; - I810SAREAPriv *sarea = imesa->sarea; + drm_i810_sarea_t *sarea = imesa->sarea; int me = imesa->hHWContext; int stamp = dPriv->lastStamp; + if (0) fprintf(stderr, ".\n"); + + /* We know there has been contention. + */ + drmGetLock(imesa->driFd, imesa->hHWContext, flags); + + + /* Note contention for throttling hint + */ + imesa->any_contend = 1; + /* If the window moved, may need to set a new cliprect now. * * NOTE: This releases and regains the hw lock, so all state @@ -541,26 +585,24 @@ void i810XMesaUpdateState( i810ContextPtr imesa ) */ XMESA_VALIDATE_DRAWABLE_INFO(imesa->display, sPriv, dPriv); - i810glx.LpRing.synced = 0; - /* If another client has touched the ringbuffer, need to update - * where we think the pointers are: - */ - if (sarea->ringOwner != me) { - i810glx.c_ringlost++; - imesa->dirty |= I810_REFRESH_RING; - } - + if (0) + fprintf(stderr, "i810GetLock, last enque: %d last dispatch: %d\n", + sarea->last_enqueue, + sarea->last_dispatch); + /* If we lost context, need to dump all registers to hardware. * Note that we don't care about 2d contexts, even if they perform * accelerated commands, so the DRI locking in the X server is even * more broken than usual. */ if (sarea->ctxOwner != me) { - i810glx.c_ctxlost++; - imesa->dirty |= I810_UPLOAD_CTX; - imesa->dirty |= I810_EMIT_CLIPRECT; - imesa->dirty |= I810_UPLOAD_BUFFERS; + imesa->dirty |= (I810_UPLOAD_CTX | + I810_UPLOAD_CLIPRECTS | + I810_UPLOAD_BUFFERS | + I810_UPLOAD_TEX0 | + I810_UPLOAD_TEX1); + sarea->ctxOwner = me; } /* Shared texture managment - if another client has played with @@ -587,23 +629,18 @@ void i810XMesaUpdateState( i810ContextPtr imesa ) i810ResetGlobalLRU( imesa ); } + if (0) fprintf(stderr, "imesa %d sarea %d\n", imesa->texAge, sarea->texAge); + imesa->dirty |= I810_UPLOAD_TEX0IMAGE; + imesa->dirty |= I810_UPLOAD_TEX1IMAGE; imesa->texAge = sarea->texAge; - imesa->dirty |= I810_UPLOAD_TEX0IMAGE | I810_UPLOAD_TEX1IMAGE; } if (dPriv->lastStamp != stamp) i810XMesaWindowMoved( imesa ); - sarea->ctxOwner=me; - sarea->ringOwner=me; - - - _I810RefreshLpRing(imesa, 0); - - if (imesa->dirty) - i810EmitHwStateLocked( imesa ); - + + sarea->last_quiescent = -1; /* just kill it for now */ } diff --git a/xc/lib/GL/mesa/src/drv/i810/i810dd.c b/xc/lib/GL/mesa/src/drv/i810/i810dd.c index 17436bf0d..583eb630c 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810dd.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810dd.c @@ -29,10 +29,7 @@ #include <stdio.h> #include "mm.h" -#include "i810lib.h" -#include "i810clear.h" #include "i810dd.h" -#include "i810depth.h" #include "i810log.h" #include "i810state.h" #include "i810span.h" @@ -59,7 +56,7 @@ static const GLubyte *i810DDGetString( GLcontext *ctx, GLenum name ) case GL_VENDOR: return "Keith Whitwell, Precision Insight Inc."; case GL_RENDERER: - return "DRI-I810"; + return "Mesa DRI I810 20000510"; default: return 0; } @@ -100,10 +97,13 @@ void i810DDExtensionsInit( GLcontext *ctx ) /* The imaging subset of 1.2 isn't supported by any mesa driver. */ gl_extensions_disable( ctx, "ARB_imaging" ); + gl_extensions_disable( ctx, "GL_EXT_blend_color" ); gl_extensions_disable( ctx, "GL_EXT_blend_minmax" ); gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" ); gl_extensions_disable( ctx, "GL_EXT_blend_subtract" ); gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" ); + gl_extensions_disable( ctx, "GL_EXT_texture_lod_bias" ); + gl_extensions_disable( ctx, "GL_MESA_resize_buffers" ); if (0) gl_extensions_disable( ctx, "GL_ARB_multitexture" ); @@ -115,18 +115,6 @@ void i810DDExtensionsInit( GLcontext *ctx ) } -static void i810DDFlush( GLcontext *ctx ) -{ - i810DmaFlush( I810_CONTEXT(ctx) ); -} - -static void i810DDFinish( GLcontext *ctx ) -{ - i810ContextPtr imesa = I810_CONTEXT(ctx); - LOCK_HARDWARE( imesa ); - i810DmaFinish( imesa ); - UNLOCK_HARDWARE( imesa ); -} void i810DDInitDriverFuncs( GLcontext *ctx ) @@ -139,8 +127,5 @@ void i810DDInitDriverFuncs( GLcontext *ctx ) ctx->Driver.Clear = i810Clear; - ctx->Driver.Flush = i810DDFlush; - ctx->Driver.Finish = i810DDFinish; - ctx->Driver.BuildPrecalcPipeline = i810DDBuildPrecalcPipeline; } diff --git a/xc/lib/GL/mesa/src/drv/i810/i810tris.c b/xc/lib/GL/mesa/src/drv/i810/i810tris.c index 08e012c66..c601ca492 100644 --- a/xc/lib/GL/mesa/src/drv/i810/i810tris.c +++ b/xc/lib/GL/mesa/src/drv/i810/i810tris.c @@ -26,35 +26,17 @@ #include <stdio.h> #include <math.h> +#include "types.h" #include "vb.h" #include "pipeline.h" #include "mm.h" -#include "i810lib.h" #include "i810tris.h" #include "i810vb.h" #include "i810log.h" - -static void i810_null_quad( GLcontext *ctx, GLuint v0, - GLuint v1, GLuint v2, GLuint v3, GLuint pv ) -{ -} - -static void i810_null_triangle( GLcontext *ctx, GLuint v0, - GLuint v1, GLuint v2, GLuint pv ) -{ -} - -static void i810_null_line( GLcontext *ctx, GLuint v1, GLuint v2, GLuint pv ) -{ -} - -static void i810_null_points( GLcontext *ctx, GLuint first, GLuint last ) -{ -} - - +/* Used in i810tritmp.h + */ #define I810_COLOR(to, from) { \ (to)[0] = (from)[2]; \ (to)[1] = (from)[1]; \ @@ -69,17 +51,6 @@ static quad_func quad_tab[0x20]; static line_func line_tab[0x20]; static points_func points_tab[0x20]; -void i810PrintRenderState( const char *msg, GLuint state ) -{ - fprintf(stderr, "%s: (%x) %s%s%s%s%s%s\n", - msg, (int) state, - (state & I810_FLAT_BIT) ? "flat, " : "", - (state & I810_OFFSET_BIT) ? "offset, " : "", - (state & I810_TWOSIDE_BIT) ? "twoside, " : "", - (state & I810_ANTIALIAS_BIT) ? "antialias, " : "", - (state & I810_NODRAW_BIT) ? "no-draw, " : "", - (state & I810_FALLBACK_BIT) ? "fallback" : ""); -} #define IND (0) #define TAG(x) x @@ -89,33 +60,32 @@ void i810PrintRenderState( const char *msg, GLuint state ) #define TAG(x) x##_flat #include "i810tritmp.h" -#define IND (I810_OFFSET_BIT) +#define IND (I810_OFFSET_BIT) /* wide */ #define TAG(x) x##_offset #include "i810tritmp.h" -#define IND (I810_OFFSET_BIT|I810_FLAT_BIT) +#define IND (I810_OFFSET_BIT|I810_FLAT_BIT) /* wide|flat */ #define TAG(x) x##_offset_flat #include "i810tritmp.h" -#define IND (I810_TWOSIDE_BIT) +#define IND (I810_TWOSIDE_BIT) /* stipple */ #define TAG(x) x##_twoside #include "i810tritmp.h" -#define IND (I810_TWOSIDE_BIT|I810_FLAT_BIT) +#define IND (I810_TWOSIDE_BIT|I810_FLAT_BIT) /* stipple|flat */ #define TAG(x) x##_twoside_flat #include "i810tritmp.h" -#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT) +#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT) /* stipple|wide */ #define TAG(x) x##_twoside_offset #include "i810tritmp.h" -#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FLAT_BIT) +#define IND (I810_TWOSIDE_BIT|I810_OFFSET_BIT|I810_FLAT_BIT) /* stip|wide|flat*/ #define TAG(x) x##_twoside_offset_flat #include "i810tritmp.h" void i810DDTrifuncInit() { - int i; init(); init_flat(); init_offset(); @@ -124,128 +94,9 @@ void i810DDTrifuncInit() init_twoside_flat(); init_twoside_offset(); init_twoside_offset_flat(); - - /* Hmmm... - */ - for (i = 0 ; i < 0x20 ; i++) { - if (i & ~I810_FLAT_BIT) { - points_tab[i] = points_tab[i&I810_FLAT_BIT]; - line_tab[i] = line_tab[i&I810_FLAT_BIT]; - } - } - - for (i = 0 ; i < 0x20 ; i++) - if ((i & (I810_NODRAW_BIT|I810_FALLBACK_BIT)) == I810_NODRAW_BIT || - i810glx.nullprims) - { - quad_tab[i] = i810_null_quad; - tri_tab[i] = i810_null_triangle; - line_tab[i] = i810_null_line; - points_tab[i] = i810_null_points; - } - - if (i810glx.noFallback) { - for (i = 0 ; i < 0x10 ; i++) { - points_tab[i|I810_FALLBACK_BIT] = points_tab[i]; - line_tab[i|I810_FALLBACK_BIT] = line_tab[i]; - tri_tab[i|I810_FALLBACK_BIT] = tri_tab[i]; - quad_tab[i|I810_FALLBACK_BIT] = quad_tab[i]; - } - } - } -/* Everything is done via single triangle instructiopns at the moment; - * this can change fairly easily. - */ -#if I810_USE_BATCH - -GLuint *i810AllocPrimitiveVerts( i810ContextPtr imesa, int dwords ) -{ - GLuint orig_dwords = dwords; - - dwords+=2; - dwords&=~1; - - while (1) { - if (i810glx.dma_buffer->space < dwords * 4) - { - if (I810_DEBUG & DEBUG_VERBOSE_RING) - fprintf(stderr, "i810AllocPrimitiveVerts: dma buffer overflow\n"); - i810DmaOverflow( dwords ); - } - else - { - GLuint start = i810glx.dma_buffer->head; - i810glx.dma_buffer->head += dwords * 4; - i810glx.dma_buffer->space -= dwords * 4; - - if ((orig_dwords & 1) == 0) { - *(GLuint *)(i810glx.dma_buffer->virtual_start + start ) = 0; - start += 4; - } - - *(GLuint *)(i810glx.dma_buffer->virtual_start + start ) = - GFX_OP_PRIMITIVE | PR_TRIANGLES | (orig_dwords-1); - - return (GLuint *)(i810glx.dma_buffer->virtual_start + start + 4); - } - } -} - -#else - -/* Hardware lock is held. - */ -GLuint *i810AllocPrimitiveVerts( i810ContextPtr imesa, int dwords ) -{ - GLuint orig_dwords = dwords; - - dwords+=2; - dwords&=~1; - - while (1) - { - BEGIN_LP_RING( imesa, dwords ); - - if (outring + dwords * 4 != ((outring + dwords * 4) & ringmask)) - { - int i; - - if (I810_DEBUG & DEBUG_VERBOSE_RING) - fprintf(stderr, "\n\nwrap case in i810AllocPrimitiveVerts\n\n"); - - for (i = 0 ; i < dwords ; i++) - OUT_RING( 0 ); - ADVANCE_LP_RING(); - } - else - { - i810glx.LpRing.tail = outring + dwords * 4; - - if ((orig_dwords & 1) == 0) - OUT_RING(0); - - OUT_RING( GFX_OP_PRIMITIVE | PR_TRIANGLES | (orig_dwords-1) ); - return (GLuint *)(virt + outring); - } - } -} - -#if 0 -void i810FinishPrim( void ) -{ - char *virt = i810glx.LpRing.virtual_start; - - for (i = i810glx.LpRing.head ; i != i810glx.LpRing.tail ; i += 4) - fprintf(stderr, "prim %x (%f)", *(virt + i), *(float *)(virt + i)); - - OUTREG(LP_RING + RING_TAIL, i810glx.LpRing.tail); -} -#endif -#endif - void i810DDChooseRenderState( GLcontext *ctx ) @@ -253,50 +104,42 @@ void i810DDChooseRenderState( GLcontext *ctx ) i810ContextPtr imesa = I810_CONTEXT( ctx ); GLuint flags = ctx->TriangleCaps; - ctx->IndirectTriangles &= ~DD_SW_RASTERIZE; + imesa->IndirectTriangles = 0; if (flags) { GLuint ind = 0; GLuint shared = 0; - GLuint setup = imesa->setupindex; - GLuint fallback = I810_FALLBACK_BIT; - - if (i810glx.noFallback) fallback = 0; - if ((flags & DD_FLATSHADE) && (setup & I810_RGBA_BIT)) shared |= I810_FLAT_BIT; - if (flags & DD_MULTIDRAW) shared |= fallback; + if (flags & DD_FLATSHADE) shared |= I810_FLAT_BIT; + if (flags & DD_MULTIDRAW) shared |= I810_FALLBACK_BIT; if (flags & DD_SELECT) shared |= I810_FALLBACK_BIT; if (flags & DD_FEEDBACK) shared |= I810_FALLBACK_BIT; + if (flags & DD_STENCIL) shared |= I810_FALLBACK_BIT; - ind = shared; - if (flags & DD_POINT_SMOOTH) ind |= I810_ANTIALIAS_BIT; - if (flags & DD_POINT_ATTEN) ind |= fallback; - - imesa->renderindex = ind; - imesa->PointsFunc = points_tab[ind]; - if (ind & I810_FALLBACK_BIT) - ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE; + imesa->renderindex = shared; + imesa->PointsFunc = points_tab[shared]; ind = shared; - if (flags & DD_LINE_SMOOTH) ind |= I810_ANTIALIAS_BIT; - if (flags & DD_LINE_STIPPLE) ind |= fallback; + if (flags & DD_LINE_WIDTH) ind |= I810_WIDE_LINE_BIT; + if (flags & DD_LINE_STIPPLE) ind |= I810_FALLBACK_BIT; imesa->renderindex |= ind; imesa->LineFunc = line_tab[ind]; if (ind & I810_FALLBACK_BIT) - ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE; + imesa->IndirectTriangles |= DD_LINE_SW_RASTERIZE; ind = shared; - if (flags & DD_TRI_SMOOTH) ind |= I810_ANTIALIAS_BIT; if (flags & DD_TRI_OFFSET) ind |= I810_OFFSET_BIT; if (flags & DD_TRI_LIGHT_TWOSIDE) ind |= I810_TWOSIDE_BIT; - if (flags & (DD_TRI_UNFILLED|DD_TRI_STIPPLE)) ind |= fallback; + if (flags & DD_TRI_UNFILLED) ind |= I810_FALLBACK_BIT; + if ((flags & DD_TRI_STIPPLE) && + (ctx->IndirectTriangles & DD_TRI_STIPPLE)) ind |= I810_FALLBACK_BIT; imesa->renderindex |= ind; imesa->TriangleFunc = tri_tab[ind]; imesa->QuadFunc = quad_tab[ind]; if (ind & I810_FALLBACK_BIT) - ctx->IndirectTriangles |= (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE); + imesa->IndirectTriangles |= (DD_TRI_SW_RASTERIZE|DD_QUAD_SW_RASTERIZE); } else if (imesa->renderindex) { @@ -307,9 +150,9 @@ void i810DDChooseRenderState( GLcontext *ctx ) imesa->QuadFunc = quad_tab[0]; } + if (I810_DEBUG&DEBUG_VERBOSE_API) { gl_print_tri_caps("tricaps", ctx->TriangleCaps); - i810PrintRenderState("i810: Render state", imesa->renderindex); } } diff --git a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c index 496c29a05..a0d9cdf73 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/mga/mga_xmesa.c @@ -27,7 +27,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: - * Daryll Strauss <daryll@precisioninsight.com> + * Keith Whitwell <keithw@precisioninsight.com> * */ @@ -36,10 +36,12 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <X11/Xlibint.h> #include <stdio.h> +#include "drm.h" #include "mga_xmesa.h" #include "context.h" #include "vbxform.h" #include "matrix.h" +#include "mmath.h" #include "simple_list.h" #include "mgadd.h" @@ -49,20 +51,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "mgadepth.h" #include "mgatris.h" #include "mgapipeline.h" +#include "mgabuffers.h" #include "xf86dri.h" -#include "mga_dri.h" -#include "mga_drm_public.h" #include "mga_xmesa.h" +#include "mga_dri.h" + #ifndef MGA_DEBUG int MGA_DEBUG = (0 -/* | MGA_DEBUG_ALWAYS_SYNC */ -/* | MGA_DEBUG_VERBOSE_MSG */ +/* | DEBUG_ALWAYS_SYNC */ +/* | DEBUG_VERBOSE_MSG */ +/* | DEBUG_VERBOSE_LRU */ +/* | DEBUG_VERBOSE_DRI */ +/* | DEBUG_VERBOSE_IOCTL */ +/* | DEBUG_VERBOSE_2D */ ); #endif @@ -71,18 +78,7 @@ static mgaContextPtr mgaCtx = 0; mgaGlx_t mgaglx; -static int count_bits(unsigned int n) -{ - int bits = 0; - - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} - -/* These functions are accessed by dlsym from dri_mesa_init.c: +/* These functions are accessed externally to the driver: * * XMesaInitDriver * XMesaResetDriver @@ -96,163 +92,207 @@ static int count_bits(unsigned int n) * XMesaSwapBuffers * XMesaMakeCurrent * - * So this is kind of the public interface to the driver. The driver - * uses the X11 mesa driver context as a kind of wrapper around its - * own driver context - but there isn't much justificiation for doing - * it that way - the DRI might as well use a (void *) to refer to the - * driver contexts. Nothing in the X context really gets used. */ - GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) { mgaScreenPrivate *mgaScreen; - MGADRIPtr gDRIPriv = (MGADRIPtr)sPriv->pDevPriv; + MGADRIPtr serverInfo = (MGADRIPtr)sPriv->pDevPriv; + + /* Check the DRI version */ + { + int major, minor, patch; + if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) { + if (major != 3 || minor != 0 || patch < 0) { + char msg[1000]; + sprintf(msg, "MGA DRI driver expected DRI version 3.0.x but got version %d.%d.%d", major, minor, patch); + __driMesaMessage(msg); + return GL_FALSE; + } + } + } + + /* Check that the DDX driver version is compatible */ + if (sPriv->ddxMajor != 1 || + sPriv->ddxMinor != 0 || + sPriv->ddxPatch < 0) { + char msg[1000]; + sprintf(msg, "MGA DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch); + __driMesaMessage(msg); + return GL_FALSE; + } + + /* Check that the DRM driver version is compatible */ + if (sPriv->drmMajor != 1 || + sPriv->drmMinor != 0 || + sPriv->drmPatch < 0) { + char msg[1000]; + sprintf(msg, "MGA DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); + __driMesaMessage(msg); + return GL_FALSE; + } /* Allocate the private area */ mgaScreen = (mgaScreenPrivate *)Xmalloc(sizeof(mgaScreenPrivate)); - if (!mgaScreen) return GL_FALSE; + if (!mgaScreen) + return GL_FALSE; mgaScreen->sPriv = sPriv; sPriv->private = (void *)mgaScreen; - mgaScreen->chipset=gDRIPriv->chipset; - mgaScreen->width=gDRIPriv->width; - mgaScreen->height=gDRIPriv->height; - mgaScreen->mem=gDRIPriv->mem; - mgaScreen->cpp=gDRIPriv->cpp; - mgaScreen->frontPitch=gDRIPriv->frontPitch; - mgaScreen->frontOffset=gDRIPriv->frontOffset; - mgaScreen->backOffset=gDRIPriv->backOffset; - mgaScreen->backPitch = gDRIPriv->backPitch; - mgaScreen->depthOffset=gDRIPriv->depthOffset; - mgaScreen->depthPitch = gDRIPriv->depthPitch; - mgaScreen->textureOffset=gDRIPriv->textureOffset; - mgaScreen->textureSize=gDRIPriv->textureSize; - mgaScreen->logTextureGranularity = gDRIPriv->logTextureGranularity; + /* + fprintf(stderr, "serverInfo->chipset: %d\n", serverInfo->chipset); + */ + if (serverInfo->chipset != MGA_CARD_TYPE_G200 && + serverInfo->chipset != MGA_CARD_TYPE_G400) { + XFree(mgaScreen); + sPriv->private = NULL; + return GL_FALSE; + } - mgaScreen->bufs = drmMapBufs(sPriv->fd); + + mgaScreen->chipset = serverInfo->chipset; + mgaScreen->width = serverInfo->width; + mgaScreen->height = serverInfo->height; + mgaScreen->mem = serverInfo->mem; + mgaScreen->cpp = serverInfo->cpp; + mgaScreen->frontPitch = serverInfo->frontPitch; + mgaScreen->frontOffset = serverInfo->frontOffset; + mgaScreen->backOffset = serverInfo->backOffset; + mgaScreen->backPitch = serverInfo->backPitch; + mgaScreen->depthOffset = serverInfo->depthOffset; + mgaScreen->depthPitch = serverInfo->depthPitch; + + + mgaScreen->agp.handle = serverInfo->agp; + mgaScreen->agp.size = serverInfo->agpSize; + + if (drmMap(sPriv->fd, + mgaScreen->agp.handle, + mgaScreen->agp.size, + (drmAddress *)&mgaScreen->agp.map) != 0) + { + Xfree(mgaScreen); + sPriv->private = NULL; + return GL_FALSE; + } + mgaScreen->textureOffset[MGA_CARD_HEAP] = serverInfo->textureOffset; + mgaScreen->textureOffset[MGA_AGP_HEAP] = (serverInfo->agpTextureOffset | + PDEA_pagpxfer_enable | 1); + + /* + fprintf(stderr, "CARD texture size %x, granul %d --> %x\n", + serverInfo->textureSize, serverInfo->logTextureGranularity, + 1<<serverInfo->logTextureGranularity); + */ + + mgaScreen->textureSize[MGA_CARD_HEAP] = serverInfo->textureSize; + mgaScreen->textureSize[MGA_AGP_HEAP] = serverInfo->agpTextureSize; + + mgaScreen->logTextureGranularity[MGA_CARD_HEAP] = + serverInfo->logTextureGranularity; + mgaScreen->logTextureGranularity[MGA_AGP_HEAP] = + serverInfo->logAgpTextureGranularity; + + mgaScreen->texVirtual[MGA_CARD_HEAP] = (mgaScreen->sPriv->pFB + + serverInfo->textureOffset); + mgaScreen->texVirtual[MGA_AGP_HEAP] = (mgaScreen->agp.map + + serverInfo->agpTextureOffset); + + mgaScreen->mAccess = serverInfo->mAccess; + + + /* For calculating setupdma addresses. + */ + mgaScreen->dmaOffset = serverInfo->agpBufferOffset; + + /* + fprintf(stderr, "\n\n\nbackOffset: %x pitch %x\n", + mgaScreen->backOffset, + mgaScreen->backPitch); + */ + + mgaScreen->Attrib = MGA_PF_565; + mgaScreen->bufs = drmMapBufs(sPriv->fd); + if (!mgaScreen->bufs) { + /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/ + XFree(mgaScreen); + sPriv->private = NULL; + return GL_FALSE; + } /* Other mgaglx stuff, too?? */ memset(&mgaglx, 0, sizeof(mgaglx)); mgaDDFastPathInit(); + mgaDDEltPathInit(); mgaDDTrifuncInit(); mgaDDSetupInit(); return GL_TRUE; } + /* Accessed by dlsym from dri_mesa_init.c */ void XMesaResetDriver(__DRIscreenPrivate *sPriv) { - Xfree(sPriv->private); + mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *) sPriv->private; + /*drmUnmap(mgaScreen->agp_tex.map, mgaScreen->agp_tex.size);*/ + Xfree(mgaScreen); + sPriv->private = NULL; } -/* Accessed by dlsym from dri_mesa_init.c - */ -XMesaVisual XMesaCreateVisual(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_size, - GLint level) -{ - XMesaVisual v; - - /* Only RGB visuals are supported on the MGA boards */ - if (!rgb_flag) return 0; - - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) return 0; - - v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); - if(!v->visinfo) { - Xfree(v); - return 0; - } - memcpy(v->visinfo, visinfo, sizeof(*visinfo)); - - v->display = display; - v->level = level; - - v->gl_visual = (GLvisual *)Xmalloc(sizeof(GLvisual)); - if (!v->gl_visual) { - Xfree(v->visinfo); - XFree(v); - return 0; - } - - v->gl_visual->RGBAflag = rgb_flag; - v->gl_visual->DBflag = db_flag; - v->gl_visual->StereoFlag = stereo_flag; - - v->gl_visual->RedBits = count_bits(visinfo->red_mask); - v->gl_visual->GreenBits = count_bits(visinfo->green_mask); - v->gl_visual->BlueBits = count_bits(visinfo->blue_mask); - v->gl_visual->AlphaBits = 0; /* Not currently supported */ - v->gl_visual->AccumBits = accum_size; - v->gl_visual->DepthBits = depth_size; - v->gl_visual->StencilBits = stencil_size; - - return v; -} - -void XMesaDestroyVisual(XMesaVisual v) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - Xfree(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual( config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */ ); } -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) + +GLboolean XMesaCreateContext( Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv ) { + int i; GLcontext *ctx; - XMesaContext c; mgaContextPtr mmesa; __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv; mgaScreenPrivate *mgaScreen = (mgaScreenPrivate *)sPriv->private; drm_mga_sarea_t *saPriv=(drm_mga_sarea_t*)(((char*)sPriv->pSAREA)+ sizeof(XF86DRISAREARec)); - GLcontext *shareCtx = 0; + /*fprintf(stderr, "XMesaCreateContext\n");*/ - c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); - if (!c) { - return 0; - } - - mmesa = (mgaContextPtr)Xmalloc(sizeof(mgaContext)); + mmesa = (mgaContextPtr)Xcalloc(sizeof(mgaContext), 1); if (!mmesa) { - Xfree(c); - return 0; + return GL_FALSE; } - c->driContextPriv = driContextPriv; - c->xm_visual = v; - c->xm_buffer = 0; /* Set by MakeCurrent */ - c->display = v->display; - c->private = (void *)mmesa; - - if (share_list) - shareCtx=((mgaContextPtr)(share_list->private))->glCtx; - - ctx = mmesa->glCtx = gl_create_context(v->gl_visual, shareCtx, - (void*)mmesa, GL_TRUE); + ctx = driContextPriv->mesaContext; - /* Dri stuff - */ - mmesa->display = v->display; + mmesa->display = dpy; mmesa->hHWContext = driContextPriv->hHWContext; mmesa->driFd = sPriv->fd; mmesa->driHwLock = &sPriv->pSAREA->lock; @@ -260,41 +300,42 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, mmesa->mgaScreen = mgaScreen; mmesa->driScreen = sPriv; mmesa->sarea = saPriv; + mmesa->glBuffer = NULL; - mmesa->glBuffer=gl_create_framebuffer(v->gl_visual); - + make_empty_list(&mmesa->SwappedOut); - mmesa->needClip=1; + mmesa->lastTexHeap = mgaScreen->texVirtual[MGA_AGP_HEAP] ? 2 : 1; - mmesa->texHeap = mmInit( 0, mgaScreen->textureSize ); + for (i = 0 ; i < mmesa->lastTexHeap ; i++) { + mmesa->texHeap[i] = mmInit( 0, mgaScreen->textureSize[i]); + make_empty_list(&mmesa->TexObjList[i]); + } - /* Utah stuff - */ mmesa->renderindex = -1; /* impossible value */ mmesa->new_state = ~0; mmesa->dirty = ~0; - - mmesa->warp_pipe = 0; - - - make_empty_list(&mmesa->SwappedOut); - make_empty_list(&mmesa->TexObjList); - + mmesa->warp_pipe = 0; mmesa->CurrentTexObj[0] = 0; mmesa->CurrentTexObj[1] = 0; + mmesa->texAge[0] = 0; + mmesa->texAge[1] = 0; + + ctx->DriverCtx = (void *) mmesa; + mmesa->glCtx = ctx; + mgaDDExtensionsInit( ctx ); mgaDDInitStateFuncs( ctx ); mgaDDInitTextureFuncs( ctx ); mgaDDInitSpanFuncs( ctx ); - mgaDDInitDepthFuncs( ctx ); mgaDDInitDriverFuncs( ctx ); mgaDDInitIoctlFuncs( ctx ); ctx->Driver.TriangleCaps = (DD_TRI_CULL| DD_TRI_LIGHT_TWOSIDE| + DD_TRI_STIPPLE| DD_TRI_OFFSET); /* Ask mesa to clip fog coordinates for us. @@ -312,19 +353,21 @@ XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, mgaDDRegisterPipelineStages(ctx->PipelineStage, ctx->PipelineStage, ctx->NrPipelineStages); - return c; + + mgaInitState( mmesa ); + + driContextPriv->driverPrivate = (void *) mmesa; + + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { - mgaContextPtr mmesa = (mgaContextPtr) c->private; + mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; if (mmesa) { /* mgaTextureObjectPtr next_t, t; */ - gl_destroy_context(mmesa->glCtx); - gl_destroy_framebuffer(mmesa->glBuffer); - /* foreach_s (t, next_t, &(mmesa->TexObjList)) */ /* mgaDestroyTexObj(mmesa, t); */ @@ -333,90 +376,62 @@ void XMesaDestroyContext(XMesaContext c) Xfree(mmesa); - c->private = 0; + driContextPriv->driverPrivate = NULL; } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, - __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); } -void XMesaDestroyBuffer(XMesaBuffer b) + +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer bogus_value_do_not_use) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { + /* XXX should do swap according to the buffer, not the context! */ mgaContextPtr mmesa = mgaCtx; FLUSH_VB( mmesa->glCtx, "swap buffers" ); mgaSwapBuffers(mmesa); } - - - -void mgaXMesaSetFrontClipRects( mgaContextPtr mmesa ) -{ - __DRIdrawablePrivate *dPriv = mmesa->driDrawable; - - mmesa->numClipRects = dPriv->numClipRects; - mmesa->pClipRects = dPriv->pClipRects; - mmesa->drawX = dPriv->x; - mmesa->drawY = dPriv->y; - - mmesa->drawOffset = mmesa->mgaScreen->frontOffset; -} - - -void mgaXMesaSetBackClipRects( mgaContextPtr mmesa ) -{ - __DRIdrawablePrivate *dPriv = mmesa->driDrawable; - - if (dPriv->numAuxClipRects == 0) - { - mmesa->numClipRects = dPriv->numClipRects; - mmesa->pClipRects = dPriv->pClipRects; - mmesa->drawX = dPriv->x; - mmesa->drawY = dPriv->y; - } else { - mmesa->numClipRects = dPriv->numAuxClipRects; - mmesa->pClipRects = dPriv->pAuxClipRects; - mmesa->drawX = dPriv->auxX; - mmesa->drawY = dPriv->auxY; - } - - mmesa->drawOffset = mmesa->mgaScreen->backOffset; -} - - -static void mgaXMesaWindowMoved( mgaContextPtr mmesa ) +GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) { - /* Clear any contaminated CVA data. - */ - mmesa->setupdone = 0; - - switch (mmesa->glCtx->Color.DriverDrawBuffer) { - case GL_FRONT_LEFT: - mgaXMesaSetFrontClipRects( mmesa ); - break; - case GL_BACK_LEFT: - mgaXMesaSetBackClipRects( mmesa ); - break; - default: - fprintf(stderr, "fallback buffer\n"); - break; - } + mgaContextPtr mmesa = (mgaContextPtr) driContextPriv->driverPrivate; + if (mmesa) + mmesa->dirty = ~0; + return GL_TRUE; } @@ -426,27 +441,24 @@ static void mgaXMesaWindowMoved( mgaContextPtr mmesa ) * * But why are we doing context initialization here??? */ -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) { + if (driContextPriv) { + mgaCtx = (mgaContextPtr) driContextPriv->driverPrivate; - if (c->private==(void *)mgaCtx) return GL_TRUE; + gl_make_current2(mgaCtx->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); - if (c) { - __DRIdrawablePrivate *dPriv = c->driContextPriv->driDrawablePriv; - - mgaCtx = (mgaContextPtr)c->private; - - - gl_make_current(mgaCtx->glCtx, mgaCtx->glBuffer); - - mgaXMesaWindowMoved( mgaCtx ); - mgaCtx->driDrawable = dPriv; + mgaCtx->driDrawable = driDrawPriv; mgaCtx->dirty = ~0; + mgaCtx->dirty_cliprects = (MGA_FRONT|MGA_BACK); if (!mgaCtx->glCtx->Viewport.Width) - gl_Viewport(mgaCtx->glCtx, 0, 0, dPriv->w, dPriv->h); + gl_Viewport(mgaCtx->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); - } else { + } + else { gl_make_current(0,0); mgaCtx = NULL; } @@ -455,59 +467,38 @@ GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) } -void mgaXMesaUpdateState( mgaContextPtr mmesa ) +void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) { __DRIdrawablePrivate *dPriv = mmesa->driDrawable; - __DRIscreenPrivate *sPriv = mmesa->driScreen; drm_mga_sarea_t *sarea = mmesa->sarea; - int me = mmesa->hHWContext; - int stamp = dPriv->lastStamp; + int i; - /* If the window moved, may need to set a new cliprect now. - * - * NOTE: This releases and regains the hw lock, so all state - * checking must be done *after* this call: - */ - XMESA_VALIDATE_DRAWABLE_INFO(mmesa->display, sPriv, dPriv); + drmGetLock(mmesa->driFd, mmesa->hHWContext, flags); - if (sarea->ctxOwner != me) { - mmesa->dirty |= MGA_UPLOAD_CTX; + if (*(dPriv->pStamp) != dPriv->lastStamp) { + mmesa->setupdone = 0; + mmesa->dirty_cliprects = (MGA_FRONT|MGA_BACK); + mgaUpdateRects( mmesa, (MGA_FRONT|MGA_BACK) ); } - if (sarea->texAge != mmesa->texAge) { - int sz = 1 << (mmesa->mgaScreen->logTextureGranularity); - int idx, nr = 0; - - /* Have to go right round from the back to ensure stuff ends up - * LRU in our local list... - */ - for (idx = sarea->texList[MGA_NR_TEX_REGIONS].prev ; - idx != MGA_NR_TEX_REGIONS && nr < MGA_NR_TEX_REGIONS ; - idx = sarea->texList[idx].prev, nr++) - { - if (sarea->texList[idx].age > mmesa->texAge) - mgaTexturesGone(mmesa, idx * sz, sz, 1); - } + mmesa->dirty |= MGA_UPLOAD_CTX | MGA_UPLOAD_CLIPRECTS; - if (nr == MGA_NR_TEX_REGIONS) { - mgaTexturesGone(mmesa, 0, mmesa->mgaScreen->textureSize, 0); - mgaResetGlobalLRU( mmesa ); - } + mmesa->sarea->dirty |= MGA_UPLOAD_CTX; - mmesa->texAge = sarea->texAge; - mmesa->dirty |= MGA_UPLOAD_TEX0IMAGE | MGA_UPLOAD_TEX1IMAGE; + if (sarea->ctxOwner != me) { + mmesa->dirty |= (MGA_UPLOAD_CTX | MGA_UPLOAD_TEX0 | + MGA_UPLOAD_TEX1 | MGA_UPLOAD_PIPE); + sarea->ctxOwner=me; } - if (dPriv->lastStamp != stamp) - mgaXMesaWindowMoved( mmesa ); + for (i = 0 ; i < mmesa->lastTexHeap ; i++) + if (sarea->texAge[i] != mmesa->texAge[i]) + mgaAgeTextures( mmesa, i ); - sarea->ctxOwner=me; + sarea->last_quiescent = -1; /* just kill it for now */ } - - - #endif diff --git a/xc/lib/GL/mesa/src/drv/mga/mgadd.c b/xc/lib/GL/mesa/src/drv/mga/mgadd.c index ad56cbbc3..8eb717d5c 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgadd.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgadd.c @@ -61,11 +61,11 @@ static const GLubyte *mgaDDGetString( GLcontext *ctx, GLenum name ) mgaContextPtr mmesa = MGA_CONTEXT( ctx ); switch (name) { case GL_VENDOR: - return "Utah GLX"; + return "Precision Insight, Inc."; case GL_RENDERER: - if (MGA_IS_G200(mmesa)) return "GLX-MGA-G200"; - if (MGA_IS_G400(mmesa)) return "GLX-MGA-G400"; - return "GLX-MGA"; + if (MGA_IS_G200(mmesa)) return "Mesa DRI G200 20000510"; + if (MGA_IS_G400(mmesa)) return "Mesa DRI G400 20000510"; + return "Mesa DRI MGA 20000510"; default: return 0; } @@ -123,10 +123,13 @@ void mgaDDExtensionsInit( GLcontext *ctx ) * a few rogue fallbacks. */ gl_extensions_disable( ctx, "ARB_imaging" ); + gl_extensions_disable( ctx, "GL_EXT_blend_color" ); gl_extensions_disable( ctx, "GL_EXT_blend_minmax" ); gl_extensions_disable( ctx, "GL_EXT_blend_logic_op" ); gl_extensions_disable( ctx, "GL_EXT_blend_subtract" ); gl_extensions_disable( ctx, "GL_INGR_blend_func_separate" ); + gl_extensions_disable( ctx, "GL_EXT_texture_lod_bias" ); + gl_extensions_disable( ctx, "GL_MESA_resize_buffers" ); } diff --git a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c index 8017e7f02..73a939b74 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgafastpath.c @@ -380,10 +380,12 @@ static void mga_project_vertices( struct vertex_buffer *VB ) GLmatrix *mat = &ctx->Viewport.WindowMap; GLfloat m[16]; + REFRESH_DRAWABLE_INFO(mmesa); + m[MAT_SX] = mat->m[MAT_SX]; - m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX - .5; + m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX + SUBPIXEL_X; m[MAT_SY] = (- mat->m[MAT_SY]); - m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY - .5; + m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY + SUBPIXEL_Y; m[MAT_SZ] = mat->m[MAT_SZ] * (1.0 / 0x10000); m[MAT_TZ] = mat->m[MAT_TZ] * (1.0 / 0x10000); @@ -401,10 +403,12 @@ static void mga_project_clipped_vertices( struct vertex_buffer *VB ) GLmatrix *mat = &ctx->Viewport.WindowMap; GLfloat m[16]; + REFRESH_DRAWABLE_INFO(mmesa); + m[MAT_SX] = mat->m[MAT_SX]; - m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX - .5; + m[MAT_TX] = mat->m[MAT_TX] + mmesa->drawX + SUBPIXEL_X; m[MAT_SY] = (- mat->m[MAT_SY]); - m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY - .5; + m[MAT_TY] = (- mat->m[MAT_TY]) + mmesa->driDrawable->h + mmesa->drawY - SUBPIXEL_Y; m[MAT_SZ] = mat->m[MAT_SZ] * (1.0 / 0x10000); m[MAT_TZ] = mat->m[MAT_TZ] * (1.0 / 0x10000); @@ -484,6 +488,16 @@ void mgaDDFastPath( struct vertex_buffer *VB ) gl_prepare_arrays_cva( VB ); /* still need this */ + if (gl_reduce_prim[prim] == GL_TRIANGLES && + VB->Count < (MGA_DMA_BUF_SZ / 48) && + (ctx->ModelProjectMatrix.flags & (MAT_FLAG_GENERAL| + MAT_FLAG_PERSPECTIVE)) && + mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G400) + { + mgaDDEltPath( VB ); + return; + } + /* Reserve enough space for the pathological case. */ if (VB->EltPtr->count * 12 > MGA_DRIVER_DATA(VB)->size) { @@ -507,18 +521,12 @@ void mgaDDFastPath( struct vertex_buffer *VB ) ctx->CVA.elt_mode = gl_reduce_prim[prim]; VB->EltPtr = &(MGA_DRIVER_DATA(VB)->clipped_elements); - LOCK_HARDWARE( mmesa ); mga_project_clipped_vertices( VB ); /* clip->device space */ mga_render_elements_direct( VB ); /* render using new list */ - mgaFlushVerticesLocked( mmesa ); - UNLOCK_HARDWARE( mmesa ); } } else { - LOCK_HARDWARE( mmesa ); mga_project_vertices( VB ); /* clip->device space */ mga_render_elements_direct( VB ); /* render using orig list */ - mgaFlushVerticesLocked( mmesa ); - UNLOCK_HARDWARE( mmesa ); } /* This indicates that there is no cached data to reuse. diff --git a/xc/lib/GL/mesa/src/drv/mga/mgalib.h b/xc/lib/GL/mesa/src/drv/mga/mgalib.h index 4600a69a0..e00525f7b 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgalib.h +++ b/xc/lib/GL/mesa/src/drv/mga/mgalib.h @@ -32,10 +32,10 @@ #include "dri_tmm.h" #include "dri_mesaint.h" #include "dri_mesa.h" -#include "xmesaP.h" #include "types.h" +#include "drm.h" #include "mgacommon.h" #include "mm.h" #include "mgalog.h" @@ -43,7 +43,6 @@ #include "mgatex.h" #include "mgavb.h" -#include "mga_drm_public.h" #include "mga_xmesa.h" @@ -51,11 +50,8 @@ #define MGA_FIELD(field,val) (((val) << (field ## _SHIFT)) & ~(field ## _MASK)) #define MGA_GET_FIELD(field, val) ((val & ~(field ## _MASK)) >> (field ## _SHIFT)) -#define MGA_CHIP_MGAG200 0 -#define MGA_CHIP_MGAG400 1 - -#define MGA_IS_G200(mmesa) (mmesa->mgaScreen->chipset == MGA_CHIP_MGAG200) -#define MGA_IS_G400(mmesa) (mmesa->mgaScreen->chipset == MGA_CHIP_MGAG400) +#define MGA_IS_G200(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G200) +#define MGA_IS_G400(mmesa) (mmesa->mgaScreen->chipset == MGA_CARD_TYPE_G400) /* SoftwareFallback @@ -65,6 +61,7 @@ */ #define MGA_FALLBACK_TEXTURE 0x1 #define MGA_FALLBACK_BUFFER 0x2 +#define MGA_FALLBACK_STIPPLE 0x3 /* For mgaCtx->new_state. @@ -97,17 +94,45 @@ typedef void (*mga_interp_func)( GLfloat t, #define MGA_PF_8888 (10 << 4) #define MGA_PF_HASALPHA (8 << 4) + + +/* Reasons why the GL_BLEND fallback mightn't work: + */ +#define MGA_BLEND_ENV_COLOR 0x1 +#define MGA_BLEND_MULTITEX 0x2 + +struct mga_elt_tab { + void (*emit_unclipped_verts)( struct vertex_buffer *VB ); + + void (*build_tri_verts)( mgaContextPtr mmesa, + struct vertex_buffer *VB, + GLfloat *O, GLuint *elt ); + + void (*interp)( GLfloat t, GLfloat *O, + const GLfloat *I, const GLfloat *J ); + + void (*project_and_emit_verts)( mgaContextPtr mmesa, + const GLfloat *verts, + GLuint *elts, + int nr ); +}; + struct mga_context_t { GLcontext *glCtx; - /* Hardware state - moved from mgabuf.h - */ - mgaUI32 Setup[MGA_CTX_SETUP_SIZE]; - /* Variable sized vertices + /* Bookkeeping for texturing */ - mgaUI32 vertsize; + int lastTexHeap; + struct mga_texture_object_s TexObjList[MGA_NR_TEX_HEAPS]; + struct mga_texture_object_s SwappedOut; + struct mga_texture_object_s *CurrentTexObj[2]; + memHeap_t *texHeap[MGA_NR_TEX_HEAPS]; + int c_texupload; + int c_texusage; + int tex_thrash; + /* Map GL texture units onto hardware. */ @@ -116,72 +141,99 @@ struct mga_context_t { mgaUI32 tex_dest[2]; + /* Manage fallbacks + */ + mgaUI32 IndirectTriangles; + int Fallback; - /* bookkeeping for textureing */ - struct mga_texture_object_s TexObjList; - struct mga_texture_object_s SwappedOut; - struct mga_texture_object_s *CurrentTexObj[2]; - - - /* shared texture palette */ - mgaUI16 GlobalPalette[256]; - - int Fallback; /* or'ed values of FALLBACK_* */ - /* Support for CVA and the fast paths */ + /* Support for CVA and the fastpath + */ unsigned int setupdone; unsigned int setupindex; unsigned int renderindex; unsigned int using_fast_path; - unsigned int using_immediate_fast_path; mga_interp_func interp; - /* Shortcircuit some state changes */ + + /* Support for limited GL_BLEND fallback + */ + unsigned int blend_flags; + unsigned int envcolor; + + + /* Shortcircuit some state changes + */ points_func PointsFunc; line_func LineFunc; triangle_func TriangleFunc; quad_func QuadFunc; - /* Manage our own state */ + + /* Manage driver and hardware state + */ GLuint new_state; GLuint dirty; - - GLubyte clearcolor[4]; - GLushort MonoColor; - GLushort ClearColor; + GLuint Setup[MGA_CTX_SETUP_SIZE]; + GLuint warp_pipe; + GLuint vertsize; + GLushort MonoColor; + GLushort ClearColor; + GLuint poly_stipple; - /* DRI stuff + /* Dma buffers */ - drmBufPtr dma_buffer; + drmBufPtr vertex_dma_buffer; + drmBufPtr iload_buffer; - GLframebuffer *glBuffer; - memHeap_t *texHeap; + + /* Drawable, cliprect and scissor information + */ + int dirty_cliprects; /* which sets of cliprects are uptodate? */ + int draw_buffer; /* which buffer are we rendering to */ + unsigned int drawOffset; /* draw buffer address in space */ + int read_buffer; + int readOffset; + int drawX, drawY; /* origin of drawable in draw buffer */ + int lastX, lastY; /* detect DSTORG bug */ + GLuint numClipRects; /* cliprects for the draw buffer */ + XF86DRIClipRectPtr pClipRects; + XF86DRIClipRectRec draw_rect; + drm_clip_rect_t scissor_rect; + int scissor; - GLuint needClip; - GLuint warp_pipe; - /* These refer to the current draw (front vs. back) buffer: + /* Texture aging and DMA based aging. */ - int drawOffset; /* draw buffer address in agp space */ - int drawX; /* origin of drawable in draw buffer */ - int drawY; - GLuint numClipRects; /* cliprects for that buffer */ - XF86DRIClipRectPtr pClipRects; + unsigned int texAge[MGA_NR_TEX_HEAPS];/* texture LRU age */ + unsigned int dirtyAge; /* buffer age for synchronization */ + unsigned int lastSwap; /* throttling runaway apps */ - int texAge; - XF86DRIClipRectRec draw_rect; + /* Mirrors of some DRI state. + */ + GLframebuffer *glBuffer; drmContext hHWContext; drmLock *driHwLock; int driFd; Display *display; - __DRIdrawablePrivate *driDrawable; __DRIscreenPrivate *driScreen; mgaScreenPrivate *mgaScreen; drm_mga_sarea_t *sarea; + + + /* New setupdma path + */ + drmBufPtr elt_buf, retained_buf; + GLuint *first_elt, *next_elt; + GLfloat *next_vert; + GLuint next_vert_phys; + GLuint first_vert_phys; + struct mga_elt_tab *elt_tab; + GLfloat device_matrix[16]; }; @@ -191,16 +243,12 @@ typedef struct { /* dma stuff */ mgaUI32 systemTexture; - mgaUI32 noSetupDma; mgaUI32 default32BitTextures; - mgaUI32 swapBuffersCount; /* options */ mgaUI32 nullprims; /* skip all primitive generation */ - mgaUI32 noFallback; /* don't fall back to software, do - best-effort rendering */ - mgaUI32 skipDma; /* don't send anything to the hardware */ + mgaUI32 noFallback; /* performance counters */ mgaUI32 c_textureUtilization; @@ -240,10 +288,12 @@ extern mgaGlx_t mgaglx; extern int MGA_DEBUG; #endif -#define MGA_DEBUG_ALWAYS_SYNC 0x1 -#define MGA_DEBUG_VERBOSE_MSG 0x2 -#define MGA_DEBUG_VERBOSE_LRU 0x4 -#define MGA_DEBUG_VERBOSE_DRI 0x8 +#define DEBUG_ALWAYS_SYNC 0x1 +#define DEBUG_VERBOSE_MSG 0x2 +#define DEBUG_VERBOSE_LRU 0x4 +#define DEBUG_VERBOSE_DRI 0x8 +#define DEBUG_VERBOSE_IOCTL 0x10 +#define DEBUG_VERBOSE_2D 0x20 static __inline__ mgaUI32 mgaPackColor(mgaUI32 format, mgaUI8 r, mgaUI8 g, @@ -263,4 +313,12 @@ static __inline__ mgaUI32 mgaPackColor(mgaUI32 format, } } + +/* + * Subpixel offsets for window coordinates: + */ +#define SUBPIXEL_X (-0.5F) +#define SUBPIXEL_Y (-0.5F + 0.125) + + #endif diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c index 38e3cdde8..887e194d2 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaspan.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgaspan.c @@ -5,71 +5,100 @@ #include "mgalog.h" #include "mgaspan.h" +#define DBG 0 + #define LOCAL_VARS \ - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); \ __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \ - __DRIscreenPrivate *sPriv = mmesa->driScreen; \ mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \ - GLuint pitch = mgaScreen->backPitch; \ + __DRIscreenPrivate *sPriv = mmesa->driScreen; \ + GLuint pitch = mgaScreen->frontPitch; \ GLuint height = dPriv->h; \ + char *read_buf = (char *)(sPriv->pFB + \ + mmesa->readOffset + \ + dPriv->x * 2 + \ + dPriv->y * pitch); \ char *buf = (char *)(sPriv->pFB + \ mmesa->drawOffset + \ dPriv->x * 2 + \ + dPriv->y * pitch); \ + GLushort p = MGA_CONTEXT( ctx )->MonoColor; \ + (void) read_buf; (void) buf; (void) p + + + +#define LOCAL_DEPTH_VARS \ + __DRIdrawablePrivate *dPriv = mmesa->driDrawable; \ + mgaScreenPrivate *mgaScreen = mmesa->mgaScreen; \ + __DRIscreenPrivate *sPriv = mmesa->driScreen; \ + GLuint pitch = mgaScreen->frontPitch; \ + GLuint height = dPriv->h; \ + char *buf = (char *)(sPriv->pFB + \ + mgaScreen->depthOffset + \ + dPriv->x * 2 + \ dPriv->y * pitch) -#define INIT_MONO_PIXEL(p) \ - GLushort p = MGA_CONTEXT( ctx )->MonoColor; +#define INIT_MONO_PIXEL(p) -#define CLIPPIXEL(_x,_y) (_x >= minx && _x <= maxx && \ - _y >= miny && _y <= maxy) +#define CLIPPIXEL(_x,_y) (_x >= minx && _x < maxx && \ + _y >= miny && _y < maxy) -#define CLIPSPAN(_x,_y,_n,_x1,_n1) \ +#define CLIPSPAN(_x,_y,_n,_x1,_n1,_i) \ if (_y < miny || _y >= maxy) _n1 = 0, _x1 = x; \ else { \ _n1 = _n; \ _x1 = _x; \ - if (_x1 < minx) _n1 -= (minx - _x1), _x1 = minx; \ - if (_x1 + _n1 > maxx) n1 -= (_x1 + n1 - maxx); \ + if (_x1 < minx) _i += (minx - _x1), _x1 = minx; \ + if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx) + 1; \ } - +#define HW_LOCK() \ + mgaContextPtr mmesa = MGA_CONTEXT(ctx); \ + LOCK_HARDWARE_QUIESCENT(mmesa); #define HW_CLIPLOOP() \ do { \ int _nc = mmesa->numClipRects; \ - LOCK_HARDWARE_QUIESCENT(mmesa); \ while (_nc--) { \ - int minx = mmesa->pClipRects[_nc].x1 - mmesa->drawX; \ - int miny = mmesa->pClipRects[_nc].y1 - mmesa->drawY; \ - int maxx = mmesa->pClipRects[_nc].x2 - mmesa->drawX; \ + int minx = mmesa->pClipRects[_nc].x1 - mmesa->drawX; \ + int miny = mmesa->pClipRects[_nc].y1 - mmesa->drawY; \ + int maxx = mmesa->pClipRects[_nc].x2 - mmesa->drawX; \ int maxy = mmesa->pClipRects[_nc].y2 - mmesa->drawY; - #define HW_ENDCLIPLOOP() \ } \ - UNLOCK_HARDWARE(mmesa); \ } while (0) +#define HW_UNLOCK() \ + UNLOCK_HARDWARE(mmesa); + + -#define Y_FLIP(_y) (height - _y) + + + + +/* 16 bit, 565 rgb color spanline and pixel functions + */ +#define Y_FLIP(_y) (height - _y - 1) #define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0x1f) << 11) | \ - ((g & 0x3f) << 5) | \ - ((b & 0x1f))) + *(GLushort *)(buf + _x*2 + _y*pitch) = ( (((int)r & 0xf8) << 8) | \ + (((int)g & 0xfc) << 3) | \ + (((int)b & 0xf8) >> 3)) + #define WRITE_PIXEL( _x, _y, p ) \ *(GLushort *)(buf + _x*2 + _y*pitch) = p -#define READ_RGBA( rgba, _x, _y ) \ -do { \ - GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \ - rgba[0] = (p >> 11) & 0x1f; \ - rgba[1] = (p >> 5) & 0x3f; \ - rgba[2] = (p >> 0) & 0x1f; \ - rgba[3] = 0; /* or 255? */ \ +#define READ_RGBA( rgba, _x, _y ) \ +do { \ + GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \ + rgba[0] = (p >> 8) & 0xf8; \ + rgba[1] = (p >> 3) & 0xfc; \ + rgba[2] = (p << 3) & 0xf8; \ + rgba[3] = 255; \ } while(0) #define TAG(x) mga##x##_565 @@ -78,22 +107,22 @@ do { \ - -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLushort *)(buf + _x*2 + _y*pitch) = ( ((r & 0x1f) << 10) | \ - ((g & 0x1f) << 5) | \ - ((b & 0x1f))) - +/* 15 bit, 555 rgb color spanline and pixel functions + */ +#define WRITE_RGBA( _x, _y, r, g, b, a ) \ + *(GLushort *)(buf + _x*2 + _y*pitch) = (((r & 0xf8) << 7) | \ + ((g & 0xf8) << 3) | \ + ((b & 0xf8) >> 3)) #define WRITE_PIXEL( _x, _y, p ) \ *(GLushort *)(buf + _x*2 + _y*pitch) = p -#define READ_RGBA( rgba, _x, _y ) \ -do { \ - GLushort p = *(GLushort *)(buf + _x*2 + _y*pitch); \ - rgba[0] = (p >> 10) & 0x1f; \ - rgba[1] = (p >> 5) & 0x1f; \ - rgba[2] = (p >> 0) & 0x1f; \ - rgba[3] = 0; /* or 255? */ \ +#define READ_RGBA( rgba, _x, _y ) \ +do { \ + GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \ + rgba[0] = (p >> 7) & 0xf8; \ + rgba[1] = (p >> 3) & 0xf8; \ + rgba[2] = (p << 3) & 0xf8; \ + rgba[3] = 255; \ } while(0) #define TAG(x) mga##x##_555 @@ -101,27 +130,19 @@ do { \ -#if 0 -#define WRITE_RGBA( _x, _y, r, g, b, a ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = ( ((r) << 16) | \ - ((g) << 8) | \ - ((b))) +/* 16 bit depthbuffer functions. + */ +#define WRITE_DEPTH( _x, _y, d ) \ + *(GLushort *)(buf + _x*2 + _y*pitch) = d; + +#define READ_DEPTH( d, _x, _y ) \ + d = *(GLushort *)(buf + _x*2 + _y*pitch); + +#define TAG(x) mga##x##_16 +#include "depthtmp.h" + -#define WRITE_PIXEL( _x, _y, p ) \ - *(GLuint *)(buf + _x*4 + _y*pitch) = p - -#define READ_RGBA( rgba, _x, _y ) \ -do { \ - GLuint p = *(GLuint *)(buf + _x*4 + _y*pitch); \ - rgba[0] = (p >> 16) & 0xff; \ - rgba[1] = (p >> 8) & 0xff; \ - rgba[2] = (p >> 0) & 0xff; \ - rgba[3] = 0; /* or 255? */ \ -} while(0) -#define TAG(x) mga##x##_888 -#include "spantmp.h" -#endif void mgaDDInitSpanFuncs( GLcontext *ctx ) { @@ -143,6 +164,11 @@ void mgaDDInitSpanFuncs( GLcontext *ctx ) ctx->Driver.ReadRGBAPixels = mgaReadRGBAPixels_555; } + ctx->Driver.ReadDepthSpan = mgaReadDepthSpan_16; + ctx->Driver.WriteDepthSpan = mgaWriteDepthSpan_16; + ctx->Driver.ReadDepthPixels = mgaReadDepthPixels_16; + ctx->Driver.WriteDepthPixels = mgaWriteDepthPixels_16; + ctx->Driver.WriteCI8Span =NULL; ctx->Driver.WriteCI32Span =NULL; ctx->Driver.WriteMonoCISpan =NULL; diff --git a/xc/lib/GL/mesa/src/drv/mga/mgavb.c b/xc/lib/GL/mesa/src/drv/mga/mgavb.c index f78c542c8..3f246d9a7 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgavb.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgavb.c @@ -100,11 +100,11 @@ static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \ mgaVertexPtr v; \ GLfloat (*tc0)[4]; \ GLfloat (*tc1)[4]; \ - GLfloat xoffset = 0.5 + mmesa->drawX; \ - GLfloat yoffset = mmesa->driDrawable->h - 0.5 + mmesa->drawY; \ + GLfloat xoffset = mmesa->drawX + SUBPIXEL_X; \ + GLfloat yoffset = mmesa->driDrawable->h + mmesa->drawY + SUBPIXEL_Y; \ int i; \ (void) xoffset; (void) yoffset; \ - \ + if (0) fprintf(stderr, "V"); \ gl_import_client_data( VB, VB->ctx->RenderFlags, \ (VB->ClipOrMask \ ? VEC_WRITABLE|VEC_GOOD_STRIDE \ @@ -260,11 +260,21 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) mmesa->tex_dest[0] = MGA_TEX0_BIT; mmesa->tex_dest[1] = MGA_TEX1_BIT; mmesa->multitex = 0; + mmesa->blend_flags &= ~MGA_BLEND_MULTITEX; if (ctx->Texture.Enabled & 0xf) { if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE) funcindex &= ~MGA_RGBA_BIT; + if (ctx->Texture.Unit[0].EnvMode == GL_BLEND && + mmesa->envcolor) + { + mmesa->multitex = 1; + mmesa->vertsize = 10; + mmesa->tmu_source[1] = 0; + funcindex |= MGA_TEX1_BIT; + } + funcindex |= MGA_TEX0_BIT; } @@ -272,7 +282,8 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) if (ctx->Texture.Enabled & 0xf) { mmesa->multitex = 1; mmesa->vertsize = 10; - funcindex |= MGA_TEX1_BIT; + mmesa->blend_flags |= MGA_BLEND_MULTITEX; + funcindex |= MGA_TEX1_BIT; } else { /* Just a funny way of doing single texturing */ @@ -281,11 +292,25 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) if (ctx->Texture.Unit[1].EnvMode == GL_REPLACE) funcindex &= ~MGA_RGBA_BIT; + + if (ctx->Texture.Unit[0].EnvMode == GL_BLEND && + mmesa->envcolor) + { + mmesa->multitex = 1; + mmesa->vertsize = 10; + mmesa->tmu_source[1] = 1; + funcindex |= MGA_TEX1_BIT; + } funcindex |= MGA_TEX0_BIT; } } + /* Not really a good place to do this - need to make the mga state + * management code more event-driven so this can be calculated for + * free. + */ + if (ctx->Color.BlendEnabled) funcindex |= MGA_ALPHA_BIT; @@ -298,6 +323,7 @@ void mgaChooseRasterSetupFunc(GLcontext *ctx) if (0) mgaPrintSetupFlags("xsmesa: full setup function", funcindex); + mmesa->dirty |= MGA_UPLOAD_PIPE; mmesa->setupindex = funcindex; /* Called by mesa's clip functons: @@ -477,17 +503,3 @@ void mgaDDUnregisterVB( struct vertex_buffer *VB ) } -mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) -{ - int bytes = dwords * 4; - mgaUI32 *head; - - if (mmesa->dma_buffer->used + bytes > mmesa->dma_buffer->total) - mgaFlushVertices( mmesa ); - - head = (mgaUI32 *)((char *)mmesa->dma_buffer->address + - mmesa->dma_buffer->used); - - mmesa->dma_buffer->used += bytes; - return head; -} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_cce.c b/xc/lib/GL/mesa/src/drv/r128/r128_cce.c new file mode 100644 index 000000000..a89d7dc84 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_cce.c @@ -0,0 +1,333 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Gareth Hughes <gareth@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_state.h" +#include "r128_reg.h" +#include "r128_cce.h" + +#define R128_TIMEOUT 2000000 + +typedef drmBufPtr (*r128_get_buffer_func)( r128ContextPtr r128ctx ); + +static r128_get_buffer_func r128GetBufferLocked; +r128_fire_vertices_func r128FireVerticesLocked; + + +static void r128RingStatus( r128ContextPtr r128ctx ) +{ + r128ScreenPtr r128scrn = r128ctx->r128Screen; + unsigned char *R128MMIO = r128scrn->mmio; + + fprintf( stderr, "GUI_STAT = 0x%08x\n", + (unsigned int) INREG( R128_GUI_STAT ) ); + fprintf( stderr, "PM4_STAT = 0x%08x\n", + (unsigned int) INREG( R128_PM4_STAT ) ); + fprintf( stderr, "PM4_BUFFER_DL_WPTR = 0x%08x\n", + (unsigned int) INREG( R128_PM4_BUFFER_DL_WPTR ) ); + fprintf( stderr, "PM4_BUFFER_DL_RPTR = 0x%08x\n", + (unsigned int) INREG( R128_PM4_BUFFER_DL_RPTR ) ); + fprintf( stderr, "ringWrite = 0x%08x\n", + r128scrn->SAREA->ringWrite ); + fprintf( stderr, "*ringReadPtr = 0x%08x\n", + *r128scrn->ringReadPtr ); +} + + +/* Get a new VB from the pool of vertex buffers in AGP space. + */ +static drmBufPtr r128_get_buffer_locked( r128ContextPtr r128ctx ) +{ + int fd = r128ctx->r128Screen->driScreen->fd; + int num; + int index = 0; + int size = 0; + int to = 0; + drmBufPtr buf = NULL; + + while ( !buf && ( to++ < r128ctx->CCEtimeout ) ) { + num = drmR128GetVertexBuffers( fd, 1, &index, &size ); + + if ( num > 0 ) { + buf = &r128ctx->r128Screen->vbBufs->list[index]; + buf->used = 0; + return buf; + } + } + + if ( !buf ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not get new VB... exiting\n" ); + exit( -1 ); + } + + return buf; +} + +static void r128_fire_vertices_locked( r128ContextPtr r128ctx ) +{ + int vertsize = r128ctx->vertsize; + int format = r128ctx->vc_format; + int index = r128ctx->vert_buf->idx; + int offset = r128ctx->r128Screen->vbOffset + + index * r128ctx->r128Screen->vbBufSize; + int size = r128ctx->vert_buf->used / (vertsize * sizeof(GLuint)); + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + CARD32 prim; + + prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST; + + /* Send the vertex buffer to the hardware */ + BEGIN_CLIP_LOOP( r128ctx ); + { + R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3 ); + R128CCE( offset ); + R128CCE( size ); + R128CCE( format ); + R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_LIST | + (size << R128_CCE_VC_CNTL_NUM_SHIFT) ); + + R128CCE_SUBMIT_PACKET(); + } + END_CLIP_LOOP( r128ctx ); + + /* Tell the kernel to release the vertex buffer */ + do { + ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not flush VB... exiting\n" ); + exit( -1 ); + } + + r128ctx->vert_buf = NULL; +} + +static drmBufPtr r128_get_ring_locked( r128ContextPtr r128ctx ) +{ + r128ScreenPtr r128scrn = r128ctx->r128Screen; + drmBufPtr buf = NULL; + + buf = (drmBufPtr) malloc( sizeof(*buf) ); + + buf->idx = -666; + buf->total = r128scrn->vbBufSize; + buf->used = 0; + buf->address = (drmAddress *) malloc( r128scrn->vbBufSize ); + + return buf; +} + +static void r128_fire_ring_locked( r128ContextPtr r128ctx ) +{ + int vertsize = r128ctx->vertsize; + int format = r128ctx->vc_format; + int size = r128ctx->vert_buf->used / (vertsize * sizeof(GLuint)); + drmBufPtr buf = r128ctx->vert_buf; + CARD32 prim; + + prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST; + + /* Send the vertex buffer to the hardware */ + BEGIN_CLIP_LOOP( r128ctx ); + { + R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 3 ); + R128CCE( format ); + R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_RING | + (size << R128_CCE_VC_CNTL_NUM_SHIFT) ); + + memcpy( &r128ctx->CCEbuf[r128ctx->CCEcount], buf->address, buf->used ); + r128ctx->CCEcount += (buf->used >> 2); + + R128CCE_SUBMIT_PACKET(); + } + END_CLIP_LOOP( r128ctx ); + + free( buf->address ); + free( buf ); + + r128ctx->vert_buf = NULL; +} + + +void r128FlushVerticesLocked( r128ContextPtr r128ctx ) +{ + if ( r128ctx->vert_buf && r128ctx->vert_buf->used ) { + r128FireVerticesLocked( r128ctx ); + } +} + +CARD32 *r128AllocVertexDwords( r128ContextPtr r128ctx, int dwords ) +{ + int bytes = dwords * 4; + CARD32 *head; + + if ( !r128ctx->vert_buf ) { + LOCK_HARDWARE( r128ctx ); + + if ( r128ctx->first_elt != r128ctx->next_elt ) { + r128FlushEltsLocked( r128ctx ); + } + r128ctx->vert_buf = r128GetBufferLocked( r128ctx ); + + UNLOCK_HARDWARE( r128ctx ); + } else if ( r128ctx->vert_buf->used + bytes > r128ctx->vert_buf->total ) { + LOCK_HARDWARE( r128ctx ); + + r128FlushVerticesLocked( r128ctx ); + r128ctx->vert_buf = r128GetBufferLocked( r128ctx ); + + UNLOCK_HARDWARE( r128ctx ); + } + + head = (CARD32 *)((char *)r128ctx->vert_buf->address + + r128ctx->vert_buf->used); + + r128ctx->vert_buf->used += bytes; + return head; +} + + +/* ================================================================ */ + + +void r128GetEltBufLocked( r128ContextPtr r128ctx ) +{ + r128ctx->elt_buf = r128GetBufferLocked( r128ctx ); +} + +void r128FireEltsLocked( r128ContextPtr r128ctx, + GLuint num_elts, GLuint discard ) +{ + int vertsize = r128ctx->vertsize; + int format = r128ctx->vc_format; + int index = r128ctx->vert_buf->idx; + int offset = r128ctx->r128Screen->vbOffset + + index * r128ctx->r128Screen->vbBufSize; + int size = r128ctx->vert_buf->used / (vertsize * sizeof(GLuint)); + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + CARD32 prim; + + fprintf( stderr, "Error: elt buffers not supported at this time...\n" ); + return; + + prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST; + + /* Send the vertex buffer to the hardware */ + BEGIN_CLIP_LOOP( r128ctx ); + { + R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3 ); + R128CCE( offset ); + R128CCE( size ); + R128CCE( format ); + R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_IND | + (size << R128_CCE_VC_CNTL_NUM_SHIFT) ); + + R128CCE_SUBMIT_PACKET(); + } + END_CLIP_LOOP( r128ctx ); + + if ( discard ) { + /* Tell the kernel to release the vertex buffer */ + do { + ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not flush VB... exiting\n" ); + exit( -1 ); + } + } + + r128ctx->vert_buf = NULL; +} + +void r128FlushEltsLocked( r128ContextPtr r128ctx ) +{ + if ( r128ctx->first_elt != r128ctx->next_elt ) { + r128FireEltsLocked( r128ctx, + (GLuint)r128ctx->next_elt - + (GLuint)r128ctx->first_elt, + 0 ); + r128ctx->first_elt = r128ctx->next_elt; + } +} + +void r128ReleaseBufLocked( r128ContextPtr r128ctx, drmBufPtr buffer ) +{ + int index; + int size; + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + + if ( !buffer ) return; + + index = buffer->idx; + size = buffer->used = 0; + + /* Tell the kernel to release the vertex buffer */ + do { + ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not release VB... exiting\n" ); + exit( -1 ); + } +} + + +void r128InitVertexBuffers( r128ScreenPtr r128scrn ) +{ + if ( !r128scrn->IsPCI ) { + r128GetBufferLocked = r128_get_buffer_locked; + r128FireVerticesLocked = r128_fire_vertices_locked; + } else { + r128GetBufferLocked = r128_get_ring_locked; + r128FireVerticesLocked = r128_fire_ring_locked; + } +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_cce.h b/xc/lib/GL/mesa/src/drv/r128/r128_cce.h new file mode 100644 index 000000000..768151971 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_cce.h @@ -0,0 +1,160 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * Gareth Hughes <gareth@precisioninsight.com> + * + */ + +#ifndef _R128_CCE_H_ +#define _R128_CCE_H_ + +#ifdef GLX_DIRECT_RENDERING + +#include "r128_dri.h" +#include "r128_reg.h" + +#include "xf86drmR128.h" + +#define R128_DEFAULT_TOTAL_CCE_TIMEOUT 1000000 /* usecs */ + +typedef union { + float f; + int i; +} floatTOint; + +/* Insert an integer value into the CCE ring buffer. */ +#define R128CCE(v) \ +do { \ + r128ctx->CCEbuf[r128ctx->CCEcount] = (v); \ + r128ctx->CCEcount++; \ +} while (0) + +/* Insert an floating point value into the CCE ring buffer. */ +#define R128CCEF(v) \ +do { \ + floatTOint fTi; \ + fTi.f = (v); \ + r128ctx->CCEbuf[r128ctx->CCEcount] = fTi.i; \ + r128ctx->CCEcount++; \ +} while (0) + +/* Insert a type-[0123] packet header into the ring buffer */ +#define R128CCE0(p,r,n) R128CCE((p) | ((n) << 16) | ((r) >> 2)) +#define R128CCE1(p,r1,r2) R128CCE((p) | (((r2) >> 2) << 11) | ((r1) >> 2)) +#define R128CCE2(p) R128CCE((p)) +#define R128CCE3(p,n) R128CCE((p) | ((n) << 16)) + +#define R128CCE_SUBMIT_PACKET() \ +do { \ + r128SubmitPacketLocked( r128ctx, r128ctx->CCEbuf, r128ctx->CCEcount ); \ + r128ctx->CCEcount = 0; \ +} while (0) + +static __inline void r128SubmitPacketLocked( r128ContextPtr r128ctx, + CARD32 *buf, GLuint count ) +{ + CARD32 *b; + int c = count; + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + + do { + b = buf + (count - c); + ret = drmR128SubmitPacket( fd, b, &c, 0 ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not submit packet... exiting\n" ); + exit( -1 ); + } +} + +static __inline void r128WaitForIdleLocked( r128ContextPtr r128ctx ) +{ + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + + drmR128EngineFlush( fd ); + + do { + ret = drmR128WaitForIdle( fd ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Rage 128 timed out... exiting\n" ); + exit( -1 ); + } +} + +#define r128WaitForIdle( r128ctx ) \ +do { \ + LOCK_HARDWARE( r128ctx ); \ + r128WaitForIdleLocked( r128ctx ); \ + UNLOCK_HARDWARE( r128ctx ); \ +} while (0) + + +extern CARD32 *r128AllocVertexDwords( r128ContextPtr r128ctx, int dwords ); +extern void r128FlushVerticesLocked( r128ContextPtr r128ctx ); + +typedef void (*r128_fire_vertices_func)( r128ContextPtr r128ctx ); +extern r128_fire_vertices_func r128FireVerticesLocked; + +#define r128FlushVertices( r128ctx ) \ +do { \ + LOCK_HARDWARE( r128ctx ); \ + r128FlushVerticesLocked( r128ctx ); \ + UNLOCK_HARDWARE( r128ctx ); \ +} while (0) + + +extern void r128GetEltBufLocked( r128ContextPtr r128ctx ); +extern void r128FlushEltsLocked( r128ContextPtr r128ctx ); +extern void r128FireEltsLocked( r128ContextPtr r128ctx, + GLuint num_elts, GLuint discard ); +extern void r128ReleaseBufLocked( r128ContextPtr r128ctx, drmBufPtr buffer ); + +#define r128FlushElts( r128ctx ) \ +do { \ + LOCK_HARDWARE( r128ctx ); \ + r128FlushEltsLocked( r128ctx ); \ + UNLOCK_HARDWARE( r128ctx ); \ +} while (0) + + +extern void r128InitVertexBuffers( r128ScreenPtr r128scrn ); + +#endif +#endif /* _R128_CCE_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_clear.c b/xc/lib/GL/mesa/src/drv/r128/r128_clear.c new file mode 100644 index 000000000..725b0caef --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_clear.c @@ -0,0 +1,255 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_reg.h" +#include "r128_cce.h" +#include "r128_state.h" +#include "r128_vb.h" +#include "r128_clear.h" + +/* Clear the depth buffer */ +void r128ClearDepthBuffer(r128ContextPtr r128ctx, GLboolean all, + GLint cx, GLint cy, GLint cw, GLint ch) +{ + __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; + int nc; + XF86DRIClipRectPtr c; + int dst_bpp; + CARD32 write_mask; + + if (!(r128ctx->regs.tex_cntl_c & R128_Z_WRITE_ENABLE)) return; + + switch (r128ctx->regs.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK) { + case R128_Z_PIX_WIDTH_16: + write_mask = 0x0000ffff; + dst_bpp = R128_GMC_DST_16BPP; + break; + case R128_Z_PIX_WIDTH_24: + write_mask = 0x00ffffff; + dst_bpp = R128_GMC_DST_32BPP; + break; + case R128_Z_PIX_WIDTH_32: + write_mask = 0xffffffff; + dst_bpp = R128_GMC_DST_32BPP; + break; + default: return; + } + + cx += dPriv->x; + cy = dPriv->y + dPriv->h - cy - ch; + + LOCK_HARDWARE(r128ctx); + + /* Flush any outstanding vertex buffers */ + r128FlushVerticesLocked(r128ctx); + + /* Init the clip rects here in case they changed during the + LOCK_HARDWARE macro */ + c = dPriv->pClipRects; + nc = dPriv->numClipRects; + + /* Set the write mask so that we _only_ clear the Z buffer */ + R128CCE0(R128_CCE_PACKET0, R128_DP_WRITE_MASK, 0); + R128CCE(write_mask); + + /* Temporarily disable Z and stencil buffer and texture mapping modes */ + R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0); + R128CCE(r128ctx->regs.tex_cntl_c & ~(R128_Z_ENABLE | + R128_STENCIL_ENABLE | + R128_TEXMAP_ENABLE)); + + /* Cycle through the clip rects */ + while (nc--) { + int x = c[nc].x1; + int y = c[nc].y1; + int w = c[nc].x2 - x; + int h = c[nc].y2 - y; + + if (!all) { + if (x < cx) w -= cx - x, x = cx; + if (y < cy) h -= cy - y, y = cy; + + if (x + w > cx + cw) w = cx + cw - x; + if (y + h > cy + ch) h = cy + ch - y; + + if (w <= 0 || h <= 0) continue; + } + + x += r128ctx->r128Screen->depthX; + y += r128ctx->r128Screen->depthY; + + R128CCE3(R128_CCE_PACKET3_CNTL_PAINT_MULTI, 3); + R128CCE(R128_GMC_BRUSH_SOLID_COLOR + | dst_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_3D_FCN_EN /* FIXME?? */ + | R128_GMC_CLR_CMP_CNTL_DIS /* FIXME?? */ + | R128_AUX_CLIP_DIS /* FIXME?? */ + | R128_GMC_WR_MSK_DIS); /* FIXME?? */ + R128CCE(r128ctx->ClearDepth); + R128CCE((x << 16) | y); + R128CCE((w << 16) | h); + } + +#if 0 + /* Set the write mask so that we _only_ clear the Z buffer */ + R128CCE0(R128_CCE_PACKET0, R128_DP_WRITE_MASK, 0); + R128CCE(0xffffffff); + + /* Restore Z and stencil buffer and texture mapping modes */ + R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0); + R128CCE(r128ctx->regs.tex_cntl_c); +#else + /* FIXME: We should be able to optimize this by restoring only the + registers that change (above) */ + /* NOTE: The restore of TEX_CNTL_C and R128_DP_WRITE_MASK is handled by + vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; +/* r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; */ + r128ctx->dirty_context |= (R128_CTX_MISC | + R128_CTX_ENGINESTATE | + R128_CTX_ALPHASTATE); + +#endif + + R128CCE_SUBMIT_PACKET(); + + UNLOCK_HARDWARE(r128ctx); +} + +/* Clear a color buffer */ +void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all, + GLint cx, GLint cy, GLint cw, GLint ch, + GLint drawX, GLint drawY) +{ + __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; + int nc; + XF86DRIClipRectPtr c; + int dst_bpp; + + switch (r128ctx->r128Screen->bpp) { + case 8: + dst_bpp = R128_GMC_DST_8BPP_CI; + break; + case 16: + if (r128ctx->r128Screen->depth == 15) dst_bpp = R128_GMC_DST_15BPP; + else dst_bpp = R128_GMC_DST_16BPP; + break; + case 24: + dst_bpp = R128_GMC_DST_24BPP; + break; + case 32: + default: + dst_bpp = R128_GMC_DST_32BPP; + break; + } + + cx += dPriv->x; + cy = dPriv->y + dPriv->h - cy - ch; + + LOCK_HARDWARE(r128ctx); + + /* Flush any outstanding vertex buffers */ + r128FlushVerticesLocked(r128ctx); + + /* Init the clip rects here in case they changed during the + LOCK_HARDWARE macro */ + c = dPriv->pClipRects; + nc = dPriv->numClipRects; + + /* Temporarily disable Z and stencil buffer and texture mapping modes */ + R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0); + R128CCE(r128ctx->regs.tex_cntl_c & ~(R128_Z_ENABLE | + R128_STENCIL_ENABLE | + R128_TEXMAP_ENABLE)); + + /* Cycle through the clip rects */ + while (nc--) { + int x = c[nc].x1; + int y = c[nc].y1; + int w = c[nc].x2 - x; + int h = c[nc].y2 - y; + + if (!all) { + if (x < cx) w -= cx - x, x = cx; + if (y < cy) h -= cy - y, y = cy; + + if (x + w > cx + cw) w = cx + cw - x; + if (y + h > cy + ch) h = cy + ch - h; + + if (w <= 0 || h <= 0) continue; + } + + x += drawX; + y += drawY; + + R128CCE3(R128_CCE_PACKET3_CNTL_PAINT_MULTI, 3); + R128CCE(R128_GMC_BRUSH_SOLID_COLOR + | dst_bpp + | R128_GMC_SRC_DATATYPE_COLOR + | R128_ROP3_P + | R128_GMC_3D_FCN_EN /* FIXME?? */ + | R128_GMC_CLR_CMP_CNTL_DIS /* FIXME?? */ + | R128_AUX_CLIP_DIS); /* FIXME?? */ + R128CCE(r128ctx->ClearColor); + R128CCE((x << 16) | y); + R128CCE((w << 16) | h); + } + +#if 0 + /* Restore Z and stencil buffer and texture mapping modes */ + R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0); + R128CCE(r128ctx->regs.tex_cntl_c); +#else + /* FIXME: We should be able to optimize this by restoring only the + registers that change (above) */ + /* NOTE: The restore of TEX_CNTL_C is handled by + vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; +/* r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; */ + r128ctx->dirty_context |= (R128_CTX_MISC | + R128_CTX_ENGINESTATE | + R128_CTX_ALPHASTATE); +#endif + + R128CCE_SUBMIT_PACKET(); + + UNLOCK_HARDWARE(r128ctx); +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.c b/xc/lib/GL/mesa/src/drv/r128/r128_context.c new file mode 100644 index 000000000..9bbab1dc5 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.c @@ -0,0 +1,218 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include <stdlib.h> + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_cce.h" +#include "r128_dd.h" +#include "r128_state.h" +#include "r128_span.h" +#include "r128_tex.h" +#include "r128_vb.h" +#include "r128_pipeline.h" + +#include "context.h" +#include "simple_list.h" + +/* Create the device specific context */ +GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual, + __DRIcontextPrivate *driContextPriv) +{ + r128ContextPtr r128ctx; + r128ScreenPtr r128scrn; + GLcontext *glCtx = driContextPriv->mesaContext; + int i; + char *v; + + r128ctx = (r128ContextPtr)Xmalloc(sizeof(*r128ctx)); + if (!r128ctx) return GL_FALSE; + + /* Initialize r128Context */ + r128ctx->glCtx = glCtx; + r128ctx->display = dpy; + r128ctx->driContext = driContextPriv; + r128ctx->driDrawable = NULL; /* Set by XMesaMakeCurrent */ + + r128scrn = r128ctx->r128Screen = + (r128ScreenPtr)(driContextPriv->driScreenPriv->private); + + r128ctx->CurrentTexObj[0] = NULL; + r128ctx->CurrentTexObj[1] = NULL; + make_empty_list(&r128ctx->SwappedOut); + for (i = 0; i < r128scrn->NRTexHeaps; i++) { + make_empty_list(&r128ctx->TexObjList[i]); + r128ctx->texHeap[i] = mmInit(0, r128scrn->texSize[i]); + r128ctx->lastTexAge[i] = -1; + } + + r128ctx->lastSwapAge = 0; + + r128ctx->useFastPath = GL_FALSE; + + r128ctx->vert_buf = NULL; + + r128ctx->CCEbuf = (CARD32 *)malloc(sizeof(*r128ctx->CCEbuf) * + r128scrn->ringEntries); + r128ctx->CCEcount = 0; + + if ((v = getenv("LIBGL_CCE_TIMEOUT"))) + r128ctx->CCEtimeout = strtoul(v, NULL, 10); + else + r128ctx->CCEtimeout = (R128_DEFAULT_TOTAL_CCE_TIMEOUT / + R128_DEFAULT_CCE_TIMEOUT); + if (r128ctx->CCEtimeout <= 0) r128ctx->CCEtimeout = 1; + + /* Initialize GLcontext */ + glCtx->DriverCtx = (void *)r128ctx; + + r128DDInitExtensions(glCtx); + + r128DDInitDriverFuncs(glCtx); + r128DDInitStateFuncs(glCtx); + r128DDInitSpanFuncs(glCtx); + r128DDInitTextureFuncs(glCtx); + + /* Do this after initialization of r128ctx->Fallback in InitState(). + */ + if (getenv("LIBGL_SOFTWARE_RENDERING")) + r128ctx->Fallback |= R128_FALLBACK_SWONLY; + + /* KW: No vertex buffer code for PCI cards -- for now fallback to + * software always. + * GTH: There is support there, but I'm seeing strange behaviour + * with it enabled. I'll leave the software fallbacks in place + * for now. + */ + if (r128scrn->IsPCI) + r128ctx->Fallback |= R128_FALLBACK_SWONLY; + + if (getenv("LIBGL_NO_SOFTWARE_FALLBACKS")) + r128ctx->SWfallbackDisable = GL_TRUE; + else + r128ctx->SWfallbackDisable = GL_FALSE; + + glCtx->Driver.TriangleCaps = (DD_TRI_CULL + | DD_TRI_LIGHT_TWOSIDE + | DD_TRI_OFFSET); + + /* Reset Mesa's current 2D texture pointers to the driver's textures */ + glCtx->Shared->DefaultD[2][0].DriverData = NULL; + glCtx->Shared->DefaultD[2][1].DriverData = NULL; + + /* KW: Set the maximum texture size small enough that we can + * guarentee that both texture units can bind a maximal texture + * and have them both in on-card memory at once. (Kevin or + * Gareth: Please check these numbers are OK) + */ + if (r128scrn->texSize[0] < 2*1024*1024) { + glCtx->Const.MaxTextureLevels = 9; + glCtx->Const.MaxTextureSize = 1<<8; + } else if (r128scrn->texSize[0] < 8*1024*1024) { + glCtx->Const.MaxTextureLevels = 10; + glCtx->Const.MaxTextureSize = 1<<9; + } else { + glCtx->Const.MaxTextureLevels = 11; + glCtx->Const.MaxTextureSize = 1<<10; + } + + glCtx->Const.MaxTextureUnits = 2; + + /* If Mesa has current a vertex buffer, make sure the driver's VB + data is up to date */ + if (glCtx->VB) r128DDRegisterVB(glCtx->VB); + + /* Register the fast path */ + if (glCtx->NrPipelineStages) + glCtx->NrPipelineStages = + r128RegisterPipelineStages(glCtx->PipelineStage, + glCtx->PipelineStage, + glCtx->NrPipelineStages); + + r128DDInitState(r128ctx); + + driContextPriv->driverPrivate = (void *)r128ctx; + + return GL_TRUE; +} + +/* Destroy the device specific context */ +void r128DestroyContext(r128ContextPtr r128ctx) +{ + if (r128ctx) { + r128TexObjPtr t, next_t; + int i; + + free(r128ctx->CCEbuf); + + for (i = 0; i < r128ctx->r128Screen->NRTexHeaps; i++) { + foreach_s (t, next_t, &r128ctx->TexObjList[i]) + r128DestroyTexObj(r128ctx, t); + } + + foreach_s (t, next_t, &r128ctx->SwappedOut) + r128DestroyTexObj(r128ctx, t); + + gl_destroy_context(r128ctx->glCtx); + Xfree(r128ctx); + } +} + +/* Load the device specific context into the hardware. The actual + setting of the hardware state is done in the r128UpdateHWState(). */ +r128ContextPtr r128MakeCurrent(r128ContextPtr oldCtx, + r128ContextPtr newCtx, + __DRIdrawablePrivate *dPriv) +{ + if (oldCtx) { + if (!R128CCE_USE_RING_BUFFER(newCtx->r128Screen->CCEMode)) + newCtx->dirty |= R128_REQUIRE_QUIESCENCE; + if (oldCtx != newCtx) { + newCtx->dirty |= R128_UPDATE_CONTEXT; + newCtx->dirty_context |= R128_CTX_ALL_DIRTY; + } + if (oldCtx->driDrawable != dPriv) + newCtx->dirty |= R128_UPDATE_WINPOS; + } else { + newCtx->dirty |= R128_UPDATE_CONTEXT; + newCtx->dirty_context |= R128_CTX_ALL_DIRTY; + } + + newCtx->driDrawable = dPriv; + + return newCtx; +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.h b/xc/lib/GL/mesa/src/drv/r128/r128_context.h new file mode 100644 index 000000000..f362338d5 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h @@ -0,0 +1,236 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifndef _R128_CONTEXT_H_ +#define _R128_CONTEXT_H_ + +#ifdef GLX_DIRECT_RENDERING + +struct r128_context; +typedef struct r128_context r128ContextRec; +typedef struct r128_context *r128ContextPtr; + +#include "r128_texobj.h" +#include "r128_fastpath.h" + +/* Flags for what needs to be updated before a new primitive is rendered */ +#define R128_CLEAN 0x0000 +#define R128_REQUIRE_QUIESCENCE 0x0001 +#define R128_UPDATE_CONTEXT 0x0002 +#define R128_UPDATE_WINPOS 0x0004 +#define R128_UPDATE_TEX0IMAGES 0x0008 +#define R128_UPDATE_TEX1IMAGES 0x0010 +#define R128_UPDATE_TEXSTATE 0x0020 +#define R128_ALL_DIRTY 0xffff + +/* Flags for what context state needs to be updated */ +#define R128_CTX_CLEAN 0x0000 +#define R128_CTX_MISC 0x0001 +#define R128_CTX_ENGINESTATE 0x0002 +#define R128_CTX_TEX0STATE 0x0004 +#define R128_CTX_TEX1STATE 0x0008 +#define R128_CTX_TEXENVSTATE 0x0010 +#define R128_CTX_FOGSTATE 0x0020 +#define R128_CTX_FOGTABLE 0x0040 +#define R128_CTX_ZSTENSTATE 0x0080 +#define R128_CTX_SCISSORS 0x0100 +#define R128_CTX_ALPHASTATE 0x0200 +#define R128_CTX_SETUPSTATE 0x0400 +#define R128_CTX_WIN_Z_POS 0x0800 +#define R128_CTX_FLUSH_PIX_CACHE 0x1000 +#define R128_CTX_ALL_DIRTY 0xffff + +/* Flags for software fallback cases */ +#define R128_FALLBACK_TEXTURE 0x0001 +#define R128_FALLBACK_DRAW_BUFFER 0x0002 +#define R128_FALLBACK_READ_BUFFER 0x0004 +#define R128_FALLBACK_COLORMASK 0x0008 +#define R128_FALLBACK_STIPPLE 0x0010 +#define R128_FALLBACK_SWONLY 0x0020 +#define R128_FALLBACK_RENDER_MODE 0x0040 +#define R128_FALLBACK_MULTIDRAW 0x0080 + +/* NOTE: The groups below need to be kept together so that a single + memcpy can be used to transfer data to the ring buffer */ +typedef struct { + CARD32 scale_3d_cntl; /* 0x1a00 */ + + CARD32 aux_sc_cntl; /* 0x1660 */ + CARD32 aux1_sc_left; + CARD32 aux1_sc_right; + CARD32 aux1_sc_top; + CARD32 aux1_sc_bottom; + CARD32 aux2_sc_left; + CARD32 aux2_sc_right; + CARD32 aux2_sc_top; + CARD32 aux2_sc_bottom; + CARD32 aux3_sc_left; + CARD32 aux3_sc_right; + CARD32 aux3_sc_top; + CARD32 aux3_sc_bottom; /* 0x1690 */ + + CARD32 dst_pitch_offset_c; /* 0x1c80 */ + CARD32 dp_gui_master_cntl; + CARD32 sc_top_left_c; + CARD32 sc_bottom_right_c; + CARD32 z_offset_c; + CARD32 z_pitch_c; + CARD32 z_sten_cntl_c; + CARD32 tex_cntl_c; + CARD32 misc_3d_state_cntl_reg; + CARD32 texture_clr_cmp_clr_c; + CARD32 texture_clr_cmp_msk_c; + CARD32 fog_color_c; + CARD32 prim_tex_cntl_c; + CARD32 prim_texture_combine_cntl_c; + CARD32 tex_size_pitch_c; + CARD32 prim_tex_offset[R128_TEX_MAXLEVELS]; /* 0x1ce4 */ + + CARD32 sec_tex_cntl_c; /* 0x1d00 */ + CARD32 sec_tex_combine_cntl_c; + CARD32 sec_tex_offset[R128_TEX_MAXLEVELS]; + CARD32 constant_color_c; + CARD32 prim_texture_border_color_c; + CARD32 sec_texture_border_color_c; + CARD32 sten_ref_mask_c; + CARD32 plane_3d_mask_c; /* 0x1d44 */ + + CARD32 setup_cntl; /* 0x1bc4 */ + + CARD32 pm4_vc_fpu_setup; /* 0x071c */ + + CARD32 fog_3d_table_start; /* 0x1810 */ + CARD32 fog_3d_table_end; + CARD32 fog_3d_table_density; /* 0x181c */ + + CARD32 window_xy_offset; /* 0x1bcc */ + + CARD32 dp_write_mask; /* 0x16cc */ + + CARD32 pc_gui_ctlstat; /* 0x1748 */ +} r128ContextRegs; + +struct r128_context { + GLcontext *glCtx; /* Mesa context */ + int dirty; /* Hardware state to be updated */ + int dirty_context; /* Context state to be updated */ + + int vertsize; /* Size of current vertices */ + CARD32 vc_format; /* Format of current vertices */ + int multitex; + GLfloat depth_scale; + + int SWfallbackDisable; /* Disable software fallbacks */ + + r128TexObjPtr CurrentTexObj[2]; /* Ptr to current texture + object associated with + each texture unit */ + /* List of tex swapped in per heap*/ + r128TexObj TexObjList[R128_NR_TEX_HEAPS]; + r128TexObj SwappedOut; /* List of textures swapped out */ + memHeap_t *texHeap[R128_NR_TEX_HEAPS]; /* Global tex heaps */ + /* Last known global tex heap ages */ + int lastTexAge[R128_NR_TEX_HEAPS]; + + CARD32 lastSwapAge; /* Last known swap age */ + + GLenum FogMode; /* Current fog equation */ + + int Scissor; + XF86DRIClipRectRec ScissorRect; /* Current software scissor */ + + int useFastPath; /* Currently using Fast Path code */ + int SetupIndex; /* Raster setup function index */ + int SetupDone; /* Partial raster setup done? */ + int RenderIndex; /* Render state function index */ + r128InterpFunc interp; /* Current vert interp function */ + + drmBufPtr vert_buf; /* VB currently being filled */ + + drmBufPtr elt_buf, retained_buf; + GLushort *first_elt, *next_elt, *last_elt; + GLfloat *next_vert, *last_vert; + CARD32 next_vert_index; + CARD32 first_vert_index; + struct r128_elt_tab *elt_tab; + GLfloat device_matrix[16]; + + points_func PointsFunc; /* Current Points, Line, Triangle */ + line_func LineFunc; /* and Quad rendering functions */ + triangle_func TriangleFunc; + quad_func QuadFunc; + + CARD32 IndirectTriangles; /* Flags for point, line, + tri and quad software + fallbacks */ + CARD32 Fallback; /* Need software fallback */ + + r128ContextRegs regs; /* Hardware state */ + CARD32 Color; /* Current draw color */ + CARD32 ClearColor; /* Color used to clear color buffer */ + CARD32 ClearDepth; /* Value used to clear depth buffer */ + + int drawX; /* x-offset to current draw buffer */ + int drawY; /* y-offset to current draw buffer */ + + int readX; /* x-offset to current read buffer */ + int readY; /* y-offset to current read buffer */ + + CARD32 *CCEbuf; /* buffer to submit to CCE */ + int CCEcount; /* number of dwords in CCEbuf */ + + int CCEtimeout; /* number of times to loop + before exiting */ + + Display *display; /* X server display */ + + __DRIcontextPrivate *driContext; /* DRI context */ + __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */ + + r128ScreenPtr r128Screen; /* Screen private DRI data */ +}; + +#define R128_MESACTX(r128ctx) ((r128ctx)->glCtx) +#define R128_DRIDRAWABLE(r128ctx) ((r128ctx)->driDrawable) +#define R128_DRISCREEN(r128ctx) ((r128ctx)->r128Screen->driScreen) + +extern GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual, + __DRIcontextPrivate *driContextPriv); +extern void r128DestroyContext(r128ContextPtr r128ctx); +extern r128ContextPtr r128MakeCurrent(r128ContextPtr oldCtx, + r128ContextPtr newCtx, + __DRIdrawablePrivate *dPriv); + +#endif +#endif /* _R128_CONTEXT_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c new file mode 100644 index 000000000..b621954f4 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c @@ -0,0 +1,176 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_cce.h" +#include "r128_clear.h" +#include "r128_state.h" +#include "r128_vb.h" +#include "r128_pipeline.h" +#include "r128_dd.h" + +/* Driver entry point for clearing color and ancillary buffers */ +static GLbitfield r128DDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, + GLint x, GLint y, GLint width, GLint height) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + if (mask & DD_FRONT_LEFT_BIT) { + r128ClearColorBuffer(r128ctx, all, x, y, width, height, + r128ctx->r128Screen->fbX, + r128ctx->r128Screen->fbY); + mask &= ~DD_FRONT_LEFT_BIT; + } + + if (mask & DD_BACK_LEFT_BIT) { + r128ClearColorBuffer(r128ctx, all, x, y, width, height, + r128ctx->r128Screen->backX, + r128ctx->r128Screen->backY); + mask &= ~DD_BACK_LEFT_BIT; + } + + if (mask & DD_DEPTH_BIT) { + r128ClearDepthBuffer(r128ctx, all, x, y, width, height); + mask &= ~DD_DEPTH_BIT; + } + +#if 0 + /* FIXME: Add stencil support */ + if (mask & DD_STENCIL_BIT) { + r128ClearStencilBuffer(r128ctx, all, x, y, width, height); + mask &= ~DD_STENCIL_BIT; + } +#endif + + return mask; +} + +/* Return the current color buffer size */ +static void r128DDGetBufferSize(GLcontext *ctx, GLuint *width, GLuint *height) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + *width = r128ctx->driDrawable->w; + *height = r128ctx->driDrawable->h; +} + +/* Return various strings for glGetString() */ +static const GLubyte *r128DDGetString(GLcontext *ctx, GLenum name) +{ + switch (name) { + case GL_VENDOR: + return (GLubyte *)"Precision Insight, Inc."; + case GL_RENDERER: + return (GLubyte *)"Mesa DRI Rage128 20000320"; + default: + return NULL; + } +} + +/* Send all commands to the hardware. If vertex buffers or indirect + buffers are in use, then we need to make sure they are sent to the + hardware. All commands that are normally sent to the ring are + already considered `flushed'. */ +static void r128DDFlush(GLcontext *ctx) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + r128FlushVertices(r128ctx); +} + +/* Make sure all commands have been sent to the hardware and have + completed processing. */ +static void r128DDFinish(GLcontext *ctx) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + r128DDFlush(ctx); + r128WaitForIdle(r128ctx); +} + +/* Return various parameters requested by Mesa (this is deprecated) */ +static GLint r128DDGetParameteri(const GLcontext *ctx, GLint param) +{ + switch (param) { + /* Hardware fog isn't working yet -- however returning zero + * here means that it looks like fog is working in some cases. + * It is less confusing to simply have it never work until it + * is actually fixed. + */ + case DD_HAVE_HARDWARE_FOG: return 1; + default: return 0; + } +} + +/* Initialize the extensions supported by this driver */ +void r128DDInitExtensions(GLcontext *ctx) +{ + /* FIXME: Are there other extensions to enable/disable??? */ + gl_extensions_disable(ctx, "GL_EXT_shared_texture_palette"); + gl_extensions_disable(ctx, "GL_EXT_paletted_texture"); + gl_extensions_disable(ctx, "GL_EXT_point_parameters"); + gl_extensions_disable(ctx, "ARB_imaging"); + gl_extensions_disable(ctx, "GL_EXT_blend_minmax"); + gl_extensions_disable(ctx, "GL_EXT_blend_logic_op"); + gl_extensions_disable(ctx, "GL_EXT_blend_subtract"); + gl_extensions_disable(ctx, "GL_INGR_blend_func_separate"); + + if (getenv("LIBGL_NO_MULTITEXTURE")) + gl_extensions_disable(ctx, "GL_ARB_multitexture"); +} + +/* Initialize the driver's misc functions */ +void r128DDInitDriverFuncs(GLcontext *ctx) +{ + ctx->Driver.Clear = r128DDClear; + + ctx->Driver.GetBufferSize = r128DDGetBufferSize; + ctx->Driver.GetString = r128DDGetString; + ctx->Driver.Finish = r128DDFinish; + ctx->Driver.Flush = r128DDFlush; + + ctx->Driver.Error = NULL; + ctx->Driver.GetParameteri = r128DDGetParameteri; + + ctx->Driver.DrawPixels = NULL; + ctx->Driver.Bitmap = NULL; + + ctx->Driver.RegisterVB = r128DDRegisterVB; + ctx->Driver.UnregisterVB = r128DDUnregisterVB; + ctx->Driver.BuildPrecalcPipeline = r128DDBuildPrecalcPipeline; +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c new file mode 100644 index 000000000..cb0568321 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c @@ -0,0 +1,524 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_state.h" +#include "r128_vb.h" +#include "r128_tris.h" +#include "r128_fastpath.h" + +#include "mmath.h" +#include "cva.h" +#include "vertices.h" + +/* FIXME: These routines were copied from the i810 driver, and were only + slightly modified for the Rage 128. They still need to be optmizied + and cleaned up. Also, support for USE_RHW2 needs to be added. + + KW: The fastpath never does projective texturing, so RHW2 support + isn't necesary here. +*/ + +typedef struct r128_fast_table { + r128BuildVerticesFunc build_vertices; + r128InterpFunc interp; +} r128FastPathTable; + +#define POINT(x) r128DrawPointVB(r128ctx, &vert[x], psize) +#define LINE(x,y) r128DrawLineVB(r128ctx, &vert[x], &vert[y], lwidth) +#define TRI(x,y,z) r128DrawTriangleVB(r128ctx, &vert[x], &vert[y], &vert[z]) + +/* Direct, and no clipping required. The clip funcs have not been + written yet, so this is only useful for the fast path. */ +#define RENDER_POINTS(start, count) \ +do { \ + GLuint e; \ + for (e = start; e <= count; e++) \ + POINT(elt[e]); \ +} while (0) + +#define RENDER_LINE(i1, i) \ +do { \ + GLuint e1 = elt[i1], e = elt[i]; \ + LINE(e1, e); \ +} while (0) + +#define RENDER_TRI(i2, i1, i, pv, parity) \ +do { \ + GLuint e2 = elt[i2], e1 = elt[i1], e = elt[i]; \ + if (parity) { \ + GLuint tmp = e2; \ + e2 = e1; \ + e1 = tmp; \ + } \ + TRI(e2, e1, e); \ +} while (0) + +#define RENDER_QUAD(i3, i2, i1, i, pv) \ +do { \ + GLuint e3 = elt[i3], e2 = elt[i2], e1 = elt[i1], e = elt[i]; \ + TRI(e3, e2, e); \ + TRI(e2, e1, e); \ +} while (0) + +#define LOCAL_VARS \ + r128VertexPtr vert = R128_DRIVER_DATA(VB)->verts; \ + const GLuint *elt = VB->EltPtr->data; \ + GLcontext *ctx = VB->ctx; \ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); \ + const GLfloat lwidth = ctx->Line.Width; \ + const GLfloat psize = ctx->Point.Size; \ + (void) lwidth; (void)psize; (void) vert; + +#define TAG(x) x##_r128_smooth_indirect +#include "render_tmp.h" + + + +#define NEGATIVE(f) (f < 0) +#define DIFFERENT_SIGNS(a,b) ((a*b) < 0) +#define LINTERP(T, A, B) ((A) + (T) * ((B) - (A))) + + +#define INTERP_RGBA(t, out, a, b) \ +do { \ + int i; \ + for (i = 0; i < 4; i++) { \ + GLfloat fa = UBYTE_COLOR_TO_FLOAT_COLOR(a[i]); \ + GLfloat fb = UBYTE_COLOR_TO_FLOAT_COLOR(b[i]); \ + GLfloat fo = LINTERP(t, fa, fb); \ + FLOAT_COLOR_TO_UBYTE_COLOR(out[i], fo); \ + } \ +} while (0) + + +#define CLIP(SGN, V, PLANE) \ +do { \ + if (mask & PLANE) { \ + GLuint *indata = inlist[in]; \ + GLuint *outdata = inlist[in ^= 1]; \ + GLuint nr = n; \ + GLfloat *J = verts[indata[nr-1]].f; \ + GLfloat dpJ = (SGN J[V]) + J[3]; \ + \ + inlist[0] = vlist1; \ + for (i = n = 0 ; i < nr ; i++) { \ + GLuint elt_i = indata[i]; \ + GLfloat *I = verts[elt_i].f; \ + GLfloat dpI = (SGN I[V]) + I[3]; \ + \ + if (DIFFERENT_SIGNS(dpI, dpJ)) { \ + GLfloat *O = verts[next_vert].f; \ + GLfloat t, *in, *out; \ + \ + if (NEGATIVE(dpI)) { \ + t = dpI / (dpI - dpJ); \ + in = I; \ + out = J; \ + } else { \ + t = dpJ / (dpJ - dpI); \ + in = J; \ + out = I; \ + } \ + \ + interp(t, O, in, out); \ + \ + clipmask[next_vert] = 0; \ + outdata[n++] = next_vert++; \ + } \ + \ + clipmask[elt_i] |= PLANE; /* don't set up */ \ + \ + if (!NEGATIVE(dpI)) { \ + outdata[n++] = elt_i; \ + clipmask[elt_i] &= ~PLANE; /* set up after all */ \ + } \ + \ + J = I; \ + dpJ = dpI; \ + } \ + \ + if (n < 3) return; \ + } \ +} while (0) + +#define LINE_CLIP(x,y,z,w,PLANE) \ +do { \ + if (mask & PLANE) { \ + GLfloat dpI = DOT4V(I,x,y,z,w); \ + GLfloat dpJ = DOT4V(J,x,y,z,w); \ + \ + if (DIFFERENT_SIGNS(dpI, dpJ)) { \ + GLfloat *O = verts[next_vert].f; \ + GLfloat t = dpI / (dpI - dpJ); \ + \ + interp(t, O, I, J); \ + \ + clipmask[next_vert] = 0; \ + \ + if (NEGATIVE(dpI)) { \ + clipmask[elts[0]] |= PLANE; \ + I = O; \ + elts[0] = next_vert++; \ + } else { \ + clipmask[elts[1]] |= PLANE; \ + J = O; \ + elts[1] = next_vert++; \ + } \ + } else if (NEGATIVE(dpI)) return; \ + } \ +} while (0) + + +static void r128TriClip(GLuint **p_elts, + r128Vertex *verts, + GLubyte *clipmask, + GLuint *p_next_vert, + GLubyte mask, + r128InterpFunc interp) +{ + GLuint *elts = *p_elts; + GLuint next_vert = *p_next_vert; + GLuint in = 0; + GLuint n = 3; + GLuint vlist1[VB_MAX_CLIPPED_VERTS]; + GLuint vlist2[VB_MAX_CLIPPED_VERTS]; + GLuint *inlist[2]; + GLuint *out; + GLuint i; + + inlist[0] = elts; + inlist[1] = vlist2; + + CLIP(-,0,CLIP_RIGHT_BIT); + CLIP(+,0,CLIP_LEFT_BIT); + CLIP(-,1,CLIP_TOP_BIT); + CLIP(+,1,CLIP_BOTTOM_BIT); + CLIP(-,2,CLIP_FAR_BIT); + CLIP(+,2,CLIP_NEAR_BIT); + + /* Convert the planar polygon to a list of triangles */ + out = inlist[in]; + + for (i = 2 ; i < n ; i++) { + elts[0] = out[0]; + elts[1] = out[i-1]; + elts[2] = out[i]; + elts += 3; + } + + *p_next_vert = next_vert; + *p_elts = elts; +} + + +static void r128LineClip(GLuint **p_elts, + r128Vertex *verts, + GLubyte *clipmask, + GLuint *p_next_vert, + GLubyte mask, + r128InterpFunc interp) +{ + GLuint *elts = *p_elts; + GLfloat *I = verts[elts[0]].f; + GLfloat *J = verts[elts[1]].f; + GLuint next_vert = *p_next_vert; + + LINE_CLIP(1,0,0,-1,CLIP_LEFT_BIT); + LINE_CLIP(-1,0,0,1,CLIP_RIGHT_BIT); + LINE_CLIP(0,1,0,-1,CLIP_TOP_BIT); + LINE_CLIP(0,-1,0,1,CLIP_BOTTOM_BIT); + LINE_CLIP(0,0,1,-1,CLIP_FAR_BIT); + LINE_CLIP(0,0,-1,1,CLIP_NEAR_BIT); + + *p_next_vert = next_vert; + *p_elts += 2; +} + + + +#define CLIP_POINT(e) \ +do { \ + if (mask[e]) *out++ = e; \ +} while (0) + +#define CLIP_LINE(e1, e0) \ +do { \ + GLubyte ormask = mask[e0] | mask[e1]; \ + out[0] = e1; \ + out[1] = e0; \ + out += 2; \ + if (ormask) { \ + out-=2; \ + if (!(mask[e0] & mask[e1])) { \ + r128LineClip(&out, verts, mask, &next_vert, ormask, interp); \ + } \ + } \ +} while (0) + +#define CLIP_TRIANGLE(e2, e1, e0) \ +do { \ + GLubyte ormask; \ + out[0] = e2; \ + out[1] = e1; \ + out[2] = e0; \ + out += 3; \ + ormask = mask[e2] | mask[e1] | mask[e0]; \ + if (ormask) { \ + out -= 3; \ + if (!(mask[e2] & mask[e1] & mask[e0])) { \ + r128TriClip(&out, verts, mask, &next_vert, ormask, interp); \ + } \ + } \ +} while (0) + + + +/* Build a table of functions to clip each primitive type. These + * produce a list of elements in the appropriate 'reduced' primitive, + * ie (points, lines, triangles) containing all the clipped and + * unclipped primitives from the original list. + */ +#define LOCAL_VARS \ + r128ContextPtr r128ctx = R128_CONTEXT(VB->ctx); \ + r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB); \ + GLuint *elt = VB->EltPtr->data; \ + r128Vertex *verts = r128VB->verts; \ + GLuint next_vert = r128VB->last_vert; \ + GLuint *out = r128VB->clipped_elements.data; \ + GLubyte *mask = VB->ClipMask; \ + r128InterpFunc interp = r128ctx->interp; \ + (void) interp; (void) verts; + +#define POSTFIX \ + r128VB->clipped_elements.count = out - r128VB->clipped_elements.data; \ + r128VB->last_vert = next_vert; + + +#define INIT(x) + +#define RENDER_POINTS(start, count) \ +do { \ + GLuint i; \ + for (i = start; i < count; i++) \ + CLIP_POINT(elt[i]); \ +} while (0) + +#define RENDER_LINE(i1, i0) \ +do { \ + CLIP_LINE(elt[i1], elt[i0]); \ +} while (0) + +#define RENDER_TRI(i2, i1, i0, pv, parity) \ +do { \ + GLuint e2 = elt[i2], e1 = elt[i1], e0 = elt[i0]; \ + if (parity) e2 = elt[i1], e1 = elt[i2]; \ + CLIP_TRIANGLE(e2, e1, e0); \ +} while (0) + +#define RENDER_QUAD(i3, i2, i1, i0, pv) \ +do { \ + CLIP_TRIANGLE(elt[i3], elt[i2], elt[i0]); \ + CLIP_TRIANGLE(elt[i2], elt[i1], elt[i0]); \ +} while (0) + +#define TAG(x) r128_clip_##x##_elt +#include "render_tmp.h" + + +/* Pack rgba and/or texture into the remaining half of a 32 byte vertex. + */ +#define CLIP_UBYTE_COLOR 4 +#define CLIP_UBYTE_B 0 +#define CLIP_UBYTE_G 1 +#define CLIP_UBYTE_R 2 +#define CLIP_UBYTE_A 3 +#define CLIP_S0 6 +#define CLIP_T0 7 +#define CLIP_S1 8 +#define CLIP_T1 9 + +#define TYPE (0) +#define TAG(x) x +#include "r128_fasttmp.h" + +#define TYPE (R128_RGBA_BIT) +#define TAG(x) x##_RGBA +#include "r128_fasttmp.h" + +#define TYPE (R128_TEX0_BIT) +#define TAG(x) x##_TEX0 +#include "r128_fasttmp.h" + +#define TYPE (R128_RGBA_BIT | R128_TEX0_BIT) +#define TAG(x) x##_RGBA_TEX0 +#include "r128_fasttmp.h" + +#define TYPE (R128_RGBA_BIT | R128_TEX0_BIT | R128_TEX1_BIT) +#define TAG(x) x##_RGBA_TEX0_TEX1 +#include "r128_fasttmp.h" + +/* This one *could* get away with sneaking TEX1 into the color and + * specular slots, thus fitting inside a cache line. Would be even + * better to switch to a smaller vertex. + */ +#define TYPE (R128_TEX0_BIT | R128_TEX1_BIT) +#define TAG(x) x##_TEX0_TEX1 +#include "r128_fasttmp.h" + + + +/* Render elements directly from original list of vertices. */ +static void r128RenderElementsDirect(struct vertex_buffer *VB) +{ + GLcontext *ctx = VB->ctx; + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + GLenum prim = ctx->CVA.elt_mode; + GLuint nr = VB->EltPtr->count; + render_func func = render_tab_r128_smooth_indirect[prim]; + GLuint p = 0; + + if (r128ctx->dirty) r128UpdateHWState(r128ctx); + + do { + func(VB, 0, nr, 0); + } while (ctx->Driver.MultipassFunc && + ctx->Driver.MultipassFunc(VB, ++p)); +} + +/* Project vertices from clip to device space */ +static void r128ProjectVertices(struct vertex_buffer *VB) +{ + GLcontext *ctx = VB->ctx; + GLmatrix *mat = &ctx->Viewport.WindowMap; + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB); + GLfloat m[16]; + + m[MAT_SX] = mat->m[MAT_SX]; + m[MAT_TX] = mat->m[MAT_TX]; + m[MAT_SY] = -mat->m[MAT_SY]; + m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h; + m[MAT_SZ] = mat->m[MAT_SZ] * r128ctx->depth_scale; + m[MAT_TZ] = mat->m[MAT_TZ] * r128ctx->depth_scale; + + gl_project_v16(r128VB->verts[VB->CopyStart].f, + r128VB->verts[r128VB->last_vert].f, + m, + 16 * 4); +} + +/* Project clipped vertices from clip to device space */ +static void r128ProjectClippedVertices(struct vertex_buffer *VB) +{ + GLcontext *ctx = VB->ctx; + GLmatrix *mat = &ctx->Viewport.WindowMap; + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128VertexBufferPtr r128VB = R128_DRIVER_DATA(VB); + GLfloat m[16]; + + m[MAT_SX] = mat->m[MAT_SX]; + m[MAT_TX] = mat->m[MAT_TX]; + m[MAT_SY] = -mat->m[MAT_SY]; + m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h; + m[MAT_SZ] = mat->m[MAT_SZ] * r128ctx->depth_scale; + m[MAT_TZ] = mat->m[MAT_TZ] * r128ctx->depth_scale; + + gl_project_clipped_v16(r128VB->verts[VB->CopyStart].f, + r128VB->verts[r128VB->last_vert].f, + m, + 16 * 4, + VB->ClipMask + VB->CopyStart); +} + +static r128FastPathTable r128FastTab[0x80]; + +/* Initialize the table of fast path support functions */ +void r128FastPathInit(void) +{ + r128_clip_render_init_elt(); + render_init_r128_smooth_indirect(); + + r128_init_fastpath(&r128FastTab[0]); + r128_init_fastpath_RGBA(&r128FastTab[R128_RGBA_BIT]); + r128_init_fastpath_TEX0(&r128FastTab[R128_TEX0_BIT]); + r128_init_fastpath_RGBA_TEX0(&r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT]); + r128_init_fastpath_TEX0_TEX1(&r128FastTab[R128_TEX0_BIT|R128_TEX1_BIT]); + r128_init_fastpath_RGBA_TEX0_TEX1(&r128FastTab[R128_RGBA_BIT|R128_TEX0_BIT| + R128_TEX1_BIT]); +} + +#define VALID_SETUP (R128_RGBA_BIT | R128_TEX0_BIT | R128_TEX1_BIT) + +void r128FastPath(struct vertex_buffer *VB) +{ + GLcontext *ctx = VB->ctx; + GLenum prim = ctx->CVA.elt_mode; + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128FastPathTable *tab = &r128FastTab[r128ctx->SetupIndex & VALID_SETUP]; + GLuint do_cliptest = 1; + + gl_prepare_arrays_cva(VB); /* still need this */ + + /* Reserve enough space for the pathological case */ + if (VB->EltPtr->count * 12 > R128_DRIVER_DATA(VB)->size) { + r128ResizeVB(VB, VB->EltPtr->count * 12); + do_cliptest = 1; + } + + tab->build_vertices(VB, do_cliptest); /* object->clip space */ + + if (r128ctx->dirty) r128UpdateHWState(r128ctx); + + if (VB->ClipOrMask) { + if (!VB->ClipAndMask) { + render_func *clip = r128_clip_render_tab_elt; + + r128ctx->interp = tab->interp; + clip[prim](VB, 0, VB->EltPtr->count, 0); /* build new elts */ + ctx->CVA.elt_mode = gl_reduce_prim[prim]; + VB->EltPtr = &(R128_DRIVER_DATA(VB)->clipped_elements); + r128ProjectClippedVertices(VB); /* clip->device space */ + r128RenderElementsDirect(VB); /* render using new list */ + } + } else { + r128ProjectVertices(VB); /* clip->device space */ + r128RenderElementsDirect(VB); /* render using orig list */ + } + + /* This indicates that there is no cached data to reuse */ + VB->pipeline->data_valid = 0; + VB->pipeline->new_state = 0; +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_init.h b/xc/lib/GL/mesa/src/drv/r128/r128_init.h new file mode 100644 index 000000000..2d58242a9 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_init.h @@ -0,0 +1,86 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifndef _R128_INIT_H_ +#define _R128_INIT_H_ + +#ifdef GLX_DIRECT_RENDERING + +#include <X11/Xlibint.h> + +#include "types.h" +#include "xf86drm.h" +#include "dri_tmm.h" +#include "dri_mesaint.h" + +#include "r128_screen.h" +#include "r128_context.h" + +#define DEBUG 1 +#define DEBUG_LOCKING 1 +#define USE_USER_SPACE_RING 0 + + +#if DEBUG + +#include <stdio.h> +#define R128_DEBUG(p) \ + do { \ + printf p ; \ + fflush(stdout); \ + } while (0) + +extern int R128_DEBUG_FLAGS; + +#else + +#define R128_DEBUG_FLAGS 0 + +#endif + +#define DEBUG_VERBOSE_2D 0x0001 +#define DEBUG_VERBOSE_CCE 0x0008 +#define DEBUG_VERBOSE_OUTREG 0x0010 +#define DEBUG_ALWAYS_SYNC 0x0040 +#define DEBUG_VERBOSE_MSG 0x0080 +#define DEBUG_NO_OUTRING 0x0100 +#define DEBUG_NO_OUTREG 0x0200 +#define DEBUG_VERBOSE_API 0x0400 +#define DEBUG_VALIDATE_RING 0x0800 +#define DEBUG_VERBOSE_LRU 0x1000 +#define DEBUG_VERBOSE_DRI 0x2000 +#define DEBUG_VERBOSE_IOCTL 0x4000 + +#endif +#endif /* _R128_INIT_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_lock.h b/xc/lib/GL/mesa/src/drv/r128/r128_lock.h new file mode 100644 index 000000000..91a65c210 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_lock.h @@ -0,0 +1,134 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifndef _R128_LOCK_H_ +#define _R128_LOCK_H_ + +#ifdef GLX_DIRECT_RENDERING + +/* Turn DEBUG_LOCKING on to find locking conflicts (see r128_init.h) */ +#if DEBUG_LOCKING +extern char *prevLockFile; +extern int prevLockLine; + +#define DEBUG_LOCK() \ + do { \ + prevLockFile = (__FILE__); \ + prevLockLine = (__LINE__); \ + } while (0) + +#define DEBUG_RESET() \ + do { \ + prevLockFile = 0; \ + prevLockLine = 0; \ + } while (0) + +#define DEBUG_CHECK_LOCK() \ + do { \ + if (prevLockFile) { \ + fprintf(stderr, \ + "LOCK SET!\n\tPrevious %s:%d\n\tCurrent: %s:%d\n", \ + prevLockFile, prevLockLine, __FILE__, __LINE__); \ + exit(1); \ + } \ + } while (0) + +#else + +#define DEBUG_LOCK() +#define DEBUG_RESET() +#define DEBUG_CHECK_LOCK() + +#endif + +/* + * !!! We may want to separate locks from locks with validation. This + * could be used to improve performance for those things commands that + * do not do any drawing !!! + */ + +/* Lock the hardware using the current context */ +#define LOCK_HARDWARE(CC) \ + do { \ + char __ret = 0; \ + __DRIcontextPrivate *cPriv = CC->driContext; \ + __DRIscreenPrivate *sPriv = CC->r128Screen->driScreen; \ + \ + DEBUG_CHECK_LOCK(); \ + DRM_CAS(&sPriv->pSAREA->lock, cPriv->hHWContext, \ + DRM_LOCK_HELD|cPriv->hHWContext, __ret); \ + if (__ret) { \ + /* We lost the context, so we need to request the lock from \ + the kernel and update our state. */ \ + drmGetLock(sPriv->fd, cPriv->hHWContext, 0); \ + XMesaUpdateState(cPriv); \ + } \ + DEBUG_LOCK(); \ + } while (0) + +/* Unlock the hardware using the current context */ +#define UNLOCK_HARDWARE(CC) \ + do { \ + __DRIcontextPrivate *cPriv = CC->driContext; \ + __DRIscreenPrivate *sPriv = CC->r128Screen->driScreen; \ + \ + DRM_UNLOCK(sPriv->fd, &sPriv->pSAREA->lock, cPriv->hHWContext); \ + DEBUG_RESET(); \ + } while (0) + +/* + * This pair of macros makes a loop over the drawing operations, so it + * is not self contained and does not have the nice single statement + * semantics of most macros. + */ +#define BEGIN_CLIP_LOOP(CC) \ + do { \ + __DRIdrawablePrivate *_dPriv = CC->driDrawable; \ + XF86DRIClipRectPtr _pc = _dPriv->pClipRects; \ + int _nc, _sc; \ + \ + for (_nc = _dPriv->numClipRects; _nc > 0; _nc -= 3, _pc += 3) { \ + _sc = (_nc <= 3) ? _nc : 3; \ + r128SetClipRects(CC, _pc, _sc) + +/* FIXME: This should be a function call to turn off aux clipping */ +#define END_CLIP_LOOP(CC) \ + R128CCE0(R128_CCE_PACKET0, R128_AUX_SC_CNTL, 0); \ + R128CCE(0x00000000); \ + R128CCE_SUBMIT_PACKET(); \ + } \ + } while (0) + +#endif +#endif /* _R128_LOCK_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c new file mode 100644 index 000000000..74ad8395f --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c @@ -0,0 +1,123 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_vb.h" +#include "r128_fastpath.h" +#include "r128_pipeline.h" + +#include "types.h" + +static struct gl_pipeline_stage r128FastStage = { + "R128 Fast Path", + (PIPE_OP_VERT_XFORM | + PIPE_OP_RAST_SETUP_0 | + PIPE_OP_RAST_SETUP_1 | + PIPE_OP_RENDER), + PIPE_PRECALC, + 0, 0, 0, 0, 0, 0, 0, 0, 0, + r128FastPath +}; + +/* Build the PRECALC pipeline with our stage, if possible. Otherwise, + return GL_FALSE */ +GLboolean r128DDBuildPrecalcPipeline(GLcontext *ctx) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + struct gl_pipeline *pipe = &ctx->CVA.pre; + + if (r128ctx->RenderIndex == 0 && + !(ctx->Enabled & (TEXTURE0_3D | + TEXTURE1_3D | + ENABLE_TEXMAT0 | + ENABLE_TEXMAT1 | + ENABLE_TEXGEN0 | + ENABLE_TEXGEN1 | + ENABLE_USERCLIP | + ENABLE_LIGHT | + ENABLE_FOG)) && + (ctx->Array.Flags & (VERT_OBJ_234 | + VERT_TEX0_4 | + VERT_TEX1_4 | + VERT_ELT)) == (VERT_OBJ_23 | + VERT_ELT)) { + pipe->stages[0] = &r128FastStage; + pipe->stages[1] = 0; + pipe->new_inputs = ctx->RenderFlags & VERT_DATA; + pipe->ops = pipe->stages[0]->ops; + + r128ctx->useFastPath = GL_TRUE; + return GL_TRUE; + } + + if (r128ctx->useFastPath) { + r128ctx->useFastPath = GL_FALSE; + + ctx->CVA.VB->ClipOrMask = 0; + ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS; + ctx->Array.NewArrayState |= ctx->Array.Summary; + } + + return GL_FALSE; +} + + +/* Register the pipeline with our stages included */ +GLuint r128RegisterPipelineStages(struct gl_pipeline_stage *out, + const struct gl_pipeline_stage *in, + GLuint nr) +{ + int i; + + for (i = 0; i < nr; i++) { + out[i] = in[i]; + switch (in[i].ops) { + case PIPE_OP_RAST_SETUP_0: + out[i].cva_state_change = (NEW_LIGHTING | + NEW_TEXTURING | + NEW_RASTER_OPS); + out[i].state_change = ~0; + out[i].check = r128CheckPartialRasterSetup; + out[i].run = r128PartialRasterSetup; + break; + + case PIPE_OP_RAST_SETUP_0|PIPE_OP_RAST_SETUP_1: + out[i].run = r128DoRasterSetup; + break; + } + } + + return nr; +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c new file mode 100644 index 000000000..3f2f0a17f --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c @@ -0,0 +1,260 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_dri.h" +#include "r128_reg.h" + +#include "r128_init.h" +#include "r128_context.h" +#include "r128_xmesa.h" +#include "r128_cce.h" +#include "r128_tris.h" +#include "r128_vb.h" +#include "r128_fastpath.h" + +#include <sys/mman.h> + +/* Create the device specific screen private data struct */ +r128ScreenPtr r128CreateScreen(__DRIscreenPrivate *sPriv) +{ + r128ScreenPtr r128Screen; + R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv; + + /* Allocate the private area */ + r128Screen = (r128ScreenPtr)Xmalloc(sizeof(*r128Screen)); + if (!r128Screen) return NULL; + + /* This is first since which regions we map depends on whether or + not we are using a PCI card */ + r128Screen->IsPCI = r128DRIPriv->IsPCI; + + r128Screen->mmioRgn.handle = r128DRIPriv->registerHandle; + r128Screen->mmioRgn.size = r128DRIPriv->registerSize; + if (drmMap(sPriv->fd, + r128Screen->mmioRgn.handle, + r128Screen->mmioRgn.size, + (drmAddressPtr)&r128Screen->mmio)) { + Xfree(r128Screen); + return NULL; + } + + if (!r128Screen->IsPCI) { + r128Screen->ringRgn.handle = r128DRIPriv->ringHandle; + r128Screen->ringRgn.size = r128DRIPriv->ringMapSize; + if (drmMap(sPriv->fd, + r128Screen->ringRgn.handle, + r128Screen->ringRgn.size, + (drmAddressPtr)&r128Screen->ring)) { + drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size); + Xfree(r128Screen); + return NULL; + } + + r128Screen->ringReadRgn.handle = r128DRIPriv->ringReadPtrHandle; + r128Screen->ringReadRgn.size = r128DRIPriv->ringReadMapSize; + if (drmMap(sPriv->fd, + r128Screen->ringReadRgn.handle, + r128Screen->ringReadRgn.size, + (drmAddressPtr)&r128Screen->ringReadPtr)) { + drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size); + drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size); + Xfree(r128Screen); + return NULL; + } + + r128Screen->vbRgn.handle = r128DRIPriv->vbHandle; + r128Screen->vbRgn.size = r128DRIPriv->vbMapSize; + r128Screen->vbOffset = r128DRIPriv->vbOffset; + if (drmMap(sPriv->fd, + r128Screen->vbRgn.handle, + r128Screen->vbRgn.size, + (drmAddressPtr)&r128Screen->vb)) { + drmUnmap((drmAddress)r128Screen->ringReadPtr, + r128Screen->ringReadRgn.size); + drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size); + drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size); + Xfree(r128Screen); + return NULL; + } + r128Screen->vbOffset = r128DRIPriv->vbOffset; + r128Screen->vbBufSize = r128DRIPriv->vbBufSize; + + r128Screen->indRgn.handle = r128DRIPriv->indHandle; + r128Screen->indRgn.size = r128DRIPriv->indMapSize; + if (drmMap(sPriv->fd, + r128Screen->indRgn.handle, + r128Screen->indRgn.size, + (drmAddressPtr)&r128Screen->ind)) { + drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size); + drmUnmap((drmAddress)r128Screen->ringReadPtr, + r128Screen->ringReadRgn.size); + drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size); + drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size); + Xfree(r128Screen); + return NULL; + } + + r128Screen->agpTexRgn.handle = r128DRIPriv->agpTexHandle; + r128Screen->agpTexRgn.size = r128DRIPriv->agpTexMapSize; + if (drmMap(sPriv->fd, + r128Screen->agpTexRgn.handle, + r128Screen->agpTexRgn.size, + (drmAddressPtr)&r128Screen->agpTex)) { + drmUnmap((drmAddress)r128Screen->ind, r128Screen->indRgn.size); + drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size); + drmUnmap((drmAddress)r128Screen->ringReadPtr, + r128Screen->ringReadRgn.size); + drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size); + drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size); + Xfree(r128Screen); + return NULL; + } + r128Screen->agpTexOffset = r128DRIPriv->agpTexOffset; + + if (!(r128Screen->vbBufs = drmMapBufs(sPriv->fd))) { + drmUnmap((drmAddress)r128Screen->agpTex, + r128Screen->agpTexRgn.size); + drmUnmap((drmAddress)r128Screen->ind, r128Screen->indRgn.size); + drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size); + drmUnmap((drmAddress)r128Screen->ringReadPtr, + r128Screen->ringReadRgn.size); + drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size); + drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size); + Xfree(r128Screen); + return NULL; + } + } + + r128Screen->deviceID = r128DRIPriv->deviceID; + + r128Screen->width = r128DRIPriv->width; + r128Screen->height = r128DRIPriv->height; + r128Screen->depth = r128DRIPriv->depth; + r128Screen->bpp = r128DRIPriv->bpp; + r128Screen->pixel_code = (r128Screen->bpp != 16 ? + r128Screen->bpp : + r128Screen->depth); + + r128Screen->fb = sPriv->pFB; + r128Screen->fbOffset = sPriv->fbOrigin; + r128Screen->fbStride = sPriv->fbStride; + r128Screen->fbSize = sPriv->fbSize; + + r128Screen->fbX = r128DRIPriv->fbX; + r128Screen->fbY = r128DRIPriv->fbY; + r128Screen->backX = r128DRIPriv->backX; + r128Screen->backY = r128DRIPriv->backY; + r128Screen->depthX = r128DRIPriv->depthX; + r128Screen->depthY = r128DRIPriv->depthY; + + r128Screen->texOffset[R128_LOCAL_TEX_HEAP] = (r128DRIPriv->textureY * + r128Screen->fbStride + + r128DRIPriv->textureX * + (r128Screen->bpp/8)); + r128Screen->texSize[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureSize; + r128Screen->log2TexGran[R128_LOCAL_TEX_HEAP] = r128DRIPriv->log2TexGran; + + if (r128Screen->IsPCI) { + r128Screen->texOffset[R128_AGP_TEX_HEAP] = 0; + r128Screen->texSize[R128_AGP_TEX_HEAP] = 0; + r128Screen->log2TexGran[R128_AGP_TEX_HEAP] = 0; + r128Screen->NRTexHeaps = R128_NR_TEX_HEAPS-1; + } else { + r128Screen->texOffset[R128_AGP_TEX_HEAP] = 0; + r128Screen->texSize[R128_AGP_TEX_HEAP] = + r128DRIPriv->agpTexMapSize; + r128Screen->log2TexGran[R128_AGP_TEX_HEAP] = + r128DRIPriv->log2AGPTexGran; + r128Screen->NRTexHeaps = R128_NR_TEX_HEAPS; + } + +#if 1 + /* FIXME: For testing only */ + if (getenv("LIBGL_SHOW_BUFFERS")) { + r128Screen->backX = 0; + r128Screen->backY = r128DRIPriv->height/2; + r128Screen->depthX = r128DRIPriv->width/2; + r128Screen->depthY = r128DRIPriv->height/2; + } +#endif + + r128Screen->CCEMode = r128DRIPriv->CCEMode; + r128Screen->CCEFifoSize = r128DRIPriv->CCEFifoSize; + + r128Screen->ringEntries = r128DRIPriv->ringSize/sizeof(CARD32); + if (!r128Screen->IsPCI) { + r128Screen->ringStartPtr = (int *)r128Screen->ring; + r128Screen->ringEndPtr = (int *)(r128Screen->ring + + r128DRIPriv->ringSize); + } + + r128Screen->MMIOFifoSlots = 0; + r128Screen->CCEFifoSlots = 0; + + r128Screen->CCEFifoAddr = R128_PM4_FIFO_DATA_EVEN; + + r128Screen->SAREA = (R128SAREAPrivPtr)((char *)sPriv->pSAREA + + sizeof(XF86DRISAREARec)); + + r128Screen->driScreen = sPriv; + + r128InitVertexBuffers(r128Screen); + + r128FastPathInit(); + r128TriangleFuncsInit(); + r128SetupInit(); + + return r128Screen; +} + +/* Destroy the device specific screen private data struct */ +void r128DestroyScreen(__DRIscreenPrivate *sPriv) +{ + r128ScreenPtr r128Screen = (r128ScreenPtr)sPriv->private; + + if (!r128Screen->IsPCI) { + drmUnmapBufs(r128Screen->vbBufs); + + drmUnmap((drmAddress)r128Screen->agpTex, r128Screen->agpTexRgn.size); + drmUnmap((drmAddress)r128Screen->ind, r128Screen->indRgn.size); + drmUnmap((drmAddress)r128Screen->vb, r128Screen->vbRgn.size); + drmUnmap((drmAddress)r128Screen->ringReadPtr, + r128Screen->ringReadRgn.size); + drmUnmap((drmAddress)r128Screen->ring, r128Screen->ringRgn.size); + } + drmUnmap((drmAddress)r128Screen->mmio, r128Screen->mmioRgn.size); + + Xfree(r128Screen); + sPriv->private = NULL; +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_span.c b/xc/lib/GL/mesa/src/drv/r128/r128_span.c new file mode 100644 index 000000000..97e70b1c3 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.c @@ -0,0 +1,329 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * Keith Whitwell <keith@precisioninsight.com> + * Gareth Hughes <gareth@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_state.h" +#include "r128_reg.h" +#include "r128_cce.h" +#include "r128_span.h" + +#define DBG 0 + +#define LOCAL_VARS \ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); \ + r128ScreenPtr r128scrn = r128ctx->r128Screen; \ + __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \ + GLuint pitch = r128scrn->fbStride; \ + GLuint height = dPriv->h; \ + char *buf = (char *)(r128scrn->fb + \ + (r128ctx->drawX + dPriv->x) * (r128scrn->bpp/8) + \ + (r128ctx->drawY + dPriv->y) * pitch); \ + char *read_buf = (char *)(r128scrn->fb + \ + (r128ctx->readX + dPriv->x) * (r128scrn->bpp/8)+\ + (r128ctx->readY + dPriv->y) * pitch); \ + GLushort p; \ + (void) read_buf; (void) buf; (void) p + +#define LOCAL_DEPTH_VARS \ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); \ + r128ScreenPtr r128scrn = r128ctx->r128Screen; \ + __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \ + GLuint pitch = r128scrn->fbStride; \ + GLuint height = dPriv->h; \ + char *buf = (char *)(r128scrn->fb + \ + (r128scrn->depthX + dPriv->x) * (r128scrn->bpp/8) + \ + (r128scrn->depthY + dPriv->y) * pitch); \ + (void) buf + +#define INIT_MONO_PIXEL(p) \ + p = R128_CONTEXT(ctx)->Color + +#define CLIPPIXEL(_x, _y) \ + ((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy)) + + +#define CLIPSPAN(_x, _y, _n, _x1, _n1, _i) \ + if (( _y < miny) || (_y >= maxy)) { \ + _n1 = 0, _x1 = x; \ + } else { \ + _n1 = _n; \ + _x1 = _x; \ + if (_x1 < minx) _i += (minx - _x1), _x1 = minx; \ + if (_x1 + _n1 >= maxx) n1 -= (_x1 + n1 - maxx) + 1; \ + } + +#define Y_FLIP(_y) (height - _y - 1) + + +#define HW_LOCK() \ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); \ + LOCK_HARDWARE(r128ctx); \ + r128WaitForIdleLocked(r128ctx); + +#define HW_CLIPLOOP() \ + do { \ + __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \ + int _nc = dPriv->numClipRects; \ + \ + while (_nc--) { \ + int minx = dPriv->pClipRects[_nc].x1 - dPriv->x; \ + int miny = dPriv->pClipRects[_nc].y1 - dPriv->y; \ + int maxx = dPriv->pClipRects[_nc].x2 - dPriv->x; \ + int maxy = dPriv->pClipRects[_nc].y2 - dPriv->y; + +#define HW_ENDCLIPLOOP() \ + } \ + } while (0) + +#define HW_UNLOCK() \ + UNLOCK_HARDWARE(r128ctx) + + + +/* 16 bit, RGB565 color spanline and pixel functions */ +#define WRITE_RGBA(_x, _y, r, g, b, a) \ + *(GLushort *)(buf + _x*2 + _y*pitch) = ((((int)r & 0xf8) << 8) | \ + (((int)g & 0xfc) << 3) | \ + (((int)b & 0xf8) >> 3) ) + +#define WRITE_PIXEL(_x, _y, p) \ + *(GLushort *)(buf + _x*2 + _y*pitch) = p + +#define READ_RGBA(rgba, _x, _y) \ + do { \ + GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \ + rgba[0] = (p >> 8) & 0xf8; \ + rgba[1] = (p >> 3) & 0xfc; \ + rgba[2] = (p << 3) & 0xf8; \ + rgba[3] = 0xff; \ + } while (0) + +#define TAG(x) r128##x##_RGB565 +#include "spantmp.h" + + + +/* 15 bit, ARGB1555 color spanline and pixel functions */ +#define WRITE_RGBA(_x, _y, r, g, b, a) \ + *(GLushort *)(buf + _x*2 + _y*pitch) = (((r & 0xf8) << 7) | \ + ((g & 0xf8) << 2) | \ + ((b & 0xf8) >> 3) | \ + ((a) ? 0x8000 : 0)) + +#define WRITE_PIXEL(_x, _y, p) \ + *(GLushort *)(buf + _x*2 + _y*pitch) = p + +#define READ_RGBA(rgba, _x, _y) \ + do { \ + GLushort p = *(GLushort *)(read_buf + _x*2 + _y*pitch); \ + rgba[0] = (p >> 7) & 0xf8; \ + rgba[1] = (p >> 2) & 0xf8; \ + rgba[2] = (p << 3) & 0xf8; \ + rgba[3] = (p & 0x8000) ? 0xff : 0; \ + } while (0) + +#define TAG(x) r128##x##_ARGB1555 +#include "spantmp.h" + + + +/* 16 bit depthbuffer functions */ +#define WRITE_DEPTH(_x, _y, d) \ + *(GLushort *)(buf + _x*2 + _y*pitch) = d; + +#define READ_DEPTH(d, _x, _y) \ + d = *(GLushort *)(buf + _x*2 + _y*pitch) + +#define TAG(x) r128##x##_16 +#include "depthtmp.h" + + + +/* 24 bit, RGB888 color spanline and pixel functions */ +#define WRITE_RGBA(_x, _y, r, g, b, a) \ + *(GLuint *)(buf + _x*3 + _y*pitch) = ((r << 16) | \ + (g << 8) | \ + (b << 0)) + +#define WRITE_PIXEL(_x, _y, p) \ + *(GLuint *)(buf + _x*3 + _y*pitch) = p + +#define READ_RGBA(rgba, _x, _y) \ + do { \ + GLuint p = *(GLuint *)(read_buf + _x*3 + _y*pitch); \ + rgba[0] = (p >> 16) & 0xff; \ + rgba[1] = (p >> 8) & 0xff; \ + rgba[2] = (p >> 0) & 0xff; \ + rgba[3] = 0xff; \ + } while (0) + +#define TAG(x) r128##x##_RGB888 +#include "spantmp.h" + + + +/* 24 bit depthbuffer functions */ +#define WRITE_DEPTH(_x, _y, d) \ + *(GLuint *)(buf + _x*3 + _y*pitch) = d + +#define READ_DEPTH(d, _x, _y) \ + d = *(GLuint *)(buf + _x*3 + _y*pitch) + +#define TAG(x) r128##x##_24 +#include "depthtmp.h" + + + +/* 32 bit, ARGB8888 color spanline and pixel functions */ +#define WRITE_RGBA(_x, _y, r, g, b, a) \ + *(GLuint *)(buf + _x*4 + _y*pitch) = ((r << 16) | \ + (g << 8) | \ + (b << 0) | \ + (a << 24) ) + +#define WRITE_PIXEL(_x, _y, p) \ + *(GLuint *)(buf + _x*4 + _y*pitch) = p + +#define READ_RGBA(rgba, _x, _y) \ + do { \ + GLuint p = *(GLuint *)(read_buf + _x*4 + _y*pitch); \ + rgba[0] = (p >> 16) & 0xff; \ + rgba[1] = (p >> 8) & 0xff; \ + rgba[2] = (p >> 0) & 0xff; \ + rgba[3] = (p >> 24) & 0xff; \ + } while (0) + +#define TAG(x) r128##x##_ARGB8888 +#include "spantmp.h" + + + +/* 32 bit depthbuffer functions */ +#define WRITE_DEPTH(_x, _y, d) \ + *(GLuint *)(buf + _x*4 + _y*pitch) = d + +#define READ_DEPTH(d, _x, _y) \ + d = *(GLuint *)(buf + _x*4 + _y*pitch) + +#define TAG(x) r128##x##_32 +#include "depthtmp.h" + + + +void r128DDInitSpanFuncs(GLcontext *ctx) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + switch (r128ctx->r128Screen->pixel_code) { + case 8: /* Color Index mode not supported */ + break; + + case 15: + ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB1555; + ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB1555; + ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB1555; + ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB1555; + ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB1555; + ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB1555; + ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB1555; + + ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_16; + ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_16; + ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_16; + ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_16; + break; + + case 16: + ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB565; + ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB565; + ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB565; + ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB565; + ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB565; + ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB565; + ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB565; + + ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_16; + ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_16; + ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_16; + ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_16; + break; + + case 24: + ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB888; + ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB888; + ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB888; + ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB888; + ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB888; + ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB888; + ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB888; + + ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_24; + ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_24; + ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_24; + ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_24; + break; + + case 32: + ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB8888; + ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB8888; + ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB8888; + ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB8888; + ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB8888; + ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB8888; + ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB8888; + + ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_32; + ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_32; + ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_32; + ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_32; + break; + + default: + break; + } + + ctx->Driver.WriteCI8Span = NULL; + ctx->Driver.WriteCI32Span = NULL; + ctx->Driver.WriteMonoCISpan = NULL; + ctx->Driver.WriteCI32Pixels = NULL; + ctx->Driver.WriteMonoCIPixels = NULL; + ctx->Driver.ReadCI32Span = NULL; + ctx->Driver.ReadCI32Pixels = NULL; +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_state.c b/xc/lib/GL/mesa/src/drv/r128/r128_state.c new file mode 100644 index 000000000..981874493 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.c @@ -0,0 +1,1402 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_state.h" +#include "r128_reg.h" +#include "r128_cce.h" +#include "r128_tris.h" +#include "r128_vb.h" +#include "r128_tex.h" + +#include "mmath.h" +#include "pb.h" + +#define INTERESTED (~(NEW_MODELVIEW | \ + NEW_PROJECTION | \ + NEW_TEXTURE_MATRIX | \ + NEW_USER_CLIP | \ + NEW_CLIENT_STATE | \ + NEW_TEXTURE_ENABLE)) + +static void r128DDUpdateState(GLcontext *ctx) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) { + fprintf(stderr, "r128DDUpdateState(%p)\n", ctx); + } + + /* Need to do this here to detect texture fallbacks before + * setting triangle functions. + */ + if (r128ctx->dirty & R128_UPDATE_TEXSTATE) + r128UpdateHWState(r128ctx); + + if (ctx->NewState & INTERESTED) { + r128ChooseRenderState(ctx); + r128ChooseRasterSetupFunc(ctx); + } + + if (!r128ctx->Fallback) { + ctx->IndirectTriangles &= ~DD_SW_RASTERIZE; + ctx->IndirectTriangles |= r128ctx->IndirectTriangles; + + ctx->Driver.PointsFunc = r128ctx->PointsFunc; + ctx->Driver.LineFunc = r128ctx->LineFunc; + ctx->Driver.TriangleFunc = r128ctx->TriangleFunc; + ctx->Driver.QuadFunc = r128ctx->QuadFunc; + ctx->Driver.RectFunc = NULL; + } +} + +static void r128DDUpdateHWState(GLcontext *ctx) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + /* FIXME: state is being updated too often */ + if (r128ctx->dirty) + r128UpdateHWState(r128ctx); +} + + +/* This is called when mesa switches between rendering triangle + * primitives (such as GL_POLYGON, GL_QUADS, GL_TRIANGLE_STRIP, etc), + * and lines, points and bitmaps. + * + * As the r128 uses triangles to render lines and points, it is + * necessary to turn off hardware culling when rendering these + * primitives. + */ +static void r128DDReducedPrimitiveChange(GLcontext *ctx, GLenum prim) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 f = r128ctx->regs.pm4_vc_fpu_setup; + + f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID; + + /* Should really use an intermediate value to hold this rather + * than recalculating all the time. + */ + if (prim == GL_POLYGON && ctx->Polygon.CullFlag) { + switch (ctx->Polygon.CullFaceMode) { + case GL_FRONT: f &= ~R128_FRONTFACE_SOLID; break; + case GL_BACK: f &= ~R128_BACKFACE_SOLID; break; + case GL_FRONT_AND_BACK: f &= ~(R128_BACKFACE_SOLID | + R128_FRONTFACE_SOLID); break; + default: + } + } + + if (r128ctx->regs.pm4_vc_fpu_setup != f) { + r128FlushVertices(r128ctx); + r128ctx->regs.pm4_vc_fpu_setup = f; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_SETUPSTATE; + } +} + +static void r128DDClearColor(GLcontext *ctx, + GLubyte r, GLubyte g, GLubyte b, GLubyte a) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + r128ctx->ClearColor = r128PackColor(r128ctx->r128Screen->depth, + r, g, b, a); +} + +static void r128DDColor(GLcontext *ctx, + GLubyte r, GLubyte g, GLubyte b, GLubyte a) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + r128ctx->Color = r128PackColor(r128ctx->r128Screen->depth, r, g, b, a); +} + +static GLboolean r128DDSetDrawBuffer(GLcontext *ctx, GLenum mode) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + int x = r128ctx->driDrawable->x; + int y = r128ctx->driDrawable->y; + int found; + + r128ctx->Fallback &= ~R128_FALLBACK_DRAW_BUFFER; + + switch (mode) { + case GL_FRONT_LEFT: + r128ctx->drawX = r128ctx->r128Screen->fbX; + r128ctx->drawY = r128ctx->r128Screen->fbY; + found = GL_TRUE; + break; + case GL_BACK_LEFT: + r128ctx->drawX = r128ctx->r128Screen->backX; + r128ctx->drawY = r128ctx->r128Screen->backY; + found = GL_TRUE; + break; + default: + r128ctx->Fallback |= R128_FALLBACK_DRAW_BUFFER; + found = GL_FALSE; + break; + } + + x += r128ctx->drawX; + y += r128ctx->drawY; + + r128FlushVertices(r128ctx); + + r128ctx->regs.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) | + (x << R128_WINDOW_X_SHIFT)); + + /* Recalculate the Z buffer offset since we might be drawing to the + back buffer and window_xy_offset affects both color buffer and + depth drawing */ + r128ctx->regs.z_offset_c = ((r128ctx->r128Screen->depthX - + r128ctx->drawX) * + (r128ctx->r128Screen->bpp/8) + + (r128ctx->r128Screen->depthY - + r128ctx->drawY) * + r128ctx->r128Screen->fbStride); + + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_WIN_Z_POS; + return found; +} + +static void r128DDSetReadBuffer(GLcontext *ctx, + GLframebuffer *colorBuffer, + GLenum mode) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + r128ctx->Fallback &= ~R128_FALLBACK_READ_BUFFER; + + switch (mode) { + case GL_FRONT_LEFT: + r128ctx->readX = r128ctx->r128Screen->fbX; + r128ctx->readY = r128ctx->r128Screen->fbY; + break; + case GL_BACK_LEFT: + r128ctx->readX = r128ctx->r128Screen->backX; + r128ctx->readY = r128ctx->r128Screen->backY; + break; + default: + r128ctx->Fallback |= R128_FALLBACK_READ_BUFFER; + break; + } +} + +static GLboolean r128DDColorMask(GLcontext *ctx, + GLboolean r, GLboolean g, + GLboolean b, GLboolean a) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + GLuint mask = r128PackColor(r128ctx->r128Screen->pixel_code, + ctx->Color.ColorMask[RCOMP], + ctx->Color.ColorMask[GCOMP], + ctx->Color.ColorMask[BCOMP], + ctx->Color.ColorMask[ACOMP]); + + if (r128ctx->regs.plane_3d_mask_c != mask) { + r128FlushVertices(r128ctx); + r128ctx->regs.plane_3d_mask_c = mask; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_MISC; + } + + return GL_TRUE; +} + + +static void r128DDDither(GLcontext *ctx, GLboolean enable) +{ +} + +static void r128DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 a = r128ctx->regs.misc_3d_state_cntl_reg; + + a &= ~(R128_ALPHA_TEST_MASK | R128_REF_ALPHA_MASK); + a |= ctx->Color.AlphaRef & R128_REF_ALPHA_MASK; + + switch (func) { + case GL_NEVER: a |= R128_ALPHA_TEST_NEVER; break; + case GL_LESS: a |= R128_ALPHA_TEST_LESS; break; + case GL_LEQUAL: a |= R128_ALPHA_TEST_LESSEQUAL; break; + case GL_EQUAL: a |= R128_ALPHA_TEST_EQUAL; break; + case GL_GEQUAL: a |= R128_ALPHA_TEST_GREATEREQUAL; break; + case GL_GREATER: a |= R128_ALPHA_TEST_GREATER; break; + case GL_NOTEQUAL: a |= R128_ALPHA_TEST_NEQUAL; break; + case GL_ALWAYS: a |= R128_ALPHA_TEST_ALWAYS; + break; + default: + /* ERROR!!! */ + return; + } + + if (r128ctx->regs.misc_3d_state_cntl_reg != a) { + r128FlushVertices(r128ctx); + r128ctx->regs.misc_3d_state_cntl_reg = a; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ALPHASTATE; + } +} + +static void r128DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 b = r128ctx->regs.misc_3d_state_cntl_reg; + + b &= ~(R128_ALPHA_BLEND_SRC_MASK | R128_ALPHA_BLEND_DST_MASK); + + switch (sfactor) { + case GL_ZERO: b |= R128_ALPHA_BLEND_SRC_ZERO; + break; + case GL_ONE: b |= R128_ALPHA_BLEND_SRC_ONE; + break; + case GL_DST_COLOR: b |= R128_ALPHA_BLEND_SRC_DESTCOLOR; + break; + case GL_ONE_MINUS_DST_COLOR: b |= R128_ALPHA_BLEND_SRC_INVDESTCOLOR; + break; + case GL_SRC_ALPHA: b |= R128_ALPHA_BLEND_SRC_SRCALPHA; + break; + case GL_ONE_MINUS_SRC_ALPHA: b |= R128_ALPHA_BLEND_SRC_INVSRCALPHA; + break; + case GL_DST_ALPHA: b |= R128_ALPHA_BLEND_SRC_DESTALPHA; + break; + case GL_ONE_MINUS_DST_ALPHA: b |= R128_ALPHA_BLEND_SRC_INVDESTALPHA; + break; + case GL_SRC_ALPHA_SATURATE: b |= R128_ALPHA_BLEND_SRC_SRCALPHASAT; + break; +#if 0 + /* FIXME: These are not supported directly by the Rage 128. + They could be emulated using something like the TexEnv + modes. */ + case GL_CONSTANT_COLOR: b |= 0; + break; + case GL_ONE_MINUS_CONSTANT_COLOR: b |= 0; + break; + case GL_CONSTANT_ALPHA: b |= 0; + break; + case GL_ONE_MINUS_CONSTANT_ALPHA: b |= 0; + break; +#endif + default: + /* ERROR!!! */ + return; + } + + switch (dfactor) { + case GL_ZERO: b |= R128_ALPHA_BLEND_DST_ZERO; + break; + case GL_ONE: b |= R128_ALPHA_BLEND_DST_ONE; + break; + case GL_SRC_COLOR: b |= R128_ALPHA_BLEND_DST_SRCCOLOR; + break; + case GL_ONE_MINUS_SRC_COLOR: b |= R128_ALPHA_BLEND_DST_INVSRCCOLOR; + break; + case GL_SRC_ALPHA: b |= R128_ALPHA_BLEND_DST_SRCALPHA; + break; + case GL_ONE_MINUS_SRC_ALPHA: b |= R128_ALPHA_BLEND_DST_INVSRCALPHA; + break; + case GL_DST_ALPHA: b |= R128_ALPHA_BLEND_DST_DESTALPHA; + break; + case GL_ONE_MINUS_DST_ALPHA: b |= R128_ALPHA_BLEND_DST_INVDESTALPHA; + break; +#if 0 + /* FIXME: These are not supported directly by the Rage 128. + They could be emulated using something like the TexEnv + modes. */ + case GL_CONSTANT_COLOR: b |= 0; + break; + case GL_ONE_MINUS_CONSTANT_COLOR: b |= 0; + break; + case GL_CONSTANT_ALPHA: b |= 0; + break; + case GL_ONE_MINUS_CONSTANT_ALPHA: b |= 0; + break; +#endif + default: + /* ERROR!!! */ + return; + } + + if (r128ctx->regs.misc_3d_state_cntl_reg != b) { + r128FlushVertices(r128ctx); + r128ctx->regs.misc_3d_state_cntl_reg = b; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ALPHASTATE; + } +} + +static void r128DDBlendFuncSeparate(GLcontext *ctx, GLenum sfactorRGB, + GLenum dfactorRGB, GLenum sfactorA, + GLenum dfactorA) +{ + if (sfactorRGB != sfactorA || dfactorRGB != dfactorA) { + /* ERROR!!! */ + return; + } + + r128DDBlendFunc(ctx, sfactorRGB, dfactorRGB); +} + +static void r128DDClearDepth(GLcontext *ctx, GLclampd d) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + switch (r128ctx->regs.z_sten_cntl_c & R128_Z_PIX_WIDTH_MASK) { + case R128_Z_PIX_WIDTH_16: r128ctx->ClearDepth = d * 0x0000ffff; break; + case R128_Z_PIX_WIDTH_24: r128ctx->ClearDepth = d * 0x00ffffff; break; + case R128_Z_PIX_WIDTH_32: r128ctx->ClearDepth = d * 0xffffffff; break; + default: return; + } +} + +static void r128DDCullFace(GLcontext *ctx, GLenum mode) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 f = r128ctx->regs.pm4_vc_fpu_setup; + + if (!ctx->Polygon.CullFlag) return; + + f &= ~(R128_BACKFACE_MASK | R128_FRONTFACE_MASK); + + switch (mode) { + case GL_FRONT: f |= R128_BACKFACE_SOLID; break; + case GL_BACK: f |= R128_FRONTFACE_SOLID; break; + case GL_FRONT_AND_BACK: break; + default: return; + } + + if (r128ctx->regs.pm4_vc_fpu_setup != f) { + r128FlushVertices(r128ctx); + r128ctx->regs.pm4_vc_fpu_setup = f; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_SETUPSTATE; + } +} + +static void r128DDFrontFace(GLcontext *ctx, GLenum mode) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 f = r128ctx->regs.pm4_vc_fpu_setup; + + f &= ~R128_FRONT_DIR_MASK; + + switch (mode) { + case GL_CW: f |= R128_FRONT_DIR_CW; break; + case GL_CCW: f |= R128_FRONT_DIR_CCW; break; + default: return; + } + + if (r128ctx->regs.pm4_vc_fpu_setup != f) { + r128FlushVertices(r128ctx); + r128ctx->regs.pm4_vc_fpu_setup = f; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_SETUPSTATE; + } +} + +static void r128DDDepthFunc(GLcontext *ctx, GLenum func) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 z = r128ctx->regs.z_sten_cntl_c; + + z &= ~R128_Z_TEST_MASK; + + switch (func) { + case GL_NEVER: z |= R128_Z_TEST_NEVER; break; + case GL_LESS: z |= R128_Z_TEST_LESS; break; + case GL_LEQUAL: z |= R128_Z_TEST_LESSEQUAL; break; + case GL_EQUAL: z |= R128_Z_TEST_EQUAL; break; + case GL_GEQUAL: z |= R128_Z_TEST_GREATEREQUAL; break; + case GL_GREATER: z |= R128_Z_TEST_GREATER; break; + case GL_NOTEQUAL: z |= R128_Z_TEST_NEQUAL; break; + case GL_ALWAYS: z |= R128_Z_TEST_ALWAYS; break; + default: return; + } + + if (r128ctx->regs.z_sten_cntl_c != z) { + r128FlushVertices(r128ctx); + r128ctx->regs.z_sten_cntl_c = z; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ZSTENSTATE; + } +} + +static void r128DDDepthMask(GLcontext *ctx, GLboolean flag) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 t = r128ctx->regs.tex_cntl_c; + + if (flag) t |= R128_Z_WRITE_ENABLE; + else t &= ~R128_Z_WRITE_ENABLE; + + if (r128ctx->regs.tex_cntl_c != t) { + r128FlushVertices(r128ctx); + r128ctx->regs.tex_cntl_c = t; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ENGINESTATE; + } +} + +static void r128DDLightModelfv(GLcontext *ctx, GLenum pname, + const GLfloat *param) +{ + if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) + { + r128ContextPtr r128ctx = R128_CONTEXT( ctx ); + CARD32 t = r128ctx->regs.tex_cntl_c; + + if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + t |= R128_SPEC_LIGHT_ENABLE; + else + t &= ~R128_SPEC_LIGHT_ENABLE; + + if (r128ctx->regs.tex_cntl_c != t) { + r128FlushVertices(r128ctx); + r128ctx->regs.tex_cntl_c = t; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ENGINESTATE; + } + } +} + + +static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 t = r128ctx->regs.tex_cntl_c; + CARD32 f = r128ctx->regs.pm4_vc_fpu_setup; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) { + fprintf(stderr, "r128DDEnable( %p, 0x%x = %s )\n", + ctx, cap, state ? "GL_TRUE" : "GL_FALSE"); + } + + switch (cap) { + case GL_ALPHA_TEST: + if (state) t |= R128_ALPHA_TEST_ENABLE; + else t &= ~R128_ALPHA_TEST_ENABLE; + break; + + case GL_AUTO_NORMAL: return; + + case GL_BLEND: + if (state) t |= R128_ALPHA_ENABLE; + else t &= ~R128_ALPHA_ENABLE; + break; + + case GL_CLIP_PLANE0: + case GL_CLIP_PLANE1: + case GL_CLIP_PLANE2: + case GL_CLIP_PLANE3: + case GL_CLIP_PLANE4: + case GL_CLIP_PLANE5: + case GL_COLOR_MATERIAL: return; + + case GL_CULL_FACE: + if (ctx->PB->primitive == GL_POLYGON) { + f &= ~(R128_BACKFACE_MASK | R128_FRONTFACE_MASK); + if (state) { + switch (ctx->Polygon.CullFaceMode) { + case GL_FRONT: f |= R128_BACKFACE_SOLID; break; + case GL_BACK: f |= R128_FRONTFACE_SOLID; break; + case GL_FRONT_AND_BACK: break; + default: return; + } + } else { + f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID; + } + } + break; + + case GL_DEPTH_TEST: + if (state) t |= R128_Z_ENABLE; + else t &= ~R128_Z_ENABLE; + break; + + case GL_DITHER: + if (state) t |= R128_DITHER_ENABLE; + else t &= ~R128_DITHER_ENABLE; + break; + + case GL_FOG: + if (state) t |= R128_FOG_ENABLE; + else t &= ~R128_FOG_ENABLE; + break; + + case GL_LIGHT0: + case GL_LIGHT1: + case GL_LIGHT2: + case GL_LIGHT3: + case GL_LIGHT4: + case GL_LIGHT5: + case GL_LIGHT6: + case GL_LIGHT7: + case GL_LIGHTING: + case GL_LINE_SMOOTH: + case GL_LINE_STIPPLE: + case GL_INDEX_LOGIC_OP: + case GL_COLOR_LOGIC_OP: + case GL_MAP1_COLOR_4: + case GL_MAP1_INDEX: + case GL_MAP1_NORMAL: + case GL_MAP1_TEXTURE_COORD_1: + case GL_MAP1_TEXTURE_COORD_2: + case GL_MAP1_TEXTURE_COORD_3: + case GL_MAP1_TEXTURE_COORD_4: + case GL_MAP1_VERTEX_3: + case GL_MAP1_VERTEX_4: + case GL_MAP2_COLOR_4: + case GL_MAP2_INDEX: + case GL_MAP2_NORMAL: + case GL_MAP2_TEXTURE_COORD_1: + case GL_MAP2_TEXTURE_COORD_2: + case GL_MAP2_TEXTURE_COORD_3: + case GL_MAP2_TEXTURE_COORD_4: + case GL_MAP2_VERTEX_3: + case GL_MAP2_VERTEX_4: + case GL_NORMALIZE: + case GL_POINT_SMOOTH: + case GL_POLYGON_SMOOTH: + case GL_POLYGON_STIPPLE: + case GL_POLYGON_OFFSET_POINT: + case GL_POLYGON_OFFSET_LINE: + case GL_POLYGON_OFFSET_FILL: + case GL_RESCALE_NORMAL_EXT: return; + + case GL_SCISSOR_TEST: + /* FIXME: Hook up the software scissor */ +#if 0 + r128ctx->Scissor = state; +#endif + break; + + case GL_SHARED_TEXTURE_PALETTE_EXT: + case GL_STENCIL_TEST: return; + + case GL_TEXTURE_1D: + case GL_TEXTURE_2D: + case GL_TEXTURE_3D: + /* This is handled in r128UpdateTex[01]State() */ + r128ctx->dirty |= R128_UPDATE_TEXSTATE; + break; + + case GL_TEXTURE_GEN_Q: + case GL_TEXTURE_GEN_R: + case GL_TEXTURE_GEN_S: + case GL_TEXTURE_GEN_T: return; + + /* Client state */ + case GL_VERTEX_ARRAY: + case GL_NORMAL_ARRAY: + case GL_COLOR_ARRAY: + case GL_INDEX_ARRAY: + case GL_TEXTURE_COORD_ARRAY: + case GL_EDGE_FLAG_ARRAY: return; + + default: return; + } + + if (r128ctx->regs.tex_cntl_c != t) { + r128FlushVertices(r128ctx); + r128ctx->regs.tex_cntl_c = t; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ENGINESTATE; + } + if (r128ctx->regs.pm4_vc_fpu_setup != f) { + r128FlushVertices(r128ctx); + r128ctx->regs.pm4_vc_fpu_setup = f; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_SETUPSTATE; + } + +} + +static void r128DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + GLubyte c[4]; + CARD32 col; + floatTOint fog; + GLenum mode; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) { + fprintf(stderr, "r128DDFogfv(%p, 0x%x)\n", ctx, pname); + } + + switch (pname) { + case GL_FOG_MODE: + mode = (GLenum)(GLint)*param; + if (r128ctx->FogMode != mode) { + r128FlushVertices(r128ctx); + r128ctx->FogMode = mode; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_FOGTABLE; + } + break; + + case GL_FOG_DENSITY: + fog.f = *param; + if (r128ctx->regs.fog_3d_table_density != fog.i) { + r128FlushVertices(r128ctx); + r128ctx->regs.fog_3d_table_density = fog.i; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_FOGSTATE; + } + break; + + case GL_FOG_START: + fog.f = *param; + if (r128ctx->regs.fog_3d_table_start != fog.i) { + r128FlushVertices(r128ctx); + r128ctx->regs.fog_3d_table_start = fog.i; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_FOGSTATE; + } + break; + + case GL_FOG_END: + fog.f = *param; + if (r128ctx->regs.fog_3d_table_end != fog.i) { + r128FlushVertices(r128ctx); + r128ctx->regs.fog_3d_table_end = fog.i; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_FOGSTATE; + } + break; + + case GL_FOG_COLOR: + FLOAT_RGBA_TO_UBYTE_RGBA(c, ctx->Fog.Color); + col = r128PackColor(32, c[0], c[1], c[2], c[3]); + if (r128ctx->regs.fog_color_c != col) { + r128FlushVertices(r128ctx); + r128ctx->regs.fog_color_c = col; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_FOGSTATE; + } + break; + + default: + return; + } +} + +static void r128DDScissor(GLcontext *ctx, + GLint x, GLint y, GLsizei w, GLsizei h) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + r128ctx->ScissorRect.x1 = x; + r128ctx->ScissorRect.y1 = r128ctx->driDrawable->h - (y + h); + r128ctx->ScissorRect.x2 = x + w; + r128ctx->ScissorRect.y2 = r128ctx->driDrawable->h - y; +} + +/* Initialize the driver's state functions */ +void r128DDInitStateFuncs(GLcontext *ctx) +{ + ctx->Driver.UpdateState = r128DDUpdateState; + + ctx->Driver.ClearIndex = NULL; + ctx->Driver.ClearColor = r128DDClearColor; + ctx->Driver.Index = NULL; + ctx->Driver.Color = r128DDColor; + ctx->Driver.SetDrawBuffer = r128DDSetDrawBuffer; + ctx->Driver.SetReadBuffer = r128DDSetReadBuffer; + + ctx->Driver.IndexMask = NULL; + ctx->Driver.ColorMask = r128DDColorMask; + ctx->Driver.LogicOp = NULL; + ctx->Driver.Dither = r128DDDither; + + ctx->Driver.NearFar = NULL; + + ctx->Driver.RenderStart = r128DDUpdateHWState; + ctx->Driver.RenderFinish = NULL; + ctx->Driver.RasterSetup = NULL; + + ctx->Driver.RenderVBClippedTab = NULL; + ctx->Driver.RenderVBCulledTab = NULL; + ctx->Driver.RenderVBRawTab = NULL; + + ctx->Driver.ReducedPrimitiveChange = r128DDReducedPrimitiveChange; + ctx->Driver.MultipassFunc = NULL; + + ctx->Driver.AlphaFunc = r128DDAlphaFunc; + ctx->Driver.BlendEquation = NULL; + ctx->Driver.BlendFunc = r128DDBlendFunc; + ctx->Driver.BlendFuncSeparate = r128DDBlendFuncSeparate; + ctx->Driver.ClearDepth = r128DDClearDepth; + ctx->Driver.CullFace = r128DDCullFace; + ctx->Driver.FrontFace = r128DDFrontFace; + ctx->Driver.DepthFunc = r128DDDepthFunc; + ctx->Driver.DepthMask = r128DDDepthMask; + ctx->Driver.DepthRange = NULL; + ctx->Driver.Enable = r128DDEnable; + ctx->Driver.Fogfv = r128DDFogfv; + ctx->Driver.Hint = NULL; + ctx->Driver.Lightfv = NULL; + ctx->Driver.LightModelfv = r128DDLightModelfv; + ctx->Driver.PolygonMode = NULL; + ctx->Driver.Scissor = r128DDScissor; + ctx->Driver.ShadeModel = NULL; + ctx->Driver.ClearStencil = NULL; + ctx->Driver.StencilFunc = NULL; + ctx->Driver.StencilMask = NULL; + ctx->Driver.StencilOp = NULL; + ctx->Driver.Viewport = NULL; +} + +/* Initialize the context's hardware state */ +void r128DDInitState(r128ContextPtr r128ctx) +{ + int dst_bpp, depth_bpp, pitch, i; + CARD32 depthClear; + + pitch = r128ctx->r128Screen->fbStride / r128ctx->r128Screen->bpp; + + switch (r128ctx->r128Screen->pixel_code) { + case 8: dst_bpp = R128_GMC_DST_8BPP_CI; break; + case 15: dst_bpp = R128_GMC_DST_15BPP; break; + case 16: dst_bpp = R128_GMC_DST_16BPP; break; + case 24: dst_bpp = R128_GMC_DST_24BPP; break; + case 32: dst_bpp = R128_GMC_DST_32BPP; break; + default: + fprintf(stderr, "Error: Unsupported pixel depth %d... exiting\n", + r128ctx->r128Screen->pixel_code); + exit(-1); + } + + /* FIXME: Figure out how to use 16bpp depth buffer in 32bpp mode */ + switch (r128ctx->glCtx->Visual->DepthBits) { + case 16: depthClear = 0x0000ffff; depth_bpp = R128_Z_PIX_WIDTH_16; break; + case 24: depthClear = 0x00ffffff; depth_bpp = R128_Z_PIX_WIDTH_24; break; + case 32: depthClear = 0xffffffff; depth_bpp = R128_Z_PIX_WIDTH_32; break; + default: + fprintf(stderr, "Error: Unsupported depth %d... exiting\n", + r128ctx->r128Screen->bpp); + exit(-1); + break; + } + + /* Precalculate the depth scale while we're here */ + switch (r128ctx->glCtx->Visual->DepthBits) { + case 16: r128ctx->depth_scale = 1.0 / 65536.0; break; + case 24: r128ctx->depth_scale = 1.0 / 16777216.0; break; + case 32: r128ctx->depth_scale = 1.0 / 4294967296.0; break; + default: r128ctx->depth_scale = 1.0 / 65536.0; break; + } + + r128ctx->dirty = R128_ALL_DIRTY; + r128ctx->dirty_context = R128_CTX_ALL_DIRTY; + + r128ctx->RenderIndex = R128_FALLBACK_BIT; + r128ctx->PointsFunc = NULL; + r128ctx->LineFunc = NULL; + r128ctx->TriangleFunc = NULL; + r128ctx->QuadFunc = NULL; + + r128ctx->IndirectTriangles = 0; + r128ctx->Fallback = 0; + + if (r128ctx->glCtx->Visual->DBflag) { + r128ctx->drawX = r128ctx->r128Screen->backX; + r128ctx->drawY = r128ctx->r128Screen->backY; + r128ctx->readX = r128ctx->r128Screen->backX; + r128ctx->readY = r128ctx->r128Screen->backY; + } else { + r128ctx->drawX = r128ctx->r128Screen->fbX; + r128ctx->drawY = r128ctx->r128Screen->fbY; + r128ctx->readX = r128ctx->r128Screen->fbX; + r128ctx->readY = r128ctx->r128Screen->fbY; + } + + r128ctx->ClearColor = 0x00000000; + r128ctx->ClearDepth = depthClear; + + r128ctx->regs.scale_3d_cntl = + R128_SCALE_DITHER_TABLE | + R128_TEX_CACHE_SIZE_FULL | + R128_DITHER_INIT_RESET | + R128_SCALE_3D_TEXMAP_SHADE | + R128_SCALE_PIX_REPLICATE | + /* R128_TEX_CACHE_SPLIT | */ + R128_ALPHA_COMB_ADD_CLAMP | + R128_FOG_TABLE | + R128_ALPHA_BLEND_SRC_ONE | + R128_ALPHA_BLEND_DST_ZERO | + R128_ALPHA_TEST_ALWAYS | + R128_COMPOSITE_SHADOW_CMP_EQUAL | + R128_TEX_MAP_ALPHA_IN_TEXTURE | + R128_TEX_CACHE_LINE_SIZE_8QW; + + r128ctx->regs.dst_pitch_offset_c = pitch << R128_PITCH_SHIFT; + + r128ctx->regs.dp_gui_master_cntl = + R128_GMC_DST_PITCH_OFFSET_CNTL | + R128_GMC_DST_CLIPPING | + R128_GMC_BRUSH_SOLID_COLOR | + dst_bpp | + R128_GMC_SRC_DATATYPE_COLOR | + R128_GMC_BYTE_MSB_TO_LSB | + R128_GMC_CONVERSION_TEMP_6500 | + R128_ROP3_S | + R128_DP_SRC_SOURCE_MEMORY | + R128_GMC_3D_FCN_EN | + R128_GMC_CLR_CMP_CNTL_DIS | + R128_AUX_CLIP_DIS | + R128_GMC_WR_MSK_DIS; + + r128ctx->regs.sc_top_left_c = 0x00000000; + r128ctx->regs.sc_bottom_right_c = 0x1fff1fff; + + r128ctx->regs.aux_sc_cntl = 0x00000000; + + r128ctx->regs.aux1_sc_left = 0x00000000; + r128ctx->regs.aux1_sc_right = 0x00001fff; + r128ctx->regs.aux1_sc_top = 0x00000000; + r128ctx->regs.aux1_sc_bottom = 0x00001fff; + + r128ctx->regs.aux2_sc_left = 0x00000000; + r128ctx->regs.aux2_sc_right = 0x00001fff; + r128ctx->regs.aux2_sc_top = 0x00000000; + r128ctx->regs.aux2_sc_bottom = 0x00001fff; + + r128ctx->regs.aux3_sc_left = 0x00000000; + r128ctx->regs.aux3_sc_right = 0x00001fff; + r128ctx->regs.aux3_sc_top = 0x00000000; + r128ctx->regs.aux3_sc_bottom = 0x00001fff; + + r128ctx->regs.z_offset_c = (r128ctx->r128Screen->depthX * + (r128ctx->r128Screen->bpp/8) + + r128ctx->r128Screen->depthY * + r128ctx->r128Screen->fbStride); + r128ctx->regs.z_pitch_c = pitch; + + r128ctx->regs.z_sten_cntl_c = + depth_bpp | + R128_Z_TEST_LESS | + R128_STENCIL_TEST_ALWAYS | + R128_STENCIL_S_FAIL_KEEP | + R128_STENCIL_ZPASS_KEEP | + R128_STENCIL_ZFAIL_KEEP; + + r128ctx->regs.tex_cntl_c = + R128_Z_WRITE_ENABLE | + R128_SHADE_ENABLE | + R128_DITHER_ENABLE | + R128_ALPHA_IN_TEX_COMPLETE_A | + R128_LIGHT_DIS | + R128_ALPHA_LIGHT_DIS | + R128_TEX_CACHE_FLUSH | + (0x0f << R128_LOD_BIAS_SHIFT); + + r128ctx->regs.misc_3d_state_cntl_reg = + R128_MISC_SCALE_3D_TEXMAP_SHADE | + R128_MISC_SCALE_PIX_REPLICATE | + R128_ALPHA_COMB_ADD_CLAMP | + R128_FOG_TABLE | + R128_ALPHA_BLEND_SRC_ONE | + R128_ALPHA_BLEND_DST_ZERO | + R128_ALPHA_TEST_ALWAYS; + + r128ctx->regs.texture_clr_cmp_clr_c = 0x00000000; + r128ctx->regs.texture_clr_cmp_msk_c = 0xffffffff; + + r128ctx->regs.prim_tex_cntl_c = + R128_MIN_BLEND_NEAREST | + R128_MAG_BLEND_NEAREST | + R128_MIP_MAP_DISABLE | + R128_TEX_CLAMP_S_WRAP | + R128_TEX_CLAMP_T_WRAP; + + r128ctx->regs.prim_texture_combine_cntl_c = + R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA; + + r128ctx->regs.tex_size_pitch_c = + (0 << R128_TEX_PITCH_SHIFT) | + (0 << R128_TEX_SIZE_SHIFT) | + (0 << R128_TEX_HEIGHT_SHIFT) | + (0 << R128_TEX_MIN_SIZE_SHIFT) | + (0 << R128_SEC_TEX_PITCH_SHIFT) | + (0 << R128_SEC_TEX_SIZE_SHIFT) | + (0 << R128_SEC_TEX_HEIGHT_SHIFT) | + (0 << R128_SEC_TEX_MIN_SIZE_SHIFT); + + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.prim_tex_offset[i] = 0x00000000; + + r128ctx->regs.sec_tex_cntl_c = + R128_SEC_SELECT_PRIM_ST; + + r128ctx->regs.sec_tex_combine_cntl_c = + R128_COMB_DIS | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_DIS | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA; + + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.sec_tex_offset[i] = 0x00000000; + + r128ctx->regs.constant_color_c = 0x00ffffff; + r128ctx->regs.prim_texture_border_color_c = 0x00ffffff; + r128ctx->regs.sec_texture_border_color_c = 0x00ffffff; + r128ctx->regs.sten_ref_mask_c = 0xffff0000; + r128ctx->regs.plane_3d_mask_c = 0xffffffff; + + r128ctx->regs.setup_cntl = + R128_COLOR_GOURAUD | + R128_PRIM_TYPE_TRI | +#if 1 + /* FIXME: Let r128 multiply? */ + R128_TEXTURE_ST_MULT_W | +#else + /* FIXME: Or, pre multiply? */ + R128_TEXTURE_ST_DIRECT | +#endif + R128_STARTING_VERTEX_1 | + R128_ENDING_VERTEX_3 | + R128_SU_POLY_LINE_NOT_LAST | + R128_SUB_PIX_4BITS; + + r128ctx->regs.pm4_vc_fpu_setup = + R128_FRONT_DIR_CCW | + R128_BACKFACE_SOLID | + R128_FRONTFACE_SOLID | + R128_FPU_COLOR_GOURAUD | + R128_FPU_SUB_PIX_4BITS | + R128_FPU_MODE_3D | + R128_TRAP_BITS_DISABLE | + R128_XFACTOR_2 | + R128_YFACTOR_2 | + R128_FLAT_SHADE_VERTEX_OGL | + R128_FPU_ROUND_TRUNCATE | + R128_WM_SEL_8DW; + + r128ctx->FogMode = GL_EXP; + r128ctx->regs.fog_color_c = 0x00808080; + r128ctx->regs.fog_3d_table_start = 0x00000000; + r128ctx->regs.fog_3d_table_end = 0xffffffff; + r128ctx->regs.fog_3d_table_density = 0x00000000; + + r128ctx->regs.window_xy_offset = 0x00000000; + + r128ctx->regs.dp_write_mask = 0xffffffff; + + r128ctx->regs.pc_gui_ctlstat = R128_PC_FLUSH_GUI; + + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; +} + +/* Upload the fog table for the current fog mode */ +static void r128UploadFogTable(r128ContextPtr r128ctx) +{ + int i; + + R128CCE0(R128_CCE_PACKET0, R128_FOG_TABLE_INDEX, 0); + R128CCE(0x00000000); + + R128CCE0(R128_CCE_PACKET0_ONE_REG_WR, R128_FOG_TABLE_DATA, 255); + + + if (0) + fprintf(stderr, "uploading fog table for %s\n", + gl_lookup_enum_by_nr(r128ctx->FogMode)); + + + /* KW: I'm not sure we're doing enough here - shouldn't density + * play a role in calculating the exp and exp2 tables -- is the + * card really doing exponent calculations of its own? Need to + * see the spec... + */ + switch (r128ctx->FogMode) { + case GL_LINEAR: + for (i = 0; i < 256; i++) { + R128CCE(255 - i); + } + break; + case GL_EXP: + for (i = 0; i < 256; i++) { + float arg = (255 - i)/255.0; + float exparg = (exp(arg) - 1) / (M_E - 1); /* range [0,1] */ + int result; + FLOAT_COLOR_TO_UBYTE_COLOR(result, exparg); + R128CCE(result); + } + break; + case GL_EXP2: + for (i = 0; i < 256; i++) { + float arg = (255 - i)/255.0; + float exparg = (exp(arg*arg) - 1) / (M_E - 1); /* range [0,1] */ + int result; + FLOAT_COLOR_TO_UBYTE_COLOR(result, exparg); + R128CCE(result); + } + break; + } +} + +/* Load the current context's state into the hardware */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128LoadContext(r128ContextPtr r128ctx) +{ + int i; + int tex_size_pitch_done = GL_FALSE; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) { + fprintf(stderr, "r128LoadContext(%p)\n", r128ctx->glCtx); + } + +#if 0 + r128ctx->dirty_context = R128_CTX_ALL_DIRTY; +#endif + +#if 1 + /* FIXME: Why do these need to be updated even when they don't change? */ + r128ctx->dirty_context |= (R128_CTX_MISC | + R128_CTX_ENGINESTATE | + R128_CTX_ALPHASTATE); +#endif + +#if 1 + /* FIXME: Is this _really_ needed? */ + if (r128ctx->dirty_context) + if (!R128CCE_USE_RING_BUFFER(r128ctx->r128Screen->CCEMode)) + r128WaitForIdleLocked(r128ctx); +#endif + + if (r128ctx->dirty_context & R128_CTX_MISC) { + R128CCE1(R128_CCE_PACKET1, R128_SCALE_3D_CNTL, R128_DP_WRITE_MASK); + R128CCE(r128ctx->regs.scale_3d_cntl); + R128CCE(r128ctx->regs.dp_write_mask); + + R128CCE0(R128_CCE_PACKET0, R128_DST_PITCH_OFFSET_C, 1); + R128CCE(r128ctx->regs.dst_pitch_offset_c); + R128CCE(r128ctx->regs.dp_gui_master_cntl); + + R128CCE0(R128_CCE_PACKET0, R128_TEXTURE_CLR_CMP_CLR_C, 1); + R128CCE(r128ctx->regs.texture_clr_cmp_clr_c); + R128CCE(r128ctx->regs.texture_clr_cmp_msk_c); + + R128CCE0(R128_CCE_PACKET0, R128_STEN_REF_MASK_C, 1); + R128CCE(r128ctx->regs.sten_ref_mask_c); + R128CCE(r128ctx->regs.plane_3d_mask_c); + } + + if (r128ctx->dirty_context & R128_CTX_ENGINESTATE) { + R128CCE0(R128_CCE_PACKET0, R128_TEX_CNTL_C, 0); + R128CCE(r128ctx->regs.tex_cntl_c); + } + + if (r128ctx->dirty_context & R128_CTX_TEX0STATE) { + R128CCE0(R128_CCE_PACKET0, R128_PRIM_TEX_CNTL_C, 2+R128_TEX_MAXLEVELS); + R128CCE(r128ctx->regs.prim_tex_cntl_c); + R128CCE(r128ctx->regs.prim_texture_combine_cntl_c); + R128CCE(r128ctx->regs.tex_size_pitch_c); + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + R128CCE(r128ctx->regs.prim_tex_offset[i]); + + R128CCE0(R128_CCE_PACKET0, R128_PRIM_TEXTURE_BORDER_COLOR_C, 0); + R128CCE(r128ctx->regs.prim_texture_border_color_c); + + tex_size_pitch_done = GL_TRUE; + } + + if (r128ctx->dirty_context & R128_CTX_TEX1STATE) { + if (!tex_size_pitch_done) { + R128CCE0(R128_CCE_PACKET0, R128_TEX_SIZE_PITCH_C, 0); + R128CCE(r128ctx->regs.tex_size_pitch_c); + } + + R128CCE0(R128_CCE_PACKET0, R128_SEC_TEX_CNTL_C, 1+R128_TEX_MAXLEVELS); + R128CCE(r128ctx->regs.sec_tex_cntl_c); + R128CCE(r128ctx->regs.sec_tex_combine_cntl_c); + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + R128CCE(r128ctx->regs.sec_tex_offset[i]); + + R128CCE0(R128_CCE_PACKET0, R128_SEC_TEXTURE_BORDER_COLOR_C, 0); + R128CCE(r128ctx->regs.sec_texture_border_color_c); + } + + if (r128ctx->dirty_context & R128_CTX_TEXENVSTATE) { + R128CCE0(R128_CCE_PACKET0, R128_CONSTANT_COLOR_C, 0); + R128CCE(r128ctx->regs.constant_color_c); + } + + if (r128ctx->dirty_context & R128_CTX_FOGSTATE) { + R128CCE0(R128_CCE_PACKET0, R128_FOG_3D_TABLE_START, 1); + R128CCE(r128ctx->regs.fog_3d_table_start); + R128CCE(r128ctx->regs.fog_3d_table_end); + + R128CCE1(R128_CCE_PACKET1, + R128_FOG_COLOR_C, R128_FOG_3D_TABLE_DENSITY); + R128CCE(r128ctx->regs.fog_color_c); + R128CCE(r128ctx->regs.fog_3d_table_density); + } + + if (r128ctx->dirty_context & R128_CTX_FOGTABLE) { + r128UploadFogTable(r128ctx); + } + + if (r128ctx->dirty_context & R128_CTX_ZSTENSTATE) { + R128CCE0(R128_CCE_PACKET0, R128_Z_STEN_CNTL_C, 0); + R128CCE(r128ctx->regs.z_sten_cntl_c); + } + + if (r128ctx->dirty_context & R128_CTX_SCISSORS) { + R128CCE0(R128_CCE_PACKET0, R128_SC_TOP_LEFT_C, 1); + R128CCE(r128ctx->regs.sc_top_left_c); + R128CCE(r128ctx->regs.sc_bottom_right_c); + } + + if (r128ctx->dirty_context & (R128_CTX_ALPHASTATE | + R128_CTX_FOGSTATE)) { + R128CCE0(R128_CCE_PACKET0, R128_MISC_3D_STATE_CNTL_REG, 0); + R128CCE(r128ctx->regs.misc_3d_state_cntl_reg); + } + + if (r128ctx->dirty_context & R128_CTX_SETUPSTATE) { + R128CCE1(R128_CCE_PACKET1, R128_SETUP_CNTL, R128_PM4_VC_FPU_SETUP); + R128CCE(r128ctx->regs.setup_cntl); + R128CCE(r128ctx->regs.pm4_vc_fpu_setup); + } + + if (r128ctx->dirty_context & R128_CTX_WIN_Z_POS) { + R128CCE0(R128_CCE_PACKET0, R128_WINDOW_XY_OFFSET, 0); + R128CCE(r128ctx->regs.window_xy_offset); + + R128CCE0(R128_CCE_PACKET0, R128_Z_OFFSET_C, 1); + R128CCE(r128ctx->regs.z_offset_c); + R128CCE(r128ctx->regs.z_pitch_c); + } + +#if 0 + if (r128ctx->dirty_context & R128_CTX_FLUSH_PIX_CACHE) { + R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0); + R128CCE(r128ctx->regs.pc_gui_ctlstat); + } +#endif + + R128CCE_SUBMIT_PACKET(); + + /* Turn off the texture cache flushing */ + r128ctx->regs.tex_cntl_c &= ~R128_TEX_CACHE_FLUSH; + + /* Turn off the pixel cache flushing */ + r128ctx->regs.pc_gui_ctlstat &= ~R128_PC_FLUSH_ALL; + + r128ctx->dirty_context = R128_CTX_CLEAN; +} + +/* Set the hardware clip rects for drawing to the current color buffer */ +/* NOTE: This function is only called while holding the hardware lock */ +void r128SetClipRects(r128ContextPtr r128ctx, + XF86DRIClipRectPtr pc, int nc) +{ + if (!pc) return; + + /* Clear any previous auxiliary scissors */ + r128ctx->regs.aux_sc_cntl = 0x00000000; + + switch (nc) { + case 3: + R128CCE0(R128_CCE_PACKET0, R128_AUX3_SC_LEFT, 3); + R128CCE(pc[2].x1 + r128ctx->drawX); + R128CCE(pc[2].x2-1 + r128ctx->drawX); + R128CCE(pc[2].y1 + r128ctx->drawY); + R128CCE(pc[2].y2-1 + r128ctx->drawY); + + r128ctx->regs.aux_sc_cntl |= R128_AUX3_SC_EN | R128_AUX3_SC_MODE_OR; + + case 2: + R128CCE0(R128_CCE_PACKET0, R128_AUX2_SC_LEFT, 3); + R128CCE(pc[1].x1 + r128ctx->drawX); + R128CCE(pc[1].x2-1 + r128ctx->drawX); + R128CCE(pc[1].y1 + r128ctx->drawY); + R128CCE(pc[1].y2-1 + r128ctx->drawY); + + r128ctx->regs.aux_sc_cntl |= R128_AUX2_SC_EN | R128_AUX2_SC_MODE_OR; + + case 1: + R128CCE0(R128_CCE_PACKET0, R128_AUX1_SC_LEFT, 3); + R128CCE(pc[0].x1 + r128ctx->drawX); + R128CCE(pc[0].x2-1 + r128ctx->drawX); + R128CCE(pc[0].y1 + r128ctx->drawY); + R128CCE(pc[0].y2-1 + r128ctx->drawY); + + r128ctx->regs.aux_sc_cntl |= R128_AUX1_SC_EN | R128_AUX1_SC_MODE_OR; + break; + + default: + return; + } + + R128CCE0(R128_CCE_PACKET0, R128_AUX_SC_CNTL, 0); + R128CCE(r128ctx->regs.aux_sc_cntl); + + R128CCE_SUBMIT_PACKET(); +} + +/* Update the driver's notion of the window position */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128UpdateWindowPosition(r128ContextPtr r128ctx) +{ + int x = r128ctx->driDrawable->x + r128ctx->drawX; + int y = r128ctx->driDrawable->y + r128ctx->drawY; + +#if 0 + /* FIXME: Is this _really_ needed? */ + R128CCE_FLUSH_VB(r128ctx); +#endif + r128ctx->regs.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) | + (x << R128_WINDOW_X_SHIFT)); + + /* Recalculate the Z buffer offset since we might be drawing to the + back buffer and window_xy_offset affects both color buffer and + depth drawing */ + r128ctx->regs.z_offset_c = ((r128ctx->r128Screen->depthX - + r128ctx->drawX) * + (r128ctx->r128Screen->bpp/8) + + (r128ctx->r128Screen->depthY - + r128ctx->drawY) * + r128ctx->r128Screen->fbStride); + + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_WIN_Z_POS; +} + +/* Update the hardware state */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128UpdateHWStateLocked(r128ContextPtr r128ctx) +{ + if (r128ctx->dirty & R128_REQUIRE_QUIESCENCE) + r128WaitForIdleLocked(r128ctx); + + /* Update any state that might have changed recently */ + + /* Update the clip rects */ + if (r128ctx->dirty & R128_UPDATE_WINPOS) + r128UpdateWindowPosition(r128ctx); + + /* Update texture state and then upload the images */ + /* Note: Texture images can only be updated after the state has been set */ + if (r128ctx->dirty & R128_UPDATE_TEXSTATE) + r128UpdateTextureState(r128ctx); + if (r128ctx->dirty & R128_UPDATE_TEX0IMAGES) + r128UploadTexImages(r128ctx, r128ctx->CurrentTexObj[0]); + if (r128ctx->dirty & R128_UPDATE_TEX1IMAGES) + r128UploadTexImages(r128ctx, r128ctx->CurrentTexObj[1]); + + /* Load the state into the hardware */ + /* Note: This must be done after all other state has been set */ + if (r128ctx->dirty & R128_UPDATE_CONTEXT) + r128LoadContext(r128ctx); + + r128ctx->dirty = R128_CLEAN; +} + +/* Update the hardware state */ +void r128UpdateHWState(r128ContextPtr r128ctx) +{ + LOCK_HARDWARE(r128ctx); + r128UpdateHWStateLocked(r128ctx); + UNLOCK_HARDWARE(r128ctx); +} + +/* Update the driver's state */ +/* NOTE: This function is only called while holding the hardware lock */ +void r128UpdateState(r128ContextPtr r128ctx, int winMoved) +{ + R128SAREAPrivPtr sarea = r128ctx->r128Screen->SAREA; + int i; + + if (sarea->ctxOwner != r128ctx->driContext->hHWContext) { + sarea->ctxOwner = r128ctx->driContext->hHWContext; + r128ctx->dirty_context = R128_CTX_ALL_DIRTY; + r128LoadContext(r128ctx); + } + + for (i = 0; i < r128ctx->r128Screen->NRTexHeaps; i++) + r128AgeTextures(r128ctx, i); + + if (winMoved) r128ctx->dirty |= R128_UPDATE_WINPOS; +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_swap.c b/xc/lib/GL/mesa/src/drv/r128/r128_swap.c new file mode 100644 index 000000000..d6467970e --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_swap.c @@ -0,0 +1,133 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_reg.h" +#include "r128_cce.h" +#include "r128_state.h" +#include "r128_vb.h" +#include "r128_swap.h" + +static void delay(void) { + /* stop the compiler from optimizing our spin loop away */ +} + +/* Copy the back color buffer to the front color buffer */ +void r128SwapBuffers(r128ContextPtr r128ctx) +{ + unsigned char *R128MMIO = r128ctx->r128Screen->mmio; + __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; + int nc; + XF86DRIClipRectPtr c; + int dst_bpp; + CARD32 swapAge; + int i, to = 0; + + switch (r128ctx->r128Screen->bpp) { + case 8: + dst_bpp = R128_GMC_DST_8BPP_CI; + break; + case 16: + if (r128ctx->r128Screen->depth == 15) dst_bpp = R128_GMC_DST_15BPP; + else dst_bpp = R128_GMC_DST_16BPP; + break; + case 24: + dst_bpp = R128_GMC_DST_24BPP; + break; + case 32: + default: + dst_bpp = R128_GMC_DST_32BPP; + break; + } + + LOCK_HARDWARE(r128ctx); + + /* Flush any outstanding vertex buffers */ + r128FlushVerticesLocked(r128ctx); + + /* Throttle the frame rate -- only allow one pending swap buffers + request at a time */ + while ((r128ctx->lastSwapAge > (swapAge = INREG(R128_SWAP_AGE_REG))) && + (to++ < r128ctx->CCEtimeout)) { + /* Don't just sit here hammering the register */ + for (i = 0; i < 1000; i++) delay(); + } + + /* Init the clip rects here in case they changed during the + LOCK_HARDWARE macro */ + c = dPriv->pClipRects; + nc = dPriv->numClipRects; + + /* Cycle through the clip rects */ + while (nc--) { + int fx = c[nc].x1; + int fy = c[nc].y1; + int fw = c[nc].x2 - fx; + int fh = c[nc].y2 - fy; + int bx = fx + r128ctx->r128Screen->backX; + int by = fy + r128ctx->r128Screen->backY; + + fx += r128ctx->r128Screen->fbX; + fy += r128ctx->r128Screen->fbY; + + R128CCE3(R128_CCE_PACKET3_CNTL_BITBLT_MULTI, 3); + R128CCE(R128_GMC_BRUSH_NONE + | R128_GMC_SRC_DATATYPE_COLOR + | R128_DP_SRC_SOURCE_MEMORY + | dst_bpp + | R128_ROP3_S); + R128CCE((bx << 16) | by); + R128CCE((fx << 16) | fy); + R128CCE((fw << 16) | fh); + } + + ++swapAge; + R128CCE0(R128_CCE_PACKET0, R128_SWAP_AGE_REG, 0); + R128CCE(swapAge); + r128ctx->lastSwapAge = swapAge; + + r128ctx->dirty |= R128_UPDATE_CONTEXT; +/* r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; */ + r128ctx->dirty_context |= (R128_CTX_MISC | + R128_CTX_ENGINESTATE | + R128_CTX_ALPHASTATE); + + R128CCE_SUBMIT_PACKET(); + + UNLOCK_HARDWARE(r128ctx); +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c new file mode 100644 index 000000000..51f282462 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c @@ -0,0 +1,1860 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * Gareth Hughes <gareth@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_state.h" +#include "r128_reg.h" +#include "r128_cce.h" +#include "r128_vb.h" +#include "r128_tex.h" + +#include "mmath.h" +#include "simple_list.h" + +static void r128SetTexWrap(r128TexObjPtr t, GLenum srwap, GLenum twrap); +static void r128SetTexFilter(r128TexObjPtr t, GLenum minf, GLenum magf); +static void r128SetTexBorderColor(r128TexObjPtr t, GLubyte c[4]); + +/* Allocate and initialize hardware state associated with texture `t' */ +/* NOTE: This function is only called while holding the hardware lock */ +static r128TexObjPtr r128CreateTexObj(r128ContextPtr r128ctx, + struct gl_texture_object *tObj) +{ + r128TexObjPtr t; + struct gl_texture_image *image; + int log2Pitch, log2Height, log2Size, log2MinSize; + int totalSize; + int i; + + image = tObj->Image[0]; + if (!image) return NULL; /* ERROR!!! */ + + t = (r128TexObjPtr)calloc(1,sizeof(*t)); + if (!t) return NULL; /* ERROR!!! */ + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) + fprintf(stderr, "r128CreateTexObj(%p)\n", tObj); + + switch (image->Format) { + case GL_RGBA: + case GL_ALPHA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + if (r128ctx->r128Screen->bpp == 32) { + t->texelBytes = 4; + t->textureFormat = R128_DATATYPE_ARGB8888; + } else { + t->texelBytes = 2; + t->textureFormat = R128_DATATYPE_ARGB4444; + } + break; + + case GL_RGB: + if (r128ctx->r128Screen->bpp == 32) { + t->texelBytes = 4; + t->textureFormat = R128_DATATYPE_ARGB8888; + } else { + t->texelBytes = 2; + t->textureFormat = R128_DATATYPE_RGB565; + } + break; + + case GL_LUMINANCE: + if (r128ctx->r128Screen->bpp == 32) { + t->texelBytes = 4; + t->textureFormat = R128_DATATYPE_ARGB8888; + } else { + t->texelBytes = 2; + /* Use this to get true greys */ + t->textureFormat = R128_DATATYPE_ARGB1555; + } + break; + + case GL_COLOR_INDEX: + t->texelBytes = 1; + t->textureFormat = R128_DATATYPE_CI8; + break; + + default: + /* ERROR!!! */ + fprintf(stderr, "r128CreateTexObj: bad image->Format\n"); + free(t); + return NULL; + } + + /* Calculate dimensions in log domain */ + for (i = 1, log2Height = 0; i < image->Height; i *= 2) log2Height++; + for (i = 1, log2Pitch = 0; i < image->Width; i *= 2) log2Pitch++; + if (image->Width > image->Height) log2Size = log2Pitch; + else log2Size = log2Height; + + t->dirty_images = 0; + + /* Calculate mipmap offsets and dimensions */ + totalSize = 0; + for (i = 0; i <= log2Size && tObj->Image[i]; i++) { + t->image[i].offset = totalSize; + t->image[i].width = tObj->Image[i]->Width; + t->image[i].height = tObj->Image[i]->Height; + t->dirty_images |= 1 << i; + totalSize += (tObj->Image[i]->Height * + tObj->Image[i]->Width * + t->texelBytes); + + /* Offsets must be 32-byte aligned for host data blits */ + totalSize = (totalSize + 31) & ~31; + } + log2MinSize = log2Size - i + 1; + + t->totalSize = totalSize; + t->internFormat = image->IntFormat; + + t->bound = 0; + t->heap = 0; /* This is set in r128UploadTexImages */ + t->tObj = tObj; + + t->memBlock = NULL; + t->bufAddr = NULL; + + t->regs.tex_cntl = t->textureFormat; + t->regs.size_pitch = ((log2Pitch << R128_TEX_PITCH_SHIFT) | + (log2Size << R128_TEX_SIZE_SHIFT) | + (log2Height << R128_TEX_HEIGHT_SHIFT) | + (log2MinSize << R128_TEX_MIN_SIZE_SHIFT)); + t->regs.border_color = 0x00000000; + + if (log2MinSize == log2Size || + log2MinSize != 0) + t->regs.tex_cntl |= R128_MIP_MAP_DISABLE; + + r128SetTexWrap(t, tObj->WrapS, tObj->WrapT); + r128SetTexFilter(t, tObj->MinFilter, tObj->MagFilter); + r128SetTexBorderColor(t, tObj->BorderColor); + + tObj->DriverData = t; + + make_empty_list(t); + + return t; +} + +/* Destroy hardware state associated with texture `t' */ +/* NOTE: This function can be called while holding the hardware lock and + while not holding the lock*/ +void r128DestroyTexObj(r128ContextPtr r128ctx, r128TexObjPtr t) +{ + if (!t) return; + + if (t->memBlock) { + mmFreeMem(t->memBlock); + t->memBlock = NULL; + } + + if (t->tObj) t->tObj->DriverData = NULL; + if (t->bound) r128ctx->CurrentTexObj[t->bound-1] = NULL; + + remove_from_list(t); + free(t); +} + +/* Keep track of swapped out texture objects */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128SwapOutTexObj(r128ContextPtr r128ctx, r128TexObjPtr t) +{ + if (t->memBlock) { + mmFreeMem(t->memBlock); + t->memBlock = NULL; + } + + t->dirty_images = ~0; + move_to_tail(&r128ctx->SwappedOut, t); +} + +/* Print out debugging information about texture LRU */ +void r128PrintLocalLRU(r128ContextPtr r128ctx, int heap) +{ + r128TexObjPtr t; + int sz = 1 << (r128ctx->r128Screen->log2TexGran[heap]); + + foreach(t, &r128ctx->TexObjList[heap]) { + if (!t->tObj) { + fprintf(stderr, "Placeholder %d at 0x%x sz 0x%x\n", + t->memBlock->ofs / sz, + t->memBlock->ofs, + t->memBlock->size); + } else { + fprintf(stderr, "Texture (bound %d) at 0x%x sz 0x%x\n", + t->bound, + t->memBlock->ofs, + t->memBlock->size); + } + } +} + +void r128PrintGlobalLRU(r128ContextPtr r128ctx, int heap) +{ + R128TexRegion *list = r128ctx->r128Screen->SAREA->texList[heap]; + int i, j; + + for (i = 0, j = R128_NR_TEX_REGIONS ; i < R128_NR_TEX_REGIONS ; i++) { + fprintf(stderr, "list[%d] age %d next %d prev %d\n", + j, list[j].age, list[j].next, list[j].prev); + j = list[j].next; + if (j == R128_NR_TEX_REGIONS) break; + } + + if (j != R128_NR_TEX_REGIONS) { + fprintf(stderr, "Loop detected in global LRU\n"); + } +} + +/* Reset the global texture LRU */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128ResetGlobalLRU(r128ContextPtr r128ctx, int heap) +{ + R128TexRegion *list = r128ctx->r128Screen->SAREA->texList[heap]; + int log2sz = 1 << r128ctx->r128Screen->log2TexGran[heap]; + int i; + + /* + * (Re)initialize the global circular LRU list. The last element in + * the array (R128_NR_TEX_REGIONS) is the sentinal. Keeping it at + * the end of the array allows it to be addressed rationally when + * looking up objects at a particular location in texture memory. + */ + + for (i = 0; (i+1) * log2sz <= r128ctx->r128Screen->texSize[heap]; i++) { + list[i].prev = i-1; + list[i].next = i+1; + list[i].age = 0; + } + + i--; + list[0].prev = R128_NR_TEX_REGIONS; + list[i].prev = i-1; + list[i].next = R128_NR_TEX_REGIONS; + list[R128_NR_TEX_REGIONS].prev = i; + list[R128_NR_TEX_REGIONS].next = 0; + r128ctx->r128Screen->SAREA->texAge[heap] = 0; +} + +/* Update the local and glock texture LRUs */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128UpdateTexLRU(r128ContextPtr r128ctx, r128TexObjPtr t) +{ + int heap = t->heap; + R128TexRegion *list = r128ctx->r128Screen->SAREA->texList[heap]; + int log2sz = r128ctx->r128Screen->log2TexGran[heap]; + + int start = t->memBlock->ofs >> log2sz; + int end = (t->memBlock->ofs + t->memBlock->size-1) >> log2sz; + int i; + + r128ctx->lastTexAge[heap] = ++r128ctx->r128Screen->SAREA->texAge[heap]; + + /* Update our local LRU */ + move_to_head(&r128ctx->TexObjList[heap], t); + + /* Update the global LRU */ + for (i = start ; i <= end ; i++) { + list[i].in_use = 1; + list[i].age = r128ctx->lastTexAge[heap]; + + /* remove_from_list(i) */ + list[(CARD32)list[i].next].prev = list[i].prev; + list[(CARD32)list[i].prev].next = list[i].next; + + /* insert_at_head(list, i) */ + list[i].prev = R128_NR_TEX_REGIONS; + list[i].next = list[R128_NR_TEX_REGIONS].next; + list[(CARD32)list[R128_NR_TEX_REGIONS].next].prev = i; + list[R128_NR_TEX_REGIONS].next = i; + } +} + +/* Update our notion of what textures have been changed since we last + held the lock. This pertains to both our local textures and the + textures belonging to other clients. Keep track of other client's + textures by pushing a placeholder texture onto the LRU list -- these + are denoted by (tObj == NULL). */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128TexturesGone(r128ContextPtr r128ctx, int heap, + int offset, int size, int in_use) +{ + r128TexObjPtr t, tmp; + + foreach_s (t, tmp, &r128ctx->TexObjList[heap]) { + if (t->memBlock->ofs >= offset + size || + t->memBlock->ofs + t->memBlock->size <= offset) + continue; + + /* It overlaps - kick it out. Need to hold onto the currently + bound objects, however. */ + if (t->bound) r128SwapOutTexObj(r128ctx, t); + else r128DestroyTexObj(r128ctx, t); + } + + if (in_use) { + t = (r128TexObjPtr) calloc(1,sizeof(*t)); + if (!t) return; + + t->memBlock = mmAllocMem(r128ctx->texHeap[heap], size, 0, offset); + insert_at_head(&r128ctx->TexObjList[heap], t); + } +} + +/* Update our client's shared texture state. If another client has + modified a region in which we have textures, then we need to figure + out which of our textures has been removed, and update our global + LRU. */ +void r128AgeTextures(r128ContextPtr r128ctx, int heap) +{ + R128SAREAPrivPtr sarea = r128ctx->r128Screen->SAREA; + + if (sarea->texAge[heap] != r128ctx->lastTexAge[heap]) { + int log2sz = 1 << r128ctx->r128Screen->log2TexGran[heap]; + int nr = 0; + int idx; + + for (idx = sarea->texList[heap][R128_NR_TEX_REGIONS].prev; + idx != R128_NR_TEX_REGIONS && nr < R128_NR_TEX_REGIONS; + idx = sarea->texList[heap][idx].prev, nr++) { + + /* If switching texturing schemes, then the SAREA might not + have been properly cleared, so we need to reset the + global texture LRU. */ + if (idx * log2sz > r128ctx->r128Screen->texSize[heap]) { + nr = R128_NR_TEX_REGIONS; + break; + } + + if (sarea->texList[heap][idx].age > r128ctx->lastTexAge[heap]) + r128TexturesGone(r128ctx, heap, idx * log2sz, log2sz, + sarea->texList[heap][idx].in_use); + } + + if (nr == R128_NR_TEX_REGIONS) { + r128TexturesGone(r128ctx, heap, + 0, r128ctx->r128Screen->texSize[heap], 0); + r128ResetGlobalLRU(r128ctx, heap); + } + + r128ctx->dirty |= R128_UPDATE_TEX0IMAGES; + r128ctx->dirty |= R128_UPDATE_TEX1IMAGES; + r128ctx->lastTexAge[heap] = sarea->texAge[heap]; + } +} + +/* Convert a block of Mesa-formatted texture to an 8bpp hardware format */ +static void r128ConvertTexture8bpp(r128ContextPtr r128ctx, + struct gl_texture_image *image, + int x, int y, int width, int height, + int pitch) +{ + CARD8 *src; + CARD32 pix; + int i, j; + + switch (image->Format) { + case GL_RGB: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3; + for (j = width >> 2; j; j--) { + pix = ((R128PACKCOLOR332( src[0], src[1], src[2]) ) | + (R128PACKCOLOR332( src[3], src[4], src[5]) << 8) | + (R128PACKCOLOR332( src[6], src[7], src[8]) << 16) | + (R128PACKCOLOR332( src[9], src[10], src[11]) << 24)); + R128CCE(pix); + src += 12; + } + } + break; + + case GL_ALPHA: + case GL_LUMINANCE: + case GL_INTENSITY: + case GL_COLOR_INDEX: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x); + for (j = width >> 2; j; j--) { + pix = src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); + R128CCE(pix); + src += 4; + } + } + break; + + default: + fprintf(stderr, "r128ConvertTexture8bpp: unsupported format 0x%x\n", + image->Format); + } +} + +/* Convert a block of Mesa-formatted texture to a 16bpp hardware format */ +static void r128ConvertTexture16bpp(r128ContextPtr r128ctx, + struct gl_texture_image *image, + int x, int y, int width, int height, + int pitch) +{ + CARD8 *src; + CARD32 pix; + int i, j; + + switch (image->Format) { + case GL_RGB: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3; + for (j = width >> 1; j; j--) { + pix = ((R128PACKCOLOR565(src[0], src[1], src[2]) ) | + (R128PACKCOLOR565(src[3], src[4], src[5]) << 16)); + R128CCE(pix); + src += 6; + } + } + break; + + case GL_RGBA: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4; + for (j = width >> 1; j; j--) { + pix = + ((R128PACKCOLOR4444(src[0], src[1], src[2], src[3]) ) | + (R128PACKCOLOR4444(src[4], src[5], src[6], src[7])<<16)); + R128CCE(pix); + src += 8; + } + } + break; + + case GL_ALPHA: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x); + for (j = width >> 1; j; j--) { + pix = ((R128PACKCOLOR4444(0xff, 0xff, 0xff, src[0]) ) | + (R128PACKCOLOR4444(0xff, 0xff, 0xff, src[1]) << 16)); + R128CCE(pix); + src += 2; + } + } + break; + + case GL_LUMINANCE: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x); + for (j = width >> 1; j; j--) { + pix = ((R128PACKCOLOR1555(src[0], src[0], src[0], 0xff) ) | + (R128PACKCOLOR1555(src[1], src[1], src[1], 0xff)<<16)); + R128CCE(pix); + src += 2; + } + } + break; + + case GL_LUMINANCE_ALPHA: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2; + for (j = width >> 1; j; j--) { + pix = + ((R128PACKCOLOR4444(src[0], src[0], src[0], src[1]) ) | + (R128PACKCOLOR4444(src[2], src[2], src[2], src[3])<<16)); + R128CCE(pix); + src += 4; + } + } + break; + + case GL_INTENSITY: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x); + for (j = width >> 1; j; j--) { + pix = + ((R128PACKCOLOR4444(src[0], src[0], src[0], src[0]) ) | + (R128PACKCOLOR4444(src[1], src[1], src[1], src[1])<<16)); + R128CCE(pix); + src += 2; + } + } + break; + + default: + fprintf(stderr, "r128ConvertTexture16bpp: unsupported format 0x%x\n", + image->Format); + } +} + +/* Convert a block of Mesa-formatted texture to a 32bpp hardware format */ +static void r128ConvertTexture32bpp(r128ContextPtr r128ctx, + struct gl_texture_image *image, + int x, int y, int width, int height, + int pitch) +{ + CARD8 *src; + CARD32 pix; + int i, j; + + switch (image->Format) { + case GL_RGB: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3; + for (j = width; j; j--) { + pix = R128PACKCOLOR8888(src[0], src[1], src[2], 0xff); + R128CCE(pix); + src += 3; + } + } + break; + + case GL_RGBA: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4; + for (j = width; j; j--) { + pix = R128PACKCOLOR8888(src[0], src[1], src[2], src[3]); + R128CCE(pix); + src += 4; + } + } + break; + + case GL_ALPHA: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x); + for (j = width; j; j--) { + pix = R128PACKCOLOR8888(0xff, 0xff, 0xff, src[0]); + R128CCE(pix); + src += 1; + } + } + break; + + case GL_LUMINANCE: + for (i = 0 ; i < height ; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x); + for (j = width; j; j--) { + pix = R128PACKCOLOR8888(src[0], src[0], src[0], 0xff); + R128CCE(pix); + src += 1; + } + } + break; + + case GL_LUMINANCE_ALPHA: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2; + for (j = width; j; j-- ) { + pix = R128PACKCOLOR8888(src[0], src[0], src[0], src[1]); + R128CCE(pix); + src += 2; + } + } + break; + + case GL_INTENSITY: + for (i = 0; i < height; i++) { + src = (CARD8 *)image->Data + ((y + i) * pitch + x); + for (j = width; j; j--) { + pix = R128PACKCOLOR8888(src[0], src[0], src[0], src[0]); + R128CCE(pix); + src += 1; + } + } + break; + + default: + fprintf(stderr, "r128ConvertTexture32bpp: unsupported format 0x%x\n", + image->Format); + } +} + +/* Upload the texture image associated with texture `t' at level `level' + at the address relative to `start'. */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128UploadSubImage(r128ContextPtr r128ctx, + r128TexObjPtr t, int level, + int x, int y, int width, int height) +{ + struct gl_texture_image *image; + int texelsPerDword = 0; + int imageWidth, imageHeight; + int remaining, rows; + int format, pitch, dwords; + CARD32 offset; + + /* Ensure we have a valid texture to upload */ + if (level < 0 || level > R128_TEX_MAXLEVELS) return; + if (!(image = t->tObj->Image[level])) return; + + /* FIXME: support RGB888 (i.e., 24bpp) textures? */ + switch (t->texelBytes) { + case 1: texelsPerDword = 4; break; + case 2: texelsPerDword = 2; break; + case 4: texelsPerDword = 1; break; + } + + imageWidth = image->Width; + imageHeight = image->Height; + + format = t->textureFormat >> 16; + + /* The texel upload routines have a minimum width, so force the size + if needed */ + if (imageWidth < texelsPerDword) { + int factor; + + factor = texelsPerDword / imageWidth; + imageWidth = texelsPerDword; + imageHeight /= factor; + if (imageHeight == 0) { + /* In this case, the texel converter will actually walk a + texel or two off the end of the image, but normal malloc + alignment should prevent it from ever causing a fault. */ + imageHeight = 1; + } + } + + /* We can't upload to a pitch less than 8 texels so we will need to + linearly upload all modified rows for textures smaller than this. + This makes the x/y/width/height different for the blitter and the + texture walker. */ + if (imageWidth >= 8) { + /* The texture walker and the blitter look identical */ + pitch = imageWidth >> 3; + } else { + int factor; + int y2; + int start, end; + + start = (y * imageWidth) & ~7; + end = (y + height) * imageWidth; + + if (end - start < 8) { + /* Handle the case where the total number of texels uploaded + is < 8 */ + x = 0; + y = start / 8; + width = end - start; + height = 1; + } else { + /* Upload some number of full 8 texel blit rows */ + factor = 8 / imageWidth; + + y2 = y + height - 1; + y /= factor; + y2 /= factor; + + x = 0; + width = 8; + height = y2 - y + 1; + } + + /* Fixed pitch of 8 */ + pitch = 1; + } + + dwords = width * height / texelsPerDword; + offset = (CARD32)(t->bufAddr + t->image[level].offset); + + /* Fix offset for AGP textures */ + if (t->heap == R128_AGP_TEX_HEAP) + offset += R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) { + fprintf(stderr, "r128UploadSubImage: %d,%d of %d,%d at %d,%d\n", + width, height, image->Width, image->Height, x, y); + fprintf(stderr, " blit ofs: 0x%08x pitch: 0x%x dwords: %d " + "level: %d format: %x\n", + (int)offset, pitch, dwords, level, format); + } + +#define R128_MAX_BLIT_DWORDS 8192 + /* Subdivide the texture if required */ + if (dwords < R128_MAX_BLIT_DWORDS) { + rows = height; + } else { + rows = (R128_MAX_BLIT_DWORDS * texelsPerDword) / (2 * width); + } + + /* Flush the pixel cache, and mark the contents as Read Invalid */ + R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0); + R128CCE(r128ctx->regs.pc_gui_ctlstat | + R128_PC_RI_GUI | + R128_PC_FLUSH_GUI); + R128CCE_SUBMIT_PACKET(); + + /* Build the CCE host data blit header */ + R128CCE3(R128_CCE_PACKET3_CNTL_HOSTDATA_BLT, 0); + + /* DP_GUI_MASTER_CNTL */ + R128CCE(R128_GMC_DST_PITCH_OFFSET_CNTL | + R128_GMC_BRUSH_NONE | + (format << 8) | + R128_GMC_SRC_DATATYPE_COLOR | + R128_ROP3_S | + R128_DP_SRC_SOURCE_HOST_DATA | + R128_GMC_CLR_CMP_CNTL_DIS | + R128_AUX_CLIP_DIS | + R128_GMC_WR_MSK_DIS ); + + /* DST_OFFSET_PITCH - fixed at the moment until we get better ring + control */ + R128CCE((pitch << 21) | (offset>>5)); + + /* FRGD_COLOR, BKGD_COLOR */ + R128CCE(0xffffffff); + R128CCE(0xffffffff); + + for (remaining = height; remaining > 0; remaining -= rows, y += rows) { + height = (remaining >= rows) ? rows : remaining; + dwords = width * height / texelsPerDword; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) { + fprintf(stderr, " blitting: %d,%d at %d,%d - %d dwords\n", + width, height, x, y, dwords); + } + + r128ctx->CCEbuf[0] &= ~R128_CCE_PACKET_COUNT_MASK; + r128ctx->CCEbuf[0] |= (dwords + 6) << 16; + + /* Blit coords, size */ + R128CCE((y << 16) | x); + R128CCE((height << 16) | width); + R128CCE(dwords); + + /* Actually do the texture conversion */ + switch (t->texelBytes) { + case 1: + r128ConvertTexture8bpp(r128ctx, image, + x, y, width, height, width); + break; + case 2: + r128ConvertTexture16bpp(r128ctx, image, + x, y, width, height, width); + break; + case 4: + r128ConvertTexture32bpp(r128ctx, + image, x, y, width, height, width); + break; + } + + /* Flush the pixel cache */ + R128CCE0(R128_CCE_PACKET0, R128_PC_GUI_CTLSTAT, 0 ); + R128CCE(r128ctx->regs.pc_gui_ctlstat | R128_PC_FLUSH_GUI); + + /* Save the partial blit header */ + R128CCE_SUBMIT_PACKET(); + r128ctx->CCEcount = 5; + } + + /* Clean up CCE ring buffer */ + r128ctx->CCEcount = 0; +} + +/* Upload the texture images associated with texture `t'. This might + require removing our own and/or other client's texture objects to + make room for these images. */ +/* NOTE: This function is only called while holding the hardware lock */ +int r128UploadTexImages(r128ContextPtr r128ctx, r128TexObjPtr t) +{ + int i; + int minLevel; + int maxLevel; + int heap; + + if (!t) return 0; + + /* Choose the heap appropriately */ + heap = t->heap = R128_LOCAL_TEX_HEAP; + if (!r128ctx->r128Screen->IsPCI && + t->totalSize > r128ctx->r128Screen->texSize[heap]) + heap = t->heap = R128_AGP_TEX_HEAP; + + /* Do we need to eject LRU texture objects? */ + if (!t->memBlock) { + /* Allocate a memory block on a 4k boundary (1<<12 == 4096) */ + t->memBlock = mmAllocMem(r128ctx->texHeap[heap], t->totalSize, 12, 0); + + /* Try AGP before kicking anything out of local mem */ + if (!t->memBlock && heap == R128_LOCAL_TEX_HEAP) { + t->memBlock = mmAllocMem(r128ctx->texHeap[R128_AGP_TEX_HEAP], + t->totalSize, 12, 0); + + if (t->memBlock) heap = t->heap = R128_AGP_TEX_HEAP; + } + + /* Kick out textures until the requested texture fits */ + while (!t->memBlock) { + if (r128ctx->TexObjList[heap].prev->bound) { + fprintf(stderr, + "r128UploadTexImages: ran into bound texture\n"); + return -1; + } + if (r128ctx->TexObjList[heap].prev == + &(r128ctx->TexObjList[heap])) { + if (r128ctx->r128Screen->IsPCI) { + fprintf(stderr, "r128UploadTexImages: upload texture " + "failure on local texture heaps, sz=%d\n", + t->totalSize); + return -1; + } else if (heap == R128_LOCAL_TEX_HEAP) { + heap = t->heap = R128_AGP_TEX_HEAP; + continue; + } else { + fprintf(stderr, "r128UploadTexImages: upload texture " + "failure on both local and AGP texture heaps, " + "sz=%d\n", + t->totalSize); + return -1; + } + } + + r128DestroyTexObj(r128ctx, r128ctx->TexObjList[heap].prev); + + t->memBlock = mmAllocMem(r128ctx->texHeap[heap], + t->totalSize, 12, 0); + } + + /* Set the base offset of the texture image */ + t->bufAddr = (unsigned char *)r128ctx->r128Screen->texOffset[heap]; + t->bufAddr += t->memBlock->ofs; + + maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >> + R128_TEX_SIZE_SHIFT); + minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >> + R128_TEX_MIN_SIZE_SHIFT); + + /* Update the hardware's texture image addresses */ + switch (t->bound) { + case 1: + /* Set texture offsets */ + if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) { + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.prim_tex_offset[i] = (CARD32)t->bufAddr; + } else { + for (i = maxLevel; i >= minLevel; i--) + r128ctx->regs.prim_tex_offset[i] = + t->image[maxLevel-i].offset + (CARD32)t->bufAddr; + } + /* Fix AGP texture offsets */ + if (heap == R128_AGP_TEX_HEAP) + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.prim_tex_offset[i] += + R128_AGP_TEX_OFFSET + + r128ctx->r128Screen->agpTexOffset; + /* Force loading the new state into the hardware */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_TEX0STATE; + break; + + case 2: + /* Set texture offsets */ + if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) { + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.sec_tex_offset[i] = (CARD32)t->bufAddr; + } else { + for (i = maxLevel; i >= minLevel; i--) + r128ctx->regs.sec_tex_offset[i] = + t->image[maxLevel-i].offset + (CARD32)t->bufAddr; + } + /* Fix AGP texture offsets */ + if (heap == R128_AGP_TEX_HEAP) + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.sec_tex_offset[i] += + R128_AGP_TEX_OFFSET + + r128ctx->r128Screen->agpTexOffset; + /* Force loading the new state into the hardware */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_TEX1STATE; + break; + + default: + return -1; + } + } + + /* Let the world know we've used this memory recently */ + r128UpdateTexLRU(r128ctx, t); + + /* Upload any images that are new */ + if (t->dirty_images) { + int num_levels = (((t->regs.size_pitch & R128_TEX_SIZE_MASK) >> + R128_TEX_SIZE_SHIFT) - + ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >> + R128_TEX_MIN_SIZE_SHIFT)); + + for (i = 0; i <= num_levels; i++) { + if (t->dirty_images & (1<<i)) { + r128UploadSubImage(r128ctx, t, i, 0, 0, + t->image[i].width, t->image[i].height); + } + } + + r128ctx->regs.tex_cntl_c |= R128_TEX_CACHE_FLUSH; + + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ENGINESTATE; + } + + t->dirty_images = 0; + return 0; +} + +/* Update the hardware state for texture unit 0 */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128UpdateTex0State(r128ContextPtr r128ctx) +{ + GLcontext *ctx = r128ctx->glCtx; + r128TexObjPtr t; + struct gl_texture_object *tObj; + int i; + CARD32 tex_size_pitch, tex_combine_cntl; + + /* Only update the hardware texture state if the texture is current, + complete and enabled. */ + if (!(tObj = ctx->Texture.Unit[0].Current)) return; + if ((tObj != ctx->Texture.Unit[0].CurrentD[2]) && + (tObj != ctx->Texture.Unit[0].CurrentD[1])) return; + if (!tObj->Complete) return; + + /* If neither tex0 nor tex1 is enabled, then disable tex0. However, + if tex1 is enabled but tex0 is disabled, then we need to enable + tex0 and have it to copy the input (see how tex_combine_cntl is + setup below). */ + if (!(ctx->Texture.Enabled & (ENABLE_TEX0 | ENABLE_TEX1))) { + r128ctx->regs.tex_cntl_c &= ~R128_TEXMAP_ENABLE; + return; + } + + r128ctx->regs.scale_3d_cntl &= ~R128_TEX_CACHE_SPLIT; + + /* If this is the first time the texture has been used, then create + a new texture object for it. */ + t = tObj->DriverData; + if (!t) t = r128CreateTexObj(r128ctx, tObj); + if (!t) return; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) + fprintf(stderr, "r128UpdateTex0State(%p, 0x%08x)\n", + tObj, (int)t->dirty_images); + + /* Force any texture images to be loaded into the hardware */ + if (t->dirty_images) r128ctx->dirty |= R128_UPDATE_TEX0IMAGES; + + /* Bind texture to texture 0 unit */ + r128ctx->CurrentTexObj[0] = t; + t->bound = 1; + + if (t->memBlock) r128UpdateTexLRU(r128ctx, t); + + /* Set the texture environment state */ + switch (ctx->Texture.Unit[0].EnvMode) { + case GL_REPLACE: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + tex_combine_cntl = (R128_COMB_DIS | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_DIS | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_RGB: + case GL_LUMINANCE: + tex_combine_cntl = (R128_COMB_DIS | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_ALPHA: + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_DIS | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + case GL_BLEND: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + switch (r128ctx->regs.constant_color_c & + R128_CONSTANT_COLOR_MASK) { + case R128_CONSTANT_COLOR_ZERO: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_NTEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case R128_CONSTANT_COLOR_ONE: + default: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + r128ctx->Fallback |= R128_FALLBACK_TEXTURE; + break; + } + break; + case GL_RGB: + case GL_LUMINANCE: + switch (r128ctx->regs.constant_color_c & + R128_CONSTANT_COLOR_MASK) { + case R128_CONSTANT_COLOR_ZERO: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_NTEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case R128_CONSTANT_COLOR_ONE: + default: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + r128ctx->Fallback |= R128_FALLBACK_TEXTURE; + break; + } + break; + case GL_ALPHA: + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_INTENSITY: + switch (r128ctx->regs.constant_color_c & + R128_CONSTANT_COLOR_MASK) { + case R128_CONSTANT_COLOR_ZERO: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_NTEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_NTEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case R128_CONSTANT_COLOR_ONE: + default: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + r128ctx->Fallback |= R128_FALLBACK_TEXTURE; + break; + } + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + case GL_MODULATE: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_RGB: + case GL_LUMINANCE: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_ALPHA: + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + case GL_DECAL: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + tex_combine_cntl = (R128_COMB_BLEND_TEXTURE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_RGB: + tex_combine_cntl = (R128_COMB_DIS | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + /* Undefined behaviour - just copy the input */ + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + case GL_ADD: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + tex_combine_cntl = (R128_COMB_ADD | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_RGB: + case GL_LUMINANCE: + tex_combine_cntl = (R128_COMB_ADD | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_ALPHA: + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + default: + return; + } + + /* If tex0 is disabled, then make sure it just copies the input */ + if (!(ctx->Texture.Enabled & ENABLE_TEX0)) + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_INT_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_INT_ALPHA); + + /* Enable tex0 */ + r128ctx->regs.tex_cntl_c |= R128_TEXMAP_ENABLE; + + tex_size_pitch = r128ctx->regs.tex_size_pitch_c; + tex_size_pitch &= ~R128_TEX_SIZE_PITCH_MASK; + tex_size_pitch |= t->regs.size_pitch << R128_TEX_SIZE_PITCH_SHIFT; + + /* Set the primary texture state in r128ctx->regs */ + r128ctx->regs.prim_tex_cntl_c = t->regs.tex_cntl; + r128ctx->regs.prim_texture_combine_cntl_c = tex_combine_cntl; + r128ctx->regs.tex_size_pitch_c = tex_size_pitch; + r128ctx->regs.prim_texture_border_color_c = t->regs.border_color; + + /* Set texture offsets */ + if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) { + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.prim_tex_offset[i] = (CARD32)t->bufAddr; + } else { + int maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >> + R128_TEX_SIZE_SHIFT); + int minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >> + R128_TEX_MIN_SIZE_SHIFT); + for (i = maxLevel; i >= minLevel; i--) + r128ctx->regs.prim_tex_offset[i] = + t->image[maxLevel-i].offset + (CARD32)t->bufAddr; + } + /* Fix AGP texture offsets */ + if (t->heap == R128_AGP_TEX_HEAP) + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.prim_tex_offset[i] += + R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset; + + /* Force loading the new state into the hardware */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_TEX0STATE | R128_CTX_ENGINESTATE; +} + +/* Update the hardware state for texture unit 1 */ +/* NOTE: This function is only called while holding the hardware lock */ +static void r128UpdateTex1State(r128ContextPtr r128ctx) +{ + GLcontext *ctx = r128ctx->glCtx; + r128TexObjPtr t; + struct gl_texture_object *tObj; + int i; + CARD32 tex_size_pitch, tex_combine_cntl, tex_cntl; + + /* Only update the hardware texture state if the texture is current, + complete and enabled. */ + if (!(tObj = ctx->Texture.Unit[1].Current)) return; + if ((tObj != ctx->Texture.Unit[1].CurrentD[2]) && + (tObj != ctx->Texture.Unit[1].CurrentD[1])) return; + if (!tObj->Complete) return; + + /* If tex1 is not enabled, then disable it */ + if (!(ctx->Texture.Enabled & ENABLE_TEX1)) { + r128ctx->regs.tex_cntl_c &= ~R128_SEC_TEXMAP_ENABLE; + return; + } + + /* If te1 is enabled, split the texel cache */ + r128ctx->regs.scale_3d_cntl |= R128_TEX_CACHE_SPLIT; + + /* If this is the first time the texture has been used, then create + a new texture object for it. */ + t = tObj->DriverData; + if (!t) t = r128CreateTexObj(r128ctx, tObj); + if (!t) return; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) + fprintf(stderr, "r128UpdateTex1State(%p, 0x%08x)\n", + tObj, (int)t->dirty_images); + + /* Force any texture images to be loaded into the hardware */ + if (t->dirty_images) r128ctx->dirty |= R128_UPDATE_TEX1IMAGES; + + /* Bind texture to texture 1 unit */ + r128ctx->CurrentTexObj[1] = t; + t->bound = 2; + + if (t->memBlock) r128UpdateTexLRU(r128ctx, t); + + /* Set the texture environment state */ + switch (ctx->Texture.Unit[1].EnvMode) { + case GL_REPLACE: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + tex_combine_cntl = (R128_COMB_DIS | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_DIS | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_RGB: + case GL_LUMINANCE: + tex_combine_cntl = (R128_COMB_DIS | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_ALPHA: + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_DIS | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + case GL_BLEND: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + switch ( r128ctx->regs.constant_color_c & R128_CONSTANT_COLOR_MASK ) { + case R128_CONSTANT_COLOR_ZERO: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_NTEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case R128_CONSTANT_COLOR_ONE: + default: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + r128ctx->Fallback |= R128_FALLBACK_TEXTURE; + break; + } + break; + case GL_RGB: + case GL_LUMINANCE: + switch (r128ctx->regs.constant_color_c & + R128_CONSTANT_COLOR_MASK) { + case R128_CONSTANT_COLOR_ZERO: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_NTEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA ); + break; + case R128_CONSTANT_COLOR_ONE: + default: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA ); + r128ctx->Fallback |= R128_FALLBACK_TEXTURE; + break; + } + break; + case GL_ALPHA: + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_INTENSITY: + switch (r128ctx->regs.constant_color_c & + R128_CONSTANT_COLOR_MASK) { + case R128_CONSTANT_COLOR_ZERO: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_NTEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_NTEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case R128_CONSTANT_COLOR_ONE: + default: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + r128ctx->Fallback |= R128_FALLBACK_TEXTURE; + break; + } + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + case GL_MODULATE: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_RGB: + case GL_LUMINANCE: + tex_combine_cntl = (R128_COMB_MODULATE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_ALPHA: + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + case GL_DECAL: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + tex_combine_cntl = (R128_COMB_BLEND_TEXTURE | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_RGB: + tex_combine_cntl = (R128_COMB_DIS | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + /* Undefined behaviour - just copy the input */ + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + case GL_ADD: + switch (tObj->Image[0]->Format) { + case GL_RGBA: + case GL_LUMINANCE_ALPHA: + case GL_INTENSITY: + tex_combine_cntl = (R128_COMB_ADD | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_RGB: + case GL_LUMINANCE: + tex_combine_cntl = (R128_COMB_ADD | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_COPY_INP | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_ALPHA: + tex_combine_cntl = (R128_COMB_COPY_INP | + R128_COLOR_FACTOR_TEX | + R128_INPUT_FACTOR_PREV_COLOR | + R128_COMB_ALPHA_MODULATE | + R128_ALPHA_FACTOR_TEX_ALPHA | + R128_INP_FACTOR_A_PREV_ALPHA); + break; + case GL_COLOR_INDEX: + default: + return; + } + break; + + default: + return; + } + + /* Enable tex1 */ + r128ctx->regs.tex_cntl_c |= R128_SEC_TEXMAP_ENABLE; + + tex_size_pitch = r128ctx->regs.tex_size_pitch_c; + tex_size_pitch &= ~R128_SEC_TEX_SIZE_PITCH_MASK; + tex_size_pitch |= t->regs.size_pitch << R128_SEC_TEX_SIZE_PITCH_SHIFT; + + tex_cntl = t->regs.tex_cntl | R128_SEC_SELECT_SEC_ST; + + /* Set the secondary texture state in r128ctx->regs */ + r128ctx->regs.sec_tex_cntl_c = tex_cntl; + r128ctx->regs.sec_tex_combine_cntl_c = tex_combine_cntl; + r128ctx->regs.tex_size_pitch_c = tex_size_pitch; + r128ctx->regs.sec_texture_border_color_c = t->regs.border_color; + + /* Set texture offsets */ + if (t->regs.tex_cntl & R128_MIP_MAP_DISABLE) { + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.sec_tex_offset[i] = (CARD32)t->bufAddr; + } else { + int maxLevel = ((t->regs.size_pitch & R128_TEX_SIZE_MASK) >> + R128_TEX_SIZE_SHIFT); + int minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >> + R128_TEX_MIN_SIZE_SHIFT); + for (i = maxLevel; i >= minLevel; i--) + r128ctx->regs.sec_tex_offset[i] = + t->image[maxLevel-i].offset + (CARD32)t->bufAddr; + } + /* Fix AGP texture offsets */ + if (t->heap == R128_AGP_TEX_HEAP) + for (i = 0; i < R128_TEX_MAXLEVELS; i++) + r128ctx->regs.sec_tex_offset[i] += + R128_AGP_TEX_OFFSET + r128ctx->r128Screen->agpTexOffset; + + /* Force loading the new state into the hardware */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_TEX1STATE | R128_CTX_ENGINESTATE; +} + +/* Update the hardware texture state */ +/* NOTE: This function is only called while holding the hardware lock */ +void r128UpdateTextureState(r128ContextPtr r128ctx) +{ + /* Clear the GL_BLEND texturing fallback */ + r128ctx->Fallback &= ~R128_FALLBACK_TEXTURE; + + /* Unbind any currently bound textures */ + if (r128ctx->CurrentTexObj[0]) r128ctx->CurrentTexObj[0]->bound = 0; + if (r128ctx->CurrentTexObj[1]) r128ctx->CurrentTexObj[1]->bound = 0; + r128ctx->CurrentTexObj[0] = NULL; + r128ctx->CurrentTexObj[1] = NULL; + + if (r128ctx->glCtx->Enabled & (TEXTURE0_3D|TEXTURE1_3D)) + r128ctx->Fallback |= R128_FALLBACK_TEXTURE; + + /* Update the texture unit 0/1 state */ + r128UpdateTex0State(r128ctx); + r128UpdateTex1State(r128ctx); +} + +/* Set the texture wrap mode */ +static void r128SetTexWrap(r128TexObjPtr t, GLenum swrap, GLenum twrap) +{ + t->regs.tex_cntl &= ~(R128_TEX_CLAMP_S_MASK | R128_TEX_CLAMP_T_MASK); + + switch (swrap) { + case GL_CLAMP: t->regs.tex_cntl |= R128_TEX_CLAMP_S_CLAMP; break; + case GL_REPEAT: t->regs.tex_cntl |= R128_TEX_CLAMP_S_WRAP; break; + default: /* ERROR!! */ return; + } + + switch (twrap) { + case GL_CLAMP: t->regs.tex_cntl |= R128_TEX_CLAMP_T_CLAMP; break; + case GL_REPEAT: t->regs.tex_cntl |= R128_TEX_CLAMP_T_WRAP; break; + default: /* ERROR!! */ return; + } +} + +/* Set the texture filter mode */ +static void r128SetTexFilter(r128TexObjPtr t, GLenum minf, GLenum magf) +{ + t->regs.tex_cntl &= ~(R128_MIN_BLEND_MASK | R128_MAG_BLEND_MASK); + + switch (minf) { + case GL_NEAREST: + t->regs.tex_cntl |= R128_MIN_BLEND_NEAREST; + break; + case GL_LINEAR: + t->regs.tex_cntl |= R128_MIN_BLEND_LINEAR; + break; + case GL_NEAREST_MIPMAP_NEAREST: + t->regs.tex_cntl |= R128_MIN_BLEND_MIPNEAREST; + break; + case GL_LINEAR_MIPMAP_NEAREST: + t->regs.tex_cntl |= R128_MIN_BLEND_LINEARMIPNEAREST; + break; + case GL_NEAREST_MIPMAP_LINEAR: + t->regs.tex_cntl |= R128_MIN_BLEND_MIPLINEAR; + break; + case GL_LINEAR_MIPMAP_LINEAR: + t->regs.tex_cntl |= R128_MIN_BLEND_LINEARMIPLINEAR; + break; + default: /* ERROR!! */ return; + } + + switch (magf) { + case GL_NEAREST: + t->regs.tex_cntl |= R128_MAG_BLEND_NEAREST; + break; + case GL_LINEAR: + t->regs.tex_cntl |= R128_MAG_BLEND_LINEAR; + break; + } +} + +/* Set the texture border color */ +static void r128SetTexBorderColor(r128TexObjPtr t, GLubyte c[4]) +{ + t->regs.border_color = r128PackColor(32, c[0], c[1], c[2], c[3]); +} + +/* Set the texture environment state */ +static void r128DDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, + const GLfloat *param) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + struct gl_texture_unit *texUnit; + GLubyte c[4]; + CARD32 col; + + /* FIXME: Add texture LOD bias extension */ + + switch (pname) { + case GL_TEXTURE_ENV_MODE: + /* TexEnv modes are handled in UpdateTextureState */ + r128FlushVertices(r128ctx); + r128ctx->dirty |= R128_UPDATE_TEXSTATE; + break; + case GL_TEXTURE_ENV_COLOR: + texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit]; + FLOAT_RGBA_TO_UBYTE_RGBA(texUnit->EnvColor, c); + col = r128PackColor(32, c[0], c[1], c[2], c[3]); + if (r128ctx->regs.constant_color_c != col) { + r128FlushVertices(r128ctx); + r128ctx->regs.constant_color_c = col; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_TEXENVSTATE; + } + break; + default: + return; + } +} + +/* Upload a new texture image */ +static void r128DDTexImage(GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, GLint level, + GLint internalFormat, + const struct gl_texture_image *image) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128TexObjPtr t; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) + fprintf(stderr, "r128DDTexImage(%p, level %d)\n", tObj, level); + + if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return; + if (level >= R128_TEX_MAXLEVELS) return; + + t = (r128TexObjPtr)tObj->DriverData; + if (t) { + if (t->bound) r128FlushVertices(r128ctx); + + /* Destroy the old texture, and upload a new one. The actual + uploading of the texture image occurs in the UploadSubImage + function. */ + r128DestroyTexObj(r128ctx, t); + r128ctx->dirty |= R128_UPDATE_TEXSTATE; + } +} + +/* Upload a new texture sub-image */ +static void r128DDTexSubImage(GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLint internalFormat, + const struct gl_texture_image *image) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128TexObjPtr t; + + if (R128_DEBUG_FLAGS & DEBUG_VERBOSE_API) + fprintf(stderr, "r128DDTexSubImage(%p, level %d) " + "size: %d,%d of %d,%d\n", + tObj, level, width, height, image->Width, image->Height); + + if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return; + if (level >= R128_TEX_MAXLEVELS) return; + + t = (r128TexObjPtr)tObj->DriverData; + if (t) { + if (t->bound) r128FlushVertices(r128ctx); + + LOCK_HARDWARE(r128ctx); + r128UploadSubImage(r128ctx, t, level, + xoffset, yoffset, width, height); + UNLOCK_HARDWARE(r128ctx); + + /* Update the context state */ + r128ctx->regs.tex_cntl_c |= R128_TEX_CACHE_FLUSH; + + r128ctx->dirty |= (R128_UPDATE_CONTEXT | + R128_UPDATE_TEXSTATE); + r128ctx->dirty_context |= (R128_CTX_ENGINESTATE | + R128_CTX_TEX0STATE | + R128_CTX_TEX1STATE); + } +} + +/* Set the texture parameter state */ +static void r128DDTexParameter(GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj, + GLenum pname, const GLfloat *params) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData; + + if (!t) return; + if ((target != GL_TEXTURE_2D) && (target != GL_TEXTURE_1D)) return; + + switch (pname) { + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_MAG_FILTER: + if (t->bound) r128FlushVertices(r128ctx); + r128SetTexFilter(t, tObj->MinFilter, tObj->MagFilter); + break; + + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: + if (t->bound) r128FlushVertices(r128ctx); + r128SetTexWrap(t, tObj->WrapS, tObj->WrapT); + break; + + case GL_TEXTURE_BORDER_COLOR: + if (t->bound) r128FlushVertices(r128ctx); + r128SetTexBorderColor(t, tObj->BorderColor); + break; + + default: + return; + } + + r128ctx->dirty |= R128_UPDATE_TEXSTATE; +} + +/* Bind a texture to the currently active texture unit */ +static void r128DDBindTexture(GLcontext *ctx, GLenum target, + struct gl_texture_object *tObj) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + + r128FlushVertices(r128ctx); + + /* Unbind the old texture */ + if (r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit]) { + r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit]->bound = 0; + r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit] = NULL; + } + + /* The actualy binding occurs in the Tex[01]UpdateState function */ + r128ctx->dirty |= R128_UPDATE_TEXSTATE; +} + +/* Remove texture from AGP/local texture memory */ +static void r128DDDeleteTexture(GLcontext *ctx, + struct gl_texture_object *tObj) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData; + + if (t) { + if (t->bound) { + r128FlushVertices(r128ctx); + + r128ctx->CurrentTexObj[t->bound-1] = 0; + r128ctx->dirty |= R128_UPDATE_TEXSTATE; + } + + r128DestroyTexObj(r128ctx, t); + tObj->DriverData = NULL; + } +} + +/* Determine if a texture is currently residing in either AGP/local + texture memory */ +static GLboolean r128DDIsTextureResident(GLcontext *ctx, + struct gl_texture_object *tObj) +{ + r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData; + + return t && t->memBlock; +} + +/* Initialize the driver's texture functions */ +void r128DDInitTextureFuncs(GLcontext *ctx) +{ + ctx->Driver.TexEnv = r128DDTexEnv; + ctx->Driver.TexImage = r128DDTexImage; + ctx->Driver.TexSubImage = r128DDTexSubImage; + ctx->Driver.TexParameter = r128DDTexParameter; + ctx->Driver.BindTexture = r128DDBindTexture; + ctx->Driver.DeleteTexture = r128DDDeleteTexture; + ctx->Driver.UpdateTexturePalette = NULL; + ctx->Driver.ActiveTexture = NULL; + ctx->Driver.IsTextureResident = r128DDIsTextureResident; + ctx->Driver.PrioritizeTexture = NULL; +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c new file mode 100644 index 000000000..00bbe948e --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c @@ -0,0 +1,304 @@ +/* $XFree86$ */ /* -*- c-basic-offset: 4 -*- */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_reg.h" +#include "r128_cce.h" +#include "r128_vb.h" +#include "r128_tris.h" +#include "r128_state.h" + +static triangle_func tri_tab[0x10]; +static quad_func quad_tab[0x10]; +static line_func line_tab[0x10]; +static points_func points_tab[0x10]; + +/* Draw a triangle from the vertices in the vertex buffer */ +__inline void r128DrawTriangleVB(r128ContextPtr r128ctx, + r128Vertex *v0, + r128Vertex *v1, + r128Vertex *v2) +{ + int vertsize = r128ctx->vertsize; + CARD32 *vb = r128AllocVertexDwords( r128ctx, 3 * vertsize ); + int j; + + for (j = 0 ; j < vertsize ; j++) + vb[j] = v0->ui[j]; + + vb += vertsize; + for (j = 0 ; j < vertsize ; j++) + vb[j] = v1->ui[j]; + + vb += vertsize; + for (j = 0 ; j < vertsize ; j++) + vb[j] = v2->ui[j]; +} + +/* Draw a line from the vertices in the vertex buffer */ +__inline void r128DrawLineVB( r128ContextPtr r128ctx, + r128Vertex *tmp0, + r128Vertex *tmp1, + float width ) +{ + int vertsize = r128ctx->vertsize; + CARD32 *vb = r128AllocVertexDwords( r128ctx, 6 * vertsize ); + float dx, dy, ix, iy; + int j; + + dx = tmp0->vert1.x - tmp1->vert1.x; + dy = tmp0->vert1.y - tmp1->vert1.y; + + ix = width * .5; iy = 0; + + if ((ix<.5) && (ix>0.1)) ix = .5; /* I want to see lines with width + 0.5 also */ + + if (dx * dx > dy * dy) { + iy = ix; ix = 0; + } + + *(float *)&vb[0] = tmp0->vert1.x - ix; + *(float *)&vb[1] = tmp0->vert1.y - iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp0->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp1->vert1.x + ix; + *(float *)&vb[1] = tmp1->vert1.y + iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp1->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp0->vert1.x + ix; + *(float *)&vb[1] = tmp0->vert1.y + iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp0->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp0->vert1.x - ix; + *(float *)&vb[1] = tmp0->vert1.y - iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp0->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp1->vert1.x - ix; + *(float *)&vb[1] = tmp1->vert1.y - iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp1->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp1->vert1.x + ix; + *(float *)&vb[1] = tmp1->vert1.y + iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp1->ui[j]; +} + + +/* Draw a point from the vertices in the vertex buffer */ +__inline void r128DrawPointVB( r128ContextPtr r128ctx, + r128Vertex *tmp, float sz ) +{ + int vertsize = r128ctx->vertsize; + CARD32 *vb = r128AllocVertexDwords( r128ctx, 6 * vertsize ); + int j; + + *(float *)&vb[0] = tmp->vert1.x - sz; + *(float *)&vb[1] = tmp->vert1.y - sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x + sz; + *(float *)&vb[1] = tmp->vert1.y - sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x + sz; + *(float *)&vb[1] = tmp->vert1.y + sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x + sz; + *(float *)&vb[1] = tmp->vert1.y + sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x - sz; + *(float *)&vb[1] = tmp->vert1.y + sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x - sz; + *(float *)&vb[1] = tmp->vert1.y - sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; +} + +#define R128_COLOR(to, from) \ +do { \ + (to)[0] = (from)[2]; \ + (to)[1] = (from)[1]; \ + (to)[2] = (from)[0]; \ + (to)[3] = (from)[3]; \ +} while (0) + +#define IND (0) +#define TAG(x) x +#include "r128_tritmp.h" + +#define IND (R128_FLAT_BIT) +#define TAG(x) x##_flat +#include "r128_tritmp.h" + +#define IND (R128_OFFSET_BIT) +#define TAG(x) x##_offset +#include "r128_tritmp.h" + +#define IND (R128_OFFSET_BIT | R128_FLAT_BIT) +#define TAG(x) x##_offset_flat +#include "r128_tritmp.h" + +#define IND (R128_TWOSIDE_BIT) +#define TAG(x) x##_twoside +#include "r128_tritmp.h" + +#define IND (R128_TWOSIDE_BIT | R128_FLAT_BIT) +#define TAG(x) x##_twoside_flat +#include "r128_tritmp.h" + +#define IND (R128_TWOSIDE_BIT | R128_OFFSET_BIT) +#define TAG(x) x##_twoside_offset +#include "r128_tritmp.h" + +#define IND (R128_TWOSIDE_BIT | R128_OFFSET_BIT | R128_FLAT_BIT) +#define TAG(x) x##_twoside_offset_flat +#include "r128_tritmp.h" + +/* Initialize the table of points, line and triangle drawing functions */ +void r128TriangleFuncsInit(void) +{ + init(); + init_flat(); + init_offset(); + init_offset_flat(); + init_twoside(); + init_twoside_flat(); + init_twoside_offset(); + init_twoside_offset_flat(); +} + +/* Setup the Point, Line, Triangle and Quad functions based on the + current rendering state. Wherever possible, use the hardware to + render the primitive. Otherwise, fallback to software rendering. */ +void r128ChooseRenderState(GLcontext *ctx) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + GLuint flags = ctx->TriangleCaps; + + /* KW: Includes handling of SWonly rendering: + */ + if (r128ctx->Fallback) + return; + + r128ctx->IndirectTriangles = 0; + + if (flags) { + CARD32 index = 0; + CARD32 shared = 0; + CARD32 fallback = R128_FALLBACK_BIT; + + /* KW: I'd prefer to remove SWfallbackDisable & just use + * R128_FALLBACK_BIT throughout this routine. + */ + if (r128ctx->SWfallbackDisable) fallback = 0; + + if (flags & DD_FLATSHADE) shared |= R128_FLAT_BIT; + if (flags & DD_TRI_LIGHT_TWOSIDE) shared |= R128_TWOSIDE_BIT; + + /* TODO: Fix mesa so that these can be handled in + * r128ctx->Fallback. + */ + if (flags & (DD_MULTIDRAW | + DD_SELECT | + DD_FEEDBACK)) shared |= R128_FALLBACK_BIT; + + /* Setup PointFunc */ + index = shared; + if (flags & DD_POINT_SMOOTH) index |= fallback; + + r128ctx->RenderIndex = index; + r128ctx->PointsFunc = points_tab[index]; + if (index & R128_FALLBACK_BIT) + r128ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE; + + /* Setup LineFunc */ + index = shared; + if (flags & DD_LINE_SMOOTH) index |= fallback; + if (flags & DD_LINE_STIPPLE) index |= fallback; + + r128ctx->RenderIndex |= index; + r128ctx->LineFunc = line_tab[index]; + if (index & R128_FALLBACK_BIT) + r128ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE; + + /* Setup TriangleFunc and QuadFunc */ + index = shared; + if (flags & DD_TRI_OFFSET) index |= R128_OFFSET_BIT; + if (flags & DD_TRI_SMOOTH) index |= fallback; + if (flags & DD_TRI_UNFILLED) index |= fallback; + if (flags & DD_TRI_STIPPLE) index |= fallback; + + r128ctx->RenderIndex |= index; + r128ctx->TriangleFunc = tri_tab[index]; + r128ctx->QuadFunc = quad_tab[index]; + if (index & R128_FALLBACK_BIT) + r128ctx->IndirectTriangles |= (DD_TRI_SW_RASTERIZE | + DD_QUAD_SW_RASTERIZE); + } else if (r128ctx->RenderIndex) { + r128ctx->RenderIndex = 0; + r128ctx->PointsFunc = points_tab[0]; + r128ctx->LineFunc = line_tab[0]; + r128ctx->TriangleFunc = tri_tab[0]; + r128ctx->QuadFunc = quad_tab[0]; + } +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.h b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h new file mode 100644 index 000000000..4a7a0736e --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h @@ -0,0 +1,61 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifndef _R128_TRIS_H_ +#define _R128_TRIS_H_ + +#ifdef GLX_DIRECT_RENDERING + +#include "r128_vb.h" + +#define R128_FLAT_BIT 0x01 +#define R128_OFFSET_BIT 0x02 +#define R128_TWOSIDE_BIT 0x04 +#define R128_FALLBACK_BIT 0x08 + +extern __inline void r128DrawTriangleVB(r128ContextPtr r128ctx, + r128Vertex *v0, + r128Vertex *v1, + r128Vertex *v2); +extern __inline void r128DrawLineVB(r128ContextPtr r128ctx, + r128Vertex *tmp0, r128Vertex *tmp1, + float width); +extern __inline void r128DrawPointVB(r128ContextPtr r128ctx, + r128Vertex *tmp, float size); + +extern void r128ChooseRenderState(GLcontext *ctx); +extern void r128TriangleFuncsInit(void); + +#endif +#endif /* _R128_TRIS_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h b/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h new file mode 100644 index 000000000..51fc9acfb --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h @@ -0,0 +1,204 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#if !defined(TAG) || !defined(IND) + this is an error +#endif + +/* Draw a single triangle. Note that the device-dependent vertex data + might need to be changed based on the render state. */ +static void TAG(triangle)(GLcontext *ctx, + GLuint e0, GLuint e1, GLuint e2, + GLuint pv) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + int vertsize = r128ctx->vertsize; + CARD32 *vb = r128AllocVertexDwords(r128ctx, + 3 * vertsize); + struct vertex_buffer *VB = ctx->VB; + r128VertexPtr r128verts = R128_DRIVER_DATA(VB)->verts; + const r128Vertex *v[3]; + int i, j; + +#if (IND & R128_OFFSET_BIT) + GLfloat offset = ctx->Polygon.OffsetUnits * r128ctx->depth_scale; +#endif + +#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT)) + int c[3]; + + c[0] = c[1] = c[2] = *(int *)&r128verts[pv].vert1.dif_argb; +#endif + + v[0] = &r128verts[e0]; + v[1] = &r128verts[e1]; + v[2] = &r128verts[e2]; + +#if (IND & (R128_TWOSIDE_BIT | R128_OFFSET_BIT)) + { + GLfloat ex = v[0]->vert1.x - v[2]->vert1.x; + GLfloat ey = v[0]->vert1.y - v[2]->vert1.y; + GLfloat fx = v[1]->vert1.x - v[2]->vert1.x; + GLfloat fy = v[1]->vert1.y - v[2]->vert1.y; + GLfloat cc = ex*fy - ey*fx; + +#if (IND & R128_TWOSIDE_BIT) + { + GLuint facing = (cc > 0.0) ^ ctx->Polygon.FrontBit; + GLubyte (*vbcolor)[4] = VB->Color[facing]->data; + if (IND & R128_FLAT_BIT) { + R128_COLOR((char *)&c[0], vbcolor[pv]); + c[2] = c[1] = c[0]; + } else { + R128_COLOR((char *)&c[0], vbcolor[e0]); + R128_COLOR((char *)&c[1], vbcolor[e1]); + R128_COLOR((char *)&c[2], vbcolor[e2]); + } + } +#endif + +#if (IND & R128_OFFSET_BIT) + { + if (cc * cc > 1e-16) { + GLfloat factor = ctx->Polygon.OffsetFactor; + GLfloat ez = v[0]->vert1.z - v[2]->vert1.z; + GLfloat fz = v[1]->vert1.z - v[2]->vert1.z; + GLfloat a = ey*fz - ez*fy; + GLfloat b = ez*fx - ex*fz; + GLfloat ic = 1.0 / cc; + GLfloat ac = a * ic; + GLfloat bc = b * ic; + if (ac < 0.0f) ac = -ac; + if (bc < 0.0f) bc = -bc; + offset += MAX2(ac, bc) * factor; + } + } +#endif + } +#endif + + for (j = 0 ; j < 3 ; j++, vb += vertsize) { + + for (i = 0 ; i < vertsize ; i++) + vb[i] = v[j]->ui[i]; + +#if (IND & (R128_FLAT_BIT|R128_TWOSIDE_BIT)) + vb[4] = c[j]; /* color is the fifth element... */ +#endif +#if (IND & R128_OFFSET_BIT) + *(float *)&vb[2] = v[j]->vert1.z + offset; +#endif + } +} + + +static void TAG(quad)(GLcontext *ctx, + GLuint v0, GLuint v1, GLuint v2, GLuint v3, + GLuint pv) +{ + TAG(triangle)(ctx, v0, v1, v3, pv); + TAG(triangle)(ctx, v1, v2, v3, pv); +} + + +/* Draw a single line. Note that the device-dependent vertex data might + need to be changed based on the render state. */ +static void TAG(line)(GLcontext *ctx, + GLuint v0, GLuint v1, + GLuint pv) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128VertexPtr r128verts = R128_DRIVER_DATA(ctx->VB)->verts; + float width = ctx->Line.Width; + + if (IND & (R128_TWOSIDE_BIT|R128_FLAT_BIT)) { + r128Vertex tmp0 = r128verts[v0]; + r128Vertex tmp1 = r128verts[v1]; + + if (IND & R128_TWOSIDE_BIT) { + GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data; + + if (IND & R128_FLAT_BIT) { + R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[pv]); + *(int *)&tmp1.vert1.dif_argb = *(int *)&tmp0.vert1.dif_argb; + } else { + R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[v0]); + R128_COLOR((char *)&tmp1.vert1.dif_argb, vbcolor[v1]); + } + } else { + *(int *)&tmp0.vert1.dif_argb = *(int *)&r128verts[pv].vert1.dif_argb; + *(int *)&tmp1.vert1.dif_argb = *(int *)&r128verts[pv].vert1.dif_argb; + } + + r128DrawLineVB( r128ctx, &tmp0, &tmp1, width ); + } + else + r128DrawLineVB( r128ctx, &r128verts[v0], &r128verts[v1], width ); +} + +/* Draw a set of points. Note that the device-dependent vertex data + might need to be changed based on the render state. */ +static void TAG(points)(GLcontext *ctx, + GLuint first, GLuint last) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + struct vertex_buffer *VB = ctx->VB; + r128VertexPtr r128verts = R128_DRIVER_DATA(VB)->verts; + GLfloat size = ctx->Point.Size * 0.5; + int i; + + for(i = first; i <= last; i++) { + if(VB->ClipMask[i] == 0) { + if (IND & R128_TWOSIDE_BIT) { + GLubyte (*vbcolor)[4] = VB->ColorPtr->data; + r128Vertex tmp0 = r128verts[i]; + R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[i]); + r128DrawPointVB( r128ctx, &tmp0, size ); + } else + r128DrawPointVB( r128ctx, &r128verts[i], size ); + } + } +} + +/* Initialize the table of primitives to render. */ +static void TAG(init)(void) +{ + tri_tab[IND] = TAG(triangle); + quad_tab[IND] = TAG(quad); + line_tab[IND] = TAG(line); + points_tab[IND] = TAG(points); +} + +#undef IND +#undef TAG diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c new file mode 100644 index 000000000..eb04e4473 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c @@ -0,0 +1,420 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#include "r128_init.h" +#include "r128_mesa.h" +#include "r128_xmesa.h" +#include "r128_context.h" +#include "r128_lock.h" +#include "r128_reg.h" +#include "r128_cce.h" +#include "r128_state.h" +#include "r128_vb.h" + +#include "stages.h" + +#define TEX0 \ +do { \ + v->vert1.tu0 = tc0[i][0]; \ + v->vert1.tv0 = tc0[i][1]; \ +} while (0) + +#define TEX1 \ +do { \ + v->vert2.tu1 = tc1[i][0]; \ + v->vert2.tv1 = tc1[i][1]; \ +} while (0) + +#define SPC \ +do { \ + GLubyte *spec = &(VB->Spec[0][i][0]); \ + v->vert1.spec_frgb.r = spec[0]; \ + v->vert1.spec_frgb.g = spec[1]; \ + v->vert1.spec_frgb.b = spec[2]; \ +} while (0) + + +#define COL \ +do { \ + GLubyte *col = &(VB->Color[0]->data[i][0]); \ + v->vert1.dif_argb.a = col[3]; \ + v->vert1.dif_argb.r = col[0]; \ + v->vert1.dif_argb.g = col[1]; \ + v->vert1.dif_argb.b = col[2]; \ +} while (0) + +#if 1 +/* FIXME: These are handled by the Rage 128 */ +#define TEX0_4 +#define TEX1_4 +#else +#define TEX0_4 \ +do { \ + if (VB->TexCoordPtr[0]->size == 4) { \ + GLfloat (*tc)[4] = VB->TexCoordPtr[0]->data; \ + v = &(R128_DRIVER_DATA(VB)->verts[start]); \ + for (i = start; i < end; i++, v++) { \ + float oow = 1.0 / tc[i][3]; \ + v->vert1.rhw *= tc[i][3]; \ + v->vert1.tu0 *= oow; \ + v->vert1.tv0 *= oow; \ + } \ + } \ +} while (0) + +#if USE_RHW2 +#define TEX1_4 \ +do { \ + if (VB->TexCoordPtr[1]->size == 4) { \ + GLfloat (*tc)[4] = VB->TexCoordPtr[1]->data; \ + v = &(R128_DRIVER_DATA(VB)->verts[start]); \ + for (i = start; i < end; i++, v++) { \ + float oow = 1.0 / tc[i][3]; \ + v->vert3.rhw2 *= tc[i][3]; \ + v->vert3.tu1 *= oow; \ + v->vert3.tv1 *= oow; \ + } \ + } \ +} while (0) +#else +#define TEX1_4 +#endif +#endif + +#if USE_RHW2 +#define COORD \ +do { \ + GLfloat *win = VB->Win.data[i]; \ + v->vert3.x = win[0]; \ + v->vert3.y = r128height - win[1]; \ + v->vert3.z = scale * win[2]; \ + v->vert3.rhw = v->vert3.rhw2 = win[3]; \ +} while (0) +#else +#define COORD \ +do { \ + GLfloat *win = VB->Win.data[i]; \ + v->vert1.x = win[0]; \ + v->vert1.y = r128height - win[1]; \ + v->vert1.z = scale * win[2]; \ + v->vert1.rhw = win[3]; \ +} while (0) +#endif + +#define NOP + +/* Setup the r128 vertex buffer entries */ +#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,spec) \ +static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \ +{ \ + r128ContextPtr r128ctx = R128_CONTEXT(VB->ctx); \ + __DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \ + r128VertexPtr v; \ + GLfloat (*tc0)[4]; \ + GLfloat (*tc1)[4]; \ + GLfloat r128height = dPriv->h; \ + GLfloat scale = r128ctx->depth_scale; \ + int i; \ + \ + (void) r128height; (void) r128ctx; (void) scale; \ + \ + gl_import_client_data(VB, VB->ctx->RenderFlags, \ + (VB->ClipOrMask \ + ? VEC_WRITABLE | VEC_GOOD_STRIDE \ + : VEC_GOOD_STRIDE)); \ + \ + tc0 = VB->TexCoordPtr[0]->data; \ + tc1 = VB->TexCoordPtr[1]->data; \ + \ + v = &(R128_DRIVER_DATA(VB)->verts[start]); \ + \ + if (VB->ClipOrMask == 0) \ + for (i = start; i < end; i++, v++) { \ + win; \ + col; \ + spec; \ + tex0; \ + tex1; \ + } \ + else \ + for (i = start; i < end; i++, v++) { \ + if (VB->ClipMask[i] == 0) { \ + win; \ + spec; \ + tex0; \ + tex1; \ + } \ + col; \ + } \ + tex0_4; \ + tex1_4; \ +} + + +SETUPFUNC(rs_wt0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP) +SETUPFUNC(rs_wt1, COORD, NOP, NOP, TEX1, NOP, TEX1_4, NOP) +SETUPFUNC(rs_wt0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP) +SETUPFUNC(rs_wg, COORD, COL, NOP, NOP, NOP, NOP, NOP) +SETUPFUNC(rs_wgs, COORD, COL, NOP, NOP, NOP, NOP, SPC) +SETUPFUNC(rs_wgt0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP) +SETUPFUNC(rs_wgt1, COORD, COL, NOP, TEX1, NOP, TEX1_4, NOP) +SETUPFUNC(rs_wgt0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP) +SETUPFUNC(rs_wgst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC) +SETUPFUNC(rs_wgst1, COORD, COL, NOP, TEX1, NOP, TEX1_4, SPC) +SETUPFUNC(rs_wgst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC) + +SETUPFUNC(rs_t0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP) +SETUPFUNC(rs_t1, NOP, NOP, NOP, TEX1, NOP, TEX1_4, NOP) +SETUPFUNC(rs_t0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP) +SETUPFUNC(rs_g, NOP, COL, NOP, NOP, NOP, NOP, NOP) +SETUPFUNC(rs_gs, NOP, COL, NOP, NOP, NOP, NOP, SPC) +SETUPFUNC(rs_gt0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP) +SETUPFUNC(rs_gt1, NOP, COL, NOP, TEX1, NOP, TEX1_4, NOP) +SETUPFUNC(rs_gt0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP) +SETUPFUNC(rs_gst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC) +SETUPFUNC(rs_gst1, NOP, COL, NOP, TEX1, NOP, TEX1_4, SPC) +SETUPFUNC(rs_gst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC) + +static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end) +{ + fprintf(stderr, "r128RasterSetup(): invalid setup function\n"); +} + +typedef void (*setupFunc)(struct vertex_buffer *, GLuint, GLuint); +static setupFunc setup_func[0x20]; + +/* Initialize the table of vertex buffer setup functions */ +void r128SetupInit(void) +{ + int i; + + for (i = 0; i < 0x20; i++) setup_func[i] = rs_invalid; + + /* Funcs to build vertices from scratch */ + setup_func[R128_WIN_BIT|R128_TEX0_BIT] = rs_wt0; + setup_func[R128_WIN_BIT|R128_TEX1_BIT] = rs_wt1; + setup_func[R128_WIN_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wt0t1; + + setup_func[R128_WIN_BIT|R128_RGBA_BIT] = rs_wg; + setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT] = rs_wgs; + setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT] = rs_wgt0; + setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX1_BIT] = rs_wgt1; + setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgt0t1; + setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgst0; + setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_wgst1; + setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgst0t1; + + + /* Funcs to repair vertices */ + setup_func[R128_TEX0_BIT] = rs_t0; + setup_func[R128_TEX1_BIT] = rs_t1; + setup_func[R128_TEX0_BIT|R128_TEX1_BIT] = rs_t0t1; + setup_func[R128_RGBA_BIT] = rs_g; + setup_func[R128_RGBA_BIT|R128_SPEC_BIT] = rs_gs; + setup_func[R128_RGBA_BIT|R128_TEX0_BIT] = rs_gt0; + setup_func[R128_RGBA_BIT|R128_TEX1_BIT] = rs_gt1; + setup_func[R128_RGBA_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gt0t1; + setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gst0; + setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_gst1; + setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gst0t1; +} + +/* Initialize the vertex buffer setup functions based on the current + rendering state */ +void r128ChooseRasterSetupFunc(GLcontext *ctx) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + int funcIndex = R128_WIN_BIT | R128_RGBA_BIT; + + r128ctx->vertsize = 8; + r128ctx->vc_format = R128_TEX0_VERTEX_FORMAT; + r128ctx->multitex = 0; + + if (ctx->Texture.Enabled & ENABLE_TEX0) { + if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE) + funcIndex &= ~R128_RGBA_BIT; + funcIndex |= R128_TEX0_BIT; + } + + if (ctx->Texture.Enabled & ENABLE_TEX1) { + /* GTH: we should really only enable the second texture unit + * when we're doing true multitexturing. I guess there aren't + * that many cases where apps will only bind a texture to the + * second texture unit, but it would definitely be a performance + * win in those cases. + */ + r128ctx->vertsize = 10; + r128ctx->vc_format = R128_TEX1_VERTEX_FORMAT; + r128ctx->multitex = 1; + funcIndex |= R128_TEX1_BIT; + } + + /* FIXME: Verify this works properly */ + if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + funcIndex |= R128_SPEC_BIT; + + r128ctx->SetupIndex = funcIndex; + ctx->Driver.RasterSetup = setup_func[funcIndex]; +} + +/* Check to see if any updates of the vertex buffer entries are needed */ +void r128CheckPartialRasterSetup(GLcontext *ctx, + struct gl_pipeline_stage *s) +{ + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + int tmp = r128ctx->SetupDone; + + s->type = 0; + r128ctx->SetupDone = GL_FALSE; + + if ((ctx->Array.Summary & VERT_OBJ_ANY) == 0) return; + if (ctx->IndirectTriangles) return; + + r128ctx->SetupDone = tmp; +} + + +/* Update the vertex buffer entries, if necessary */ +void r128PartialRasterSetup(struct vertex_buffer *VB) +{ + r128ContextPtr r128ctx = R128_CONTEXT(VB->ctx); + int new = VB->pipeline->new_outputs; + int available = VB->pipeline->outputs; + int index = 0; + + if (new & VERT_WIN) { + new = available; + index |= R128_WIN_BIT; + } + + if (new & VERT_RGBA) index |= R128_RGBA_BIT | R128_SPEC_BIT; + if (new & VERT_TEX0_ANY) index |= R128_TEX0_BIT; + if (new & VERT_TEX1_ANY) index |= R128_TEX1_BIT; + + r128ctx->SetupDone &= ~index; + index &= r128ctx->SetupIndex; + r128ctx->SetupDone |= index; + + if (index) setup_func[index](VB, VB->Start, VB->Count); +} + +/* Perform the raster setup for the fast path, if using CVA */ +void r128DoRasterSetup(struct vertex_buffer *VB) +{ + GLcontext *ctx = VB->ctx; + + if (VB->Type == VB_CVA_PRECALC) r128PartialRasterSetup(VB); + else if (ctx->Driver.RasterSetup) ctx->Driver.RasterSetup(VB, + VB->CopyStart, + VB->Count); +} + +/* Resize an existing vertex buffer */ +void r128ResizeVB(struct vertex_buffer *VB, GLuint size) +{ + r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB); + + while (r128vb->size < size) + r128vb->size *= 2; + + free(r128vb->vert_store); + r128vb->vert_store = malloc(sizeof(r128Vertex) * r128vb->size + 31); + if (!r128vb->vert_store) { + fprintf(stderr, "Cannot allocate vertex store! Exiting...\n"); + exit(1); + } + + r128vb->verts = (r128VertexPtr)(((CARD32)r128vb->vert_store + 31) & ~31); + + gl_vector1ui_free(&r128vb->clipped_elements); + gl_vector1ui_alloc(&r128vb->clipped_elements, + VEC_WRITABLE, r128vb->size, 32); + if (!r128vb->clipped_elements.start) { + fprintf(stderr, "Cannot allocate clipped elements! Exiting...\n"); + exit(1); + } + + free(VB->ClipMask); + VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size); + if (!VB->ClipMask) { + fprintf(stderr, "Cannot allocate clipmask! Exiting...\n"); + exit(1); + } +} + +/* Create a new device-dependent vertex buffer */ +void r128DDRegisterVB(struct vertex_buffer *VB) +{ + r128VertexBufferPtr r128vb; + + r128vb = (r128VertexBufferPtr)calloc(1, sizeof(*r128vb)); + + r128vb->size = VB->Size * 2; + r128vb->vert_store = malloc(sizeof(r128Vertex) * r128vb->size + 31); + if (!r128vb->vert_store) { + fprintf(stderr, "Cannot allocate vertex store! Exiting...\n"); + exit(1); + } + + r128vb->verts = (r128VertexPtr)(((CARD32)r128vb->vert_store + 31) & ~31); + + gl_vector1ui_alloc(&r128vb->clipped_elements, + VEC_WRITABLE, r128vb->size, 32); + if (!r128vb->clipped_elements.start) { + fprintf(stderr, "Cannot allocate clipped elements! Exiting...\n"); + exit(1); + } + + free(VB->ClipMask); + VB->ClipMask = (GLubyte *)malloc(sizeof(GLubyte) * r128vb->size); + if (!VB->ClipMask) { + fprintf(stderr, "Cannot allocate clipmask! Exiting...\n"); + exit(1); + } + + VB->driver_data = r128vb; +} + +/* Destroy a device-dependent vertex buffer */ +void r128DDUnregisterVB(struct vertex_buffer *VB) +{ + r128VertexBufferPtr r128vb = R128_DRIVER_DATA(VB); + + if (r128vb) { + if (r128vb->vert_store) free(r128vb->vert_store); + gl_vector1ui_free(&r128vb->clipped_elements); + free(r128vb); + VB->driver_data = 0; + } +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.h b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h new file mode 100644 index 000000000..f2244b687 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h @@ -0,0 +1,166 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifndef _R128_VB_H_ +#define _R128_VB_H_ + +#ifdef GLX_DIRECT_RENDERING + +/* FIXME: This is endian-specific */ +typedef struct { + GLubyte b; + GLubyte g; + GLubyte r; + GLubyte a; +} r128Color; + +/* Single texture vertex, single x86 cache line. + * + * GTH: This is in use now. + */ +typedef struct { + GLfloat x, y, z; /* Coordinates in screen space */ + GLfloat rhw; /* Reciprocal homogeneous w */ + r128Color dif_argb; /* Diffuse color */ + r128Color spec_frgb; /* Specular color (alpha is fog) */ + GLfloat tu0, tv0; /* Texture 0 coordinates */ +} r128_vertex1; + +/* The only vertex format in current use, but unsatisfactory for two + * reasons: + * - Not possible to implement fully conformant rendering + * with this format (projective multitexturing), + * - Performance is lower with this vertex for single-texture + * geometry, as the vertex is unnecessarily larger than + * a cacheline. + * + * Switching to single-texture vertices can be accomplished in state + * management, and is relatively trivial. Switching to the rhw2 + * format is data-dependent (are there any glTexCoord4f's in the + * current buffer). One option is to switch between single-texture + * and rhw2 vertex formats only on the standard path. + * + * The fastpath never requires the rhw2 format, as it already makes + * the data-dependent checks. + * + * GTH: This is fixed. + */ +typedef struct { + GLfloat x, y, z; /* Coordinates in screen space */ + GLfloat rhw; /* Reciprocal homogeneous w */ + r128Color dif_argb; /* Diffuse color */ + r128Color spec_frgb; /* Specular color (alpha is fog) */ + GLfloat tu0, tv0; /* Texture 0 coordinates */ + GLfloat tu1, tv1; /* Texture 1 coordinates */ +} r128_vertex2; + +/* Need to be slightly clever about flushing vertex buffers in order + * to use rhw2 only on demand. + * + * GTH: This can be used now. + */ +typedef struct { + GLfloat x, y, z; /* Coordinates in screen space */ + GLfloat rhw; /* Reciprocal homogeneous w */ + r128Color dif_argb; /* Diffuse color */ + r128Color spec_frgb; /* Specular color (alpha is fog) */ + GLfloat tu0, tv0; /* Texture 0 coordinates */ + GLfloat tu1, tv1; /* Texture 1 coordinates */ + GLfloat rhw2; /* Reciprocal homogeneous w2 */ +} r128_vertex2_rhw2; + +/* Format of vertices in r128_vertex struct */ +#define R128_TEX0_VERTEX_FORMAT \ + R128_CCE_VC_FRMT_RHW | \ + R128_CCE_VC_FRMT_DIFFUSE_ARGB | \ + R128_CCE_VC_FRMT_SPEC_FRGB | \ + R128_CCE_VC_FRMT_S_T + +#define R128_TEX1_VERTEX_FORMAT \ + R128_CCE_VC_FRMT_RHW | \ + R128_CCE_VC_FRMT_DIFFUSE_ARGB | \ + R128_CCE_VC_FRMT_SPEC_FRGB | \ + R128_CCE_VC_FRMT_S_T | \ + R128_CCE_VC_FRMT_S2_T2 + +#define R128_PROJ_TEX1_VERTEX_FORMAT \ + R128_CCE_VC_FRMT_RHW | \ + R128_CCE_VC_FRMT_DIFFUSE_ARGB | \ + R128_CCE_VC_FRMT_SPEC_FRGB | \ + R128_CCE_VC_FRMT_S_T | \ + R128_CCE_VC_FRMT_S2_T2 | \ + R128_CCE_VC_FRMT_RHW2 + + +/* FIXME: We currently only have assembly for 16-stride vertices */ +union r128_vertex_t { + r128_vertex1 vert1; + r128_vertex2 vert2; + r128_vertex2_rhw2 vert3; + float f[16]; + CARD32 ui[16]; +}; + +typedef union r128_vertex_t r128Vertex; +typedef union r128_vertex_t *r128VertexPtr; + +/* Vertex buffer for use when on the fast path */ +typedef struct { + GLuint size; /* Number of vertices in store */ + void *vert_store; /* Storage for vertex buffer */ + r128VertexPtr verts; /* Aligned start of verts in storage */ + int last_vert; /* Index of last vertex used */ + GLvector1ui clipped_elements; /* List of clipped elements */ +} *r128VertexBufferPtr; + +#define R128_DRIVER_DATA(vb) ((r128VertexBufferPtr)((vb)->driver_data)) + +#define R128_SPEC_BIT 0x01 +#define R128_TEX1_BIT 0x02 +#define R128_TEX0_BIT 0x04 +#define R128_RGBA_BIT 0x08 +#define R128_WIN_BIT 0x10 + +extern void r128SetupInit(void); +extern void r128ChooseRasterSetupFunc(GLcontext *ctx); +extern void r128CheckPartialRasterSetup(GLcontext *ctx, + struct gl_pipeline_stage *s); +extern void r128PartialRasterSetup(struct vertex_buffer *VB); +extern void r128DoRasterSetup(struct vertex_buffer *VB); +extern void r128ResizeVB(struct vertex_buffer *VB, GLuint size); +extern void r128DDRegisterVB(struct vertex_buffer *VB); +extern void r128DDUnregisterVB(struct vertex_buffer *VB); + +#endif +#endif /* _R128_VB_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c new file mode 100644 index 000000000..aae13df65 --- /dev/null +++ b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c @@ -0,0 +1,255 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * + */ + +#ifdef GLX_DIRECT_RENDERING + +/* r128 Mesa driver includes */ +#include "r128_init.h" +#include "r128_context.h" +#include "r128_xmesa.h" +#include "r128_state.h" +#include "r128_tex.h" +#include "r128_swap.h" + +/* Mesa src includes */ +#include "context.h" +#include "simple_list.h" +#include "mmath.h" + +#ifndef R128_DEBUG_FLAGS +int R128_DEBUG_FLAGS = (0 +/* | DEBUG_ALWAYS_SYNC */ +/* | DEBUG_VERBOSE_CCE */ +/* | DEBUG_VERBOSE_OUTREG */ +/* | DEBUG_VERBOSE_MSG */ +/* | DEBUG_NO_OUTRING */ +/* | DEBUG_NO_OUTREG */ +/* | DEBUG_VERBOSE_API */ +/* | DEBUG_VERBOSE_2D */ +/* | DEBUG_VERBOSE_DRI */ +/* | DEBUG_VALIDATE_RING */ +/* | DEBUG_VERBOSE_IOCTL */ + ); +#endif + +#if DEBUG_LOCKING +char *prevLockFile = NULL; +int prevLockLine = 0; +#endif + +static r128ContextPtr r128Context = NULL; + + +/* Initialize the driver specific screen private data */ +GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) +{ + sPriv->private = (void *)r128CreateScreen(sPriv); + if (!sPriv->private) { + r128DestroyScreen(sPriv); + return GL_FALSE; + } + + return GL_TRUE; +} + +/* Reset the driver specific screen private data */ +void XMesaResetDriver(__DRIscreenPrivate *sPriv) +{ + r128DestroyScreen(sPriv); +} + +/* Create and initialize the Mesa and driver specific visual data */ +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) +{ + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual(config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */); +} + +/* Create and initialize the Mesa and driver specific context data */ +GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv) +{ + return r128CreateContext(dpy, mesaVis, driContextPriv); +} + +/* Destroy the Mesa and driver specific context data */ +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) +{ + r128ContextPtr r128ctx = (r128ContextPtr)driContextPriv->driverPrivate; + + if (r128ctx == (void *)r128Context) r128Context = NULL; + r128DestroyContext(r128ctx); +} + +/* Create and initialize the Mesa and driver specific pixmap buffer data */ +GLframebuffer *XMesaCreateWindowBuffer(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) +{ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +} + +/* Create and initialize the Mesa and driver specific pixmap buffer data */ +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) +{ +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0); +#else + return NULL; /* not implemented yet */ +#endif +} + +/* Copy the back color buffer to the front color buffer */ +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) +{ + /* FIXME: This assumes buffer is currently bound to a context. This + needs to be able to swap buffers when not currently bound. Also, + this needs to swap according to buffer, and NOT according to + context! */ + if (r128Context == NULL) return; + + /* Only swap buffers when a back buffer exists */ + if (R128_MESACTX(r128Context)->Visual->DBflag) { + FLUSH_VB(R128_MESACTX(r128Context), "swap buffers"); + r128SwapBuffers(r128Context); + } +} + +/* Force the context `c' to be the current context and associate with it + buffer `b' */ +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) +{ + if (driContextPriv) { + r128ContextPtr r128ctx = (r128ContextPtr)driContextPriv->driverPrivate; + + if (r128Context && + r128ctx == (void *)r128Context && + driDrawPriv == R128_DRIDRAWABLE(r128Context)) + return GL_TRUE; + + r128Context = r128MakeCurrent(r128Context, r128ctx, driDrawPriv); + + gl_make_current2(R128_MESACTX(r128Context), + driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); + + if (!R128_MESACTX(r128Context)->Viewport.Width) { + gl_Viewport(R128_MESACTX(r128Context), 0, 0, + driDrawPriv->w, driDrawPriv->h); + } + } else { + gl_make_current(0,0); + r128Context = NULL; + } + + return GL_TRUE; +} + +/* Force the context `c' to be unbound from its buffer */ +GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) +{ + return GL_TRUE; +} + +/* Update the hardware state. This is called if another context has + grabbed the hardware lock, which includes the X server. This + function also updates the driver's window state after the X server + moves, resizes or restacks a window -- the change will be reflected + in the drawable position and clip rects. Since the X server grabs + the hardware lock when it changes the window state, this routine will + automatically be called after such a change. */ +/* NOTE: This routine is only called while holding the hardware lock. */ +void XMesaUpdateState(__DRIcontextPrivate *driContextPriv) +{ + r128ContextPtr r128ctx = driContextPriv->driverPrivate; + __DRIscreenPrivate *sPriv = R128_DRISCREEN(r128ctx); + __DRIdrawablePrivate *dPriv = R128_DRIDRAWABLE(r128ctx); + int stamp = dPriv->lastStamp; + + /* The window might have moved, so we might need to get new clip + rects. + + NOTE: This releases and regrabs the hw lock to allow the X server + to respond to the DRI protocol request for new drawable info. + Since the hardware state depends on having the latest drawable + clip rects, all state checking must be done _after_ this call. */ + XMESA_VALIDATE_DRAWABLE_INFO(r128ctx->display, sPriv, dPriv); + + r128UpdateState(r128ctx, (stamp != dPriv->lastStamp)); +} + +/* This function is called by libGL.so as soon as libGL.so is loaded. + * This is where we'd register new extension functions with the dispatcher. + */ +void __driRegisterExtensions(void) +{ +} + +#endif diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c index a225fec89..0bafa3190 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_inithw.c @@ -36,13 +36,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tdfx_init.h" #include <glide.h> -GLboolean tdfxInitHW(XMesaContext c) +GLboolean tdfxInitHW(__DRIdrawablePrivate *driDrawPriv, + tdfxContextPrivate *fxMesa) { /* KW: Would be nice to make one of these a member of the other. */ - tdfxContextPrivate *cPriv = (tdfxContextPrivate*)c->private; - tdfxContextPrivate *fxMesa = cPriv; - __DRIdrawablePrivate *driDrawPriv = c->driContextPriv->driDrawablePriv; __DRIscreenPrivate *driScrnPriv = driDrawPriv->driScreenPriv; tdfxScreenPrivate *sPriv = (tdfxScreenPrivate*)driScrnPriv->private; @@ -50,10 +48,10 @@ GLboolean tdfxInitHW(XMesaContext c) fprintf(stderr, "Debug locking enabled\n"); #endif - if (cPriv->initDone) return GL_TRUE; + if (fxMesa->initDone) return GL_TRUE; - cPriv->width=driDrawPriv->w; - cPriv->height=driDrawPriv->h; + fxMesa->width=driDrawPriv->w; + fxMesa->height=driDrawPriv->h; /* We have to use a light lock here, because we can't do any glide operations yet. No use of FX_* functions in this function. */ @@ -70,18 +68,12 @@ GLboolean tdfxInitHW(XMesaContext c) fxMesa->haveTwoTMUs=GL_TRUE; /* !!! We are forcing these !!! */ - fxMesa->haveDoubleBuffer=GL_TRUE; fxMesa->haveAlphaBuffer=GL_FALSE; - fxMesa->haveZBuffer=GL_TRUE; fxMesa->haveGlobalPaletteTexture=GL_FALSE; fxMesa->glideContext = FX_grSstWinOpen_NoLock((FxU32)-1, GR_RESOLUTION_NONE, GR_REFRESH_NONE, -#if FXMESA_USE_ARGB - GR_COLORFORMAT_ARGB, -#else GR_COLORFORMAT_ABGR, -#endif GR_ORIGIN_LOWER_LEFT, 2, 1); grDRIResetSAREA(); @@ -95,7 +87,7 @@ GLboolean tdfxInitHW(XMesaContext c) fxInitPixelTables(fxMesa, GL_FALSE); /* Load tables of pixel colors */ - cPriv->initDone=GL_TRUE; + fxMesa->initDone=GL_TRUE; return GL_TRUE; } diff --git a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c index 7fc55cb16..b40f0f054 100644 --- a/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/tdfx/tdfx_xmesa.c @@ -28,7 +28,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Daryll Strauss <daryll@precisioninsight.com> - * + * Brian E. Paul <brian@precisioninsight.com> */ #ifdef GLX_DIRECT_RENDERING @@ -37,201 +37,199 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include <glide.h> #include "tdfx_init.h" #include "context.h" -#include "vbxform.h" #include "matrix.h" +#include "mmath.h" +#include "vbxform.h" -XMesaContext nullCC = 0; -XMesaContext gCC = 0; -tdfxContextPrivate *gCCPriv = 0; -static int count_bits(unsigned int n) -{ - int bits = 0; +__DRIcontextPrivate *gCC = 0; - while (n > 0) { - if (n & 1) bits++; - n >>= 1; - } - return bits; -} -GLboolean XMesaInitDriver(__DRIscreenPrivate *driScrnPriv) +GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) { - tdfxScreenPrivate *gsp; - - /* Allocate the private area */ - gsp = (tdfxScreenPrivate *)Xmalloc(sizeof(tdfxScreenPrivate)); - if (!gsp) return GL_FALSE; - - gsp->driScrnPriv = driScrnPriv; - - driScrnPriv->private = (void *)gsp; + tdfxScreenPrivate *gsp; - if (!tdfxMapAllRegions(driScrnPriv)) { - Xfree(driScrnPriv->private); - return GL_FALSE; - } - - return GL_TRUE; -} - -void XMesaResetDriver(__DRIscreenPrivate *driScrnPriv) -{ - tdfxUnmapAllRegions(driScrnPriv); - Xfree(driScrnPriv->private); -} + /* Check the DRI version */ + { + int major, minor, patch; + if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) { + if (major != 3 || minor != 0 || patch < 0) { + char msg[1000]; + sprintf(msg, "3dfx DRI driver expected DRI version 3.0.x but got version %d.%d.%d", major, minor, patch); + __driMesaMessage(msg); + return GL_FALSE; + } + } + } -XMesaVisual XMesaCreateVisual(XMesaDisplay *display, - XMesaVisualInfo visinfo, - GLboolean rgb_flag, - GLboolean alpha_flag, - GLboolean db_flag, - GLboolean stereo_flag, - GLboolean ximage_flag, - GLint depth_size, - GLint stencil_size, - GLint accum_size, - GLint level) -{ - XMesaVisual v; + /* Check that the DDX driver version is compatible */ + if (sPriv->ddxMajor != 1 || + sPriv->ddxMinor != 0 || + sPriv->ddxPatch < 0) { + char msg[1000]; + sprintf(msg, "3dfx DRI driver expected DDX driver version 1.0.x but got version %d.%d.%d", sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch); + __driMesaMessage(msg); + return GL_FALSE; + } - /* Only RGB visuals are supported on the TDFX boards */ - if (!rgb_flag) return 0; + /* Check that the DRM driver version is compatible */ + if (sPriv->drmMajor != 1 || + sPriv->drmMinor != 0 || + sPriv->drmPatch < 0) { + char msg[1000]; + sprintf(msg, "3dfx DRI driver expected DRM driver version 1.0.x but got version %d.%d.%d", sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); + __driMesaMessage(msg); + return GL_FALSE; + } - v = (XMesaVisual)Xmalloc(sizeof(struct xmesa_visual)); - if (!v) return 0; + /* Allocate the private area */ + gsp = (tdfxScreenPrivate *)Xmalloc(sizeof(tdfxScreenPrivate)); + if (!gsp) + return GL_FALSE; - v->visinfo = (XVisualInfo *)Xmalloc(sizeof(*visinfo)); - if(!v->visinfo) { - Xfree(v); - return 0; - } - memcpy(v->visinfo, visinfo, sizeof(*visinfo)); - - v->display = display; - v->level = level; - - v->gl_visual = (GLvisual *)Xmalloc(sizeof(GLvisual)); - if (!v->gl_visual) { - Xfree(v->visinfo); - XFree(v); - return 0; - } + gsp->driScrnPriv = sPriv; - v->gl_visual->RGBAflag = rgb_flag; - v->gl_visual->DBflag = db_flag; - v->gl_visual->StereoFlag = stereo_flag; + sPriv->private = (void *) gsp; - v->gl_visual->RedBits = count_bits(visinfo->red_mask); - v->gl_visual->GreenBits = count_bits(visinfo->green_mask); - v->gl_visual->BlueBits = count_bits(visinfo->blue_mask); - v->gl_visual->AlphaBits = 0; /* Not currently supported */ + if (!tdfxMapAllRegions(sPriv)) { + Xfree(gsp); + sPriv->private = NULL; + return GL_FALSE; + } - v->gl_visual->AccumBits = accum_size; - v->gl_visual->DepthBits = depth_size; - v->gl_visual->StencilBits = stencil_size; + return GL_TRUE; +} - return v; +void XMesaResetDriver(__DRIscreenPrivate *sPriv) +{ + tdfxUnmapAllRegions(sPriv); + Xfree(sPriv->private); + sPriv->private = NULL; } -void XMesaDestroyVisual(XMesaVisual v) +GLvisual *XMesaCreateVisual(Display *dpy, + __DRIscreenPrivate *driScrnPriv, + const XVisualInfo *visinfo, + const __GLXvisualConfig *config) { - Xfree(v->gl_visual); - Xfree(v->visinfo); - Xfree(v); + /* Drivers may change the args to _mesa_create_visual() in order to + * setup special visuals. + */ + return _mesa_create_visual( config->rgba, + config->doubleBuffer, + config->stereo, + _mesa_bitcount(visinfo->red_mask), + _mesa_bitcount(visinfo->green_mask), + _mesa_bitcount(visinfo->blue_mask), + config->alphaSize, + 0, /* index bits */ + config->depthSize, + config->stencilSize, + config->accumRedSize, + config->accumGreenSize, + config->accumBlueSize, + config->accumAlphaSize, + 0 /* num samples */ ); } -XMesaContext XMesaCreateContext(XMesaVisual v, XMesaContext share_list, - __DRIcontextPrivate *driContextPriv) + +GLboolean XMesaCreateContext(Display *dpy, GLvisual *mesaVis, + __DRIcontextPrivate *driContextPriv) { - XMesaContext c; tdfxContextPrivate *cPriv; __DRIscreenPrivate *driScrnPriv = driContextPriv->driScreenPriv; tdfxScreenPrivate *sPriv = (tdfxScreenPrivate *)driScrnPriv->private; TDFXSAREAPriv *saPriv; - GLcontext *shareCtx; - int **fifoPtr; - - c = (XMesaContext)Xmalloc(sizeof(struct xmesa_context)); - if (!c) return 0; - - c->driContextPriv = driContextPriv; - c->xm_visual = v; - c->xm_buffer = 0; /* Set by MakeCurrent */ - c->display = v->display; + /*int **fifoPtr;*/ cPriv = (tdfxContextPrivate *)Xmalloc(sizeof(tdfxContextPrivate)); if (!cPriv) { - Xfree(c); - return NULL; + return GL_FALSE; } cPriv->hHWContext = driContextPriv->hHWContext; cPriv->tdfxScrnPriv = sPriv; - c->private = (void *)cPriv; - - cPriv->glVis=v->gl_visual; - cPriv->glBuffer=gl_create_framebuffer(v->gl_visual, - GL_FALSE, /* software depth buffer? */ - v->gl_visual->StencilBits > 0, - v->gl_visual->AccumBits > 0, - v->gl_visual->AlphaBits > 0 - ); + /* deviceID = 0x05 = Voodoo3 */ + /* deviceID = 0x09 = Voodoo5 (and Voodoo5?) */ + cPriv->haveHwStencil = sPriv->deviceID == 0x9 && sPriv->cpp == 4; + + cPriv->glVis=mesaVis; + cPriv->glBuffer=gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0 && !cPriv->haveHwStencil, + mesaVis->AccumRedBits > 0, + GL_FALSE /* software alpha channel */ + ); cPriv->screen_width=sPriv->width; cPriv->screen_height=sPriv->height; - cPriv->new_state = ~0; - if (share_list) - shareCtx=((tdfxContextPrivate*)(share_list->private))->glCtx; - else - shareCtx=0; - cPriv->glCtx=gl_create_context(v->gl_visual, shareCtx, (void*)cPriv, GL_TRUE); + cPriv->glCtx = driContextPriv->mesaContext; cPriv->initDone=GL_FALSE; - saPriv=(TDFXSAREAPriv*)((void*)driScrnPriv->pSAREA+sizeof(XF86DRISAREARec)); + saPriv=(TDFXSAREAPriv*)((char*)driScrnPriv->pSAREA+sizeof(XF86DRISAREARec)); grDRIOpen(driScrnPriv->pFB, sPriv->regs.map, sPriv->deviceID, sPriv->width, sPriv->height, sPriv->mem, sPriv->cpp, sPriv->stride, sPriv->fifoOffset, sPriv->fifoSize, sPriv->fbOffset, sPriv->backOffset, sPriv->depthOffset, sPriv->textureOffset, sPriv->textureSize, &saPriv->fifoPtr, &saPriv->fifoRead); - return c; + driContextPriv->driverPrivate = (void *) cPriv; + + return GL_TRUE; } -void XMesaDestroyContext(XMesaContext c) +void XMesaDestroyContext(__DRIcontextPrivate *driContextPriv) { - tdfxContextPrivate *cPriv; - - cPriv=(tdfxContextPrivate*)c->private; + tdfxContextPrivate *cPriv = (tdfxContextPrivate *) driContextPriv->driverPrivate; if (cPriv) { - gl_destroy_context(cPriv->glCtx); - gl_destroy_framebuffer(cPriv->glBuffer); + XFree(cPriv); + driContextPriv->driverPrivate = NULL; } - if (c==gCC) { - gCC=0; - gCCPriv=0; + + if (driContextPriv == gCC) { + gCC = 0; } } -XMesaBuffer XMesaCreateWindowBuffer(XMesaVisual v, XMesaWindow w, - __DRIdrawablePrivate *driDrawPriv) -{ - return (XMesaBuffer)1; -} -XMesaBuffer XMesaCreatePixmapBuffer(XMesaVisual v, XMesaPixmap p, - XMesaColormap c, __DRIdrawablePrivate *driDrawPriv) +GLframebuffer *XMesaCreateWindowBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { - return (XMesaBuffer)1; + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + GL_FALSE /* software alpha channel? */ + ); } -void XMesaDestroyBuffer(XMesaBuffer b) + +GLframebuffer *XMesaCreatePixmapBuffer( Display *dpy, + __DRIscreenPrivate *driScrnPriv, + __DRIdrawablePrivate *driDrawPriv, + GLvisual *mesaVis) { +#if 0 + /* Different drivers may have different combinations of hardware and + * software ancillary buffers. + */ + return gl_create_framebuffer(mesaVis, + GL_FALSE, /* software depth buffer? */ + mesaVis->StencilBits > 0, + mesaVis->AccumRedBits > 0, + mesaVis->AlphaBits > 0 + ); +#else + return NULL; /* not implemented yet */ +#endif } -void XMesaSwapBuffers(XMesaBuffer b) + +void XMesaSwapBuffers(__DRIdrawablePrivate *driDrawPriv) { FxI32 result; #ifdef STATS @@ -239,15 +237,20 @@ void XMesaSwapBuffers(XMesaBuffer b) extern int texSwaps; static int prevStalls=0; #endif + tdfxContextPrivate *gCCPriv; + /* ** NOT_DONE: This assumes buffer is currently bound to a context. ** This needs to be able to swap buffers when not currently bound. */ - if (gCC == NULL || gCCPriv == NULL) return; + if (gCC == NULL) + return; + + gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; FLUSH_VB( gCCPriv->glCtx, "swap buffers" ); - if (gCCPriv->haveDoubleBuffer) { + if (gCC->mesaContext->Visual->DBflag) { #ifdef STATS stalls=grFifoGetStalls(); if (stalls!=prevStalls) { @@ -261,59 +264,65 @@ void XMesaSwapBuffers(XMesaBuffer b) #endif FX_grDRIBufferSwap(gCCPriv->swapInterval); do { - result=FX_grGetInteger(FX_PENDING_BUFFERSWAPS); - } while (result>gCCPriv->maxPendingSwapBuffers); + result = FX_grGetInteger(FX_PENDING_BUFFERSWAPS); + } while (result > gCCPriv->maxPendingSwapBuffers); gCCPriv->stats.swapBuffer++; - } else { - fprintf(stderr, "No double buffer\n"); } } -GLboolean XMesaUnbindContext(XMesaContext c) +GLboolean XMesaUnbindContext(__DRIcontextPrivate *driContextPriv) { - if (c && c==gCC && gCCPriv) FX_grGlideGetState((GrState*)gCCPriv->state); - return GL_TRUE; + if (driContextPriv && driContextPriv == gCC) { + tdfxContextPrivate *gCCPriv; + gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; + FX_grGlideGetState((GrState*)gCCPriv->state); + } + return GL_TRUE; } -GLboolean XMesaMakeCurrent(XMesaContext c, XMesaBuffer b) +GLboolean XMesaMakeCurrent(__DRIcontextPrivate *driContextPriv, + __DRIdrawablePrivate *driDrawPriv, + __DRIdrawablePrivate *driReadPriv) { - __DRIdrawablePrivate *driDrawPriv; + if (driContextPriv) { + tdfxContextPrivate *gCCPriv; - if (c) { - if (c==gCC) return GL_TRUE; - gCC = c; - gCCPriv = (tdfxContextPrivate *)c->private; + gCC = driContextPriv; + gCCPriv = (tdfxContextPrivate *)driContextPriv->driverPrivate; - driDrawPriv = gCC->driContextPriv->driDrawablePriv; if (!gCCPriv->initDone) { - if (!tdfxInitHW(c)) return GL_FALSE; + if (!tdfxInitHW(driDrawPriv, gCCPriv)) + return GL_FALSE; gCCPriv->width=0; XMesaWindowMoved(); FX_grGlideGetState((GrState*)gCCPriv->state); - } else { + } + else { FX_grSstSelect(gCCPriv->board); FX_grGlideSetState((GrState*)gCCPriv->state); XMesaWindowMoved(); } - gl_make_current(gCCPriv->glCtx, gCCPriv->glBuffer); + gl_make_current2(gCCPriv->glCtx, driDrawPriv->mesaBuffer, driReadPriv->mesaBuffer); + fxSetupDDPointers(gCCPriv->glCtx); if (!gCCPriv->glCtx->Viewport.Width) gl_Viewport(gCCPriv->glCtx, 0, 0, driDrawPriv->w, driDrawPriv->h); - } else { + } + else { gl_make_current(0,0); - gCC = NULL; - gCCPriv = NULL; + gCC = NULL; } return GL_TRUE; } -void -XMesaWindowMoved() { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; - GLcontext *ctx; - - ctx=gCCPriv->glCtx; + +void XMesaWindowMoved(void) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; + tdfxContextPrivate *gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; + GLcontext *ctx = gCCPriv->glCtx; + grDRIPosition(dPriv->x, dPriv->y, dPriv->w, dPriv->h, dPriv->numClipRects, dPriv->pClipRects); gCCPriv->numClipRects=dPriv->numClipRects; @@ -326,6 +335,7 @@ XMesaWindowMoved() { gCCPriv->height=dPriv->h; gCCPriv->y_delta=gCCPriv->screen_height-gCCPriv->y_offset-gCCPriv->height; } + gCCPriv->needClip=1; switch (dPriv->numClipRects) { case 0: gCCPriv->clipMinX=dPriv->x; @@ -344,14 +354,15 @@ XMesaWindowMoved() { gCCPriv->needClip=0; break; default: - gCCPriv->needClip=1; } } /* This is called from within the LOCK_HARDWARE routine */ -void XMesaUpdateState(int windowMoved) { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; +void XMesaUpdateState(int windowMoved) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; + tdfxContextPrivate *gCCPriv = (tdfxContextPrivate *) gCC->driverPrivate; TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec)); /* fprintf(stderr, "In FifoPtr=%d FifoRead=%d\n", saPriv->fifoPtr, saPriv->fifoRead); */ @@ -376,8 +387,9 @@ void XMesaUpdateState(int windowMoved) { XMesaWindowMoved(); } -void XMesaSetSAREA() { - __DRIdrawablePrivate *dPriv = gCC->driContextPriv->driDrawablePriv; +void XMesaSetSAREA(void) +{ + __DRIdrawablePrivate *dPriv = gCC->driDrawablePriv; __DRIscreenPrivate *sPriv = dPriv->driScreenPriv; TDFXSAREAPriv *saPriv=(TDFXSAREAPriv*)(((char*)sPriv->pSAREA)+sizeof(XF86DRISAREARec)); diff --git a/xc/programs/Xserver/GL/dri/dri.c b/xc/programs/Xserver/GL/dri/dri.c index 68e638f27..1d3eeee37 100644 --- a/xc/programs/Xserver/GL/dri/dri.c +++ b/xc/programs/Xserver/GL/dri/dri.c @@ -93,15 +93,12 @@ DRIDrvMsg(int scrnIndex, MessageType type, const char *format, ...) } Bool -DRIScreenInit( - ScreenPtr pScreen, - DRIInfoPtr pDRIInfo, - int* pDRMFD) +DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) { DRIScreenPrivPtr pDRIPriv; drmContextPtr reserved; int reserved_count; - int i; + int i, fd, drmWasAvailable; if (DRIGeneration != serverGeneration) { if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0) @@ -109,28 +106,38 @@ DRIScreenInit( DRIGeneration = serverGeneration; } - if (!drmAvailable()) { - return FALSE; + drmWasAvailable = drmAvailable(); + + /* Note that drmOpen will try to load the kernel module, if needed. */ + fd = drmOpen(pDRIInfo->drmDriverName, NULL); + if (fd < 0) { + /* failed to open DRM */ + pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + return FALSE; } - if (!(pDRIPriv = (DRIScreenPrivPtr)xalloc(sizeof(DRIScreenPrivRec)))) { - return FALSE; + if (!drmWasAvailable) { + /* drmOpen loaded the kernel module, print a message to say so */ + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] loaded kernel module \"%s\"\n", + pDRIInfo->drmDriverName); } - pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer)pDRIPriv; + pDRIPriv = (DRIScreenPrivPtr) xalloc(sizeof(DRIScreenPrivRec)); + if (!pDRIPriv) { + pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + return FALSE; + } + + pScreen->devPrivates[DRIScreenPrivIndex].ptr = (pointer) pDRIPriv; + pDRIPriv->drmFD = fd; pDRIPriv->directRenderingSupport = TRUE; pDRIPriv->pDriverInfo = pDRIInfo; - - /* setup device independent direct rendering memory maps */ - - if ((pDRIPriv->drmFD = drmOpen(pDRIPriv->pDriverInfo->drmDriverName, - NULL)) < 0) { - pDRIPriv->directRenderingSupport = FALSE; - return FALSE; - } + pDRIPriv->nrWindows = 0; if (drmSetBusid(pDRIPriv->drmFD, pDRIPriv->pDriverInfo->busIdString) < 0) { pDRIPriv->directRenderingSupport = FALSE; + pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmClose(pDRIPriv->drmFD); return FALSE; } @@ -149,6 +156,7 @@ DRIScreenInit( &pDRIPriv->hSAREA) < 0) { pDRIPriv->directRenderingSupport = FALSE; + pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmClose(pDRIPriv->drmFD); return FALSE; } @@ -162,6 +170,7 @@ DRIScreenInit( (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0) { pDRIPriv->directRenderingSupport = FALSE; + pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmClose(pDRIPriv->drmFD); return FALSE; } @@ -176,6 +185,7 @@ DRIScreenInit( &pDRIPriv->hFrameBuffer) < 0) { pDRIPriv->directRenderingSupport = FALSE; + pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize); drmClose(pDRIPriv->drmFD); return FALSE; @@ -334,8 +344,9 @@ DRIFinishScreenInit(ScreenPtr pScreen) pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow; } - miClipNotify(DRIClipNotify); - + if (pDRIInfo->wrap.ClipNotify) + miClipNotify(pDRIInfo->wrap.ClipNotify); + DRIDrvMsg(pScreen->myNum, X_INFO, "[DRI] installation complete\n"); return TRUE; @@ -432,8 +443,7 @@ DRIExtensionInit(void) } void -DRIReset( -) +DRIReset(void) { /* * This stub routine is called when the X Server recycles, resources @@ -445,10 +455,7 @@ DRIReset( } Bool -DRIQueryDirectRenderingCapable( - ScreenPtr pScreen, - Bool* isCapable -) +DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -461,11 +468,7 @@ DRIQueryDirectRenderingCapable( } Bool -DRIOpenConnection( - ScreenPtr pScreen, - drmHandlePtr hSAREA, - char **busIdString -) +DRIOpenConnection(ScreenPtr pScreen, drmHandlePtr hSAREA, char **busIdString) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -476,10 +479,7 @@ DRIOpenConnection( } Bool -DRIAuthConnection( - ScreenPtr pScreen, - drmMagic magic -) +DRIAuthConnection(ScreenPtr pScreen, drmMagic magic) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -488,23 +488,17 @@ DRIAuthConnection( } Bool -DRICloseConnection( - ScreenPtr pScreen -) +DRICloseConnection(ScreenPtr pScreen) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - return TRUE; } Bool -DRIGetClientDriverName( - ScreenPtr pScreen, - int* ddxDriverMajorVersion, - int* ddxDriverMinorVersion, - int* ddxDriverPatchVersion, - char** clientDriverName -) +DRIGetClientDriverName(ScreenPtr pScreen, + int *ddxDriverMajorVersion, + int *ddxDriverMinorVersion, + int *ddxDriverPatchVersion, + char **clientDriverName) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -616,11 +610,8 @@ DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv) } Bool -DRICreateContext( - ScreenPtr pScreen, - VisualPtr visual, - XID context, - drmContextPtr pHWContext +DRICreateContext(ScreenPtr pScreen, VisualPtr visual, + XID context, drmContextPtr pHWContext ) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -652,7 +643,7 @@ DRICreateContext( visual, *pHWContext, *pVisualConfigPriv, - contextStore))) { + (int)contextStore))) { DRIDestroyContextPriv(pDRIContextPriv); return FALSE; } @@ -665,10 +656,7 @@ DRICreateContext( } Bool -DRIDestroyContext( - ScreenPtr pScreen, - XID context -) +DRIDestroyContext(ScreenPtr pScreen, XID context) { FreeResourceByType(context, DRIContextPrivResType, FALSE); @@ -677,9 +665,7 @@ DRIDestroyContext( /* DRIContextPrivDelete is called by the resource manager. */ Bool -DRIContextPrivDelete( - pointer pResource, - XID id) +DRIContextPrivDelete(pointer pResource, XID id) { DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr)pResource; DRIScreenPrivPtr pDRIPriv; @@ -689,19 +675,75 @@ DRIContextPrivDelete( if (pDRIPriv->pDriverInfo->DestroyContext) { contextStore=DRIGetContextStore(pDRIContextPriv); (pDRIPriv->pDriverInfo->DestroyContext)(pDRIContextPriv->pScreen, - pDRIContextPriv->hwContext, - contextStore); + pDRIContextPriv->hwContext, + (int)contextStore); } return DRIDestroyContextPriv(pDRIContextPriv); } + +/* This walks the drawable timestamp array and invalidates all of them + * in the case of transition from private to shared backbuffers. It's + * not necessary for correctness, because DRIClipNotify gets called in + * time to prevent any conflict, but the transition from + * shared->private is sometimes missed if we don't do this. + */ +static void +DRIClipNotifyAllDrawables(ScreenPtr pScreen) +{ + int i; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) { + pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++; + } +} + + +static void +DRITransitionToSharedBuffers(ScreenPtr pScreen) +{ +/* ErrorF("DRITransitionToSharedBuffers\n"); */ + DRIClipNotifyAllDrawables( pScreen ); +} + + +static void +DRITransitionToPrivateBuffers(ScreenPtr pScreen) +{ +/* ErrorF("DRITransitionToPrivateBuffers\n"); */ + DRIClipNotifyAllDrawables( pScreen ); +} + + +static void +DRITransitionTo3d(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + +/* ErrorF("DRITransitionTo3d\n"); */ + + if (pDRIInfo->TransitionTo3d) + pDRIInfo->TransitionTo3d( pScreen ); +} + +static void +DRITransitionTo2d(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + +/* ErrorF("DRITransitionTo2d\n"); */ + + if (pDRIInfo->TransitionTo2d) + pDRIInfo->TransitionTo2d( pScreen ); +} + + Bool -DRICreateDrawable( - ScreenPtr pScreen, - Drawable id, - DrawablePtr pDrawable, - drmDrawablePtr hHWDrawable -) +DRICreateDrawable(ScreenPtr pScreen, Drawable id, + DrawablePtr pDrawable, drmDrawablePtr hHWDrawable) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv; @@ -734,6 +776,17 @@ DRICreateDrawable( pWin->devPrivates[DRIWindowPrivIndex].ptr = (pointer)pDRIDrawablePriv; + switch (++pDRIPriv->nrWindows) { + case 1: + DRITransitionTo3d( pScreen ); + break; + case 2: + DRITransitionToSharedBuffers( pScreen ); + break; + default: + break; + } + /* track this in case this window is destroyed */ AddResource(id, DRIDrawablePrivResType, (pointer)pWin); } @@ -747,22 +800,19 @@ DRICreateDrawable( } Bool -DRIDestroyDrawable( - ScreenPtr pScreen, - Drawable id, - DrawablePtr pDrawable -) +DRIDestroyDrawable(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable) { DRIDrawablePrivPtr pDRIDrawablePriv; WindowPtr pWin; + if (pDrawable->type == DRAWABLE_WINDOW) { pWin = (WindowPtr)pDrawable; pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); pDRIDrawablePriv->refCount--; if (pDRIDrawablePriv->refCount <= 0) { /* This calls back DRIDrawablePrivDelete which frees private area */ - FreeResourceByType(id, DRIDrawablePrivResType, FALSE); + FreeResourceByType(id, DRIDrawablePrivResType, FALSE); } } else { /* pixmap (or for GLX 1.3, a PBuffer) */ @@ -774,9 +824,7 @@ DRIDestroyDrawable( } Bool -DRIDrawablePrivDelete( - pointer pResource, - XID id) +DRIDrawablePrivDelete(pointer pResource, XID id) { DrawablePtr pDrawable = (DrawablePtr)pResource; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen); @@ -798,6 +846,17 @@ DRIDrawablePrivDelete( } xfree(pDRIDrawablePriv); pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL; + + switch (--pDRIPriv->nrWindows) { + case 0: + DRITransitionTo2d( pDrawable->pScreen ); + break; + case 1: + DRITransitionToPrivateBuffers( pDrawable->pScreen ); + break; + default: + break; + } } else { /* pixmap (or for GLX 1.3, a PBuffer) */ /* NOT_DONE */ @@ -808,24 +867,27 @@ DRIDrawablePrivDelete( } Bool -DRIGetDrawableInfo( - ScreenPtr pScreen, - DrawablePtr pDrawable, - unsigned int* index, - unsigned int* stamp, - int* X, - int* Y, - int* W, - int* H, - int* numClipRects, - XF86DRIClipRectPtr* pClipRects -) +DRIGetDrawableInfo(ScreenPtr pScreen, + DrawablePtr pDrawable, + unsigned int* index, + unsigned int* stamp, + int* X, + int* Y, + int* W, + int* H, + int* numClipRects, + XF86DRIClipRectPtr* pClipRects, + int* backX, + int* backY, + int* numBackClipRects, + XF86DRIClipRectPtr* pBackClipRects) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv; WindowPtr pWin, pOldWin; - int i, oldestIndex = 0; - unsigned int oldestStamp; + int i; + + printf("maxDrawableTableEntry = %d\n", pDRIPriv->pDriverInfo->maxDrawableTableEntry); if (pDrawable->type == DRAWABLE_WINDOW) { pWin = (WindowPtr)pDrawable; @@ -849,7 +911,8 @@ DRIGetDrawableInfo( /* Search table for oldest entry */ if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) { - oldestStamp = ~0; + unsigned int oldestStamp = ~0; + int oldestIndex = 0; i = pDRIPriv->pDriverInfo->maxDrawableTableEntry; while (i--) { if (pDRIPriv->pSAREA->drawableTable[i].stamp < @@ -867,10 +930,10 @@ DRIGetDrawableInfo( pOldDrawPriv->drawableIndex = -1; /* claim drawable table entry */ - pDRIPriv->DRIDrawables[i] = pDrawable; + pDRIPriv->DRIDrawables[oldestIndex] = pDrawable; /* validate SAREA entry */ - pDRIPriv->pSAREA->drawableTable[i].stamp = + pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp = DRIDrawableValidationStamp++; /* check for stamp wrap around */ @@ -907,6 +970,35 @@ DRIGetDrawableInfo( *H = (int)(pWin->drawable.height); *numClipRects = REGION_NUM_RECTS(&pWin->clipList); *pClipRects = (XF86DRIClipRectPtr)REGION_RECTS(&pWin->clipList); + + *backX = *X; + *backY = *Y; + + if (pDRIPriv->nrWindows == 1 && *numClipRects) { + /* Use a single cliprect. */ + + int x0 = *X; + int y0 = *Y; + int x1 = x0 + *W; + int y1 = y0 + *H; + + if (x0 < 0) x0 = 0; + if (y0 < 0) y0 = 0; + if (x1 > pScreen->width-1) x1 = pScreen->width-1; + if (y1 > pScreen->height-1) y1 = pScreen->height-1; + + pDRIPriv->private_buffer_rect.x1 = x0; + pDRIPriv->private_buffer_rect.y1 = y0; + pDRIPriv->private_buffer_rect.x2 = x1; + pDRIPriv->private_buffer_rect.y2 = y1; + + *numBackClipRects = 1; + *pBackClipRects = &(pDRIPriv->private_buffer_rect); + } else { + /* Use the frontbuffer cliprects for back buffers. */ + *numBackClipRects = 0; + *pBackClipRects = 0; + } } else { /* Not a DRIDrawable */ @@ -922,15 +1014,13 @@ DRIGetDrawableInfo( } Bool -DRIGetDeviceInfo( - ScreenPtr pScreen, - drmHandlePtr hFrameBuffer, - int* fbOrigin, - int* fbSize, - int* fbStride, - int* devPrivateSize, - void** pDevPrivate -) +DRIGetDeviceInfo(ScreenPtr pScreen, + drmHandlePtr hFrameBuffer, + int* fbOrigin, + int* fbSize, + int* fbStride, + int* devPrivateSize, + void** pDevPrivate) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -961,6 +1051,10 @@ DRICreateInfoRec(void) inforec->wrap.CopyWindow = DRICopyWindow; inforec->wrap.ValidateTree = DRIValidateTree; inforec->wrap.PostValidateTree = DRIPostValidateTree; + inforec->wrap.ClipNotify = DRIClipNotify; + + inforec->TransitionTo2d = 0; + inforec->TransitionTo3d = 0; return inforec; } @@ -972,11 +1066,9 @@ DRIDestroyInfoRec(DRIInfoPtr DRIInfo) xfree((char*)DRIInfo); } + void -DRIWakeupHandler( - pointer wakeupData, - int result, - pointer pReadmask) +DRIWakeupHandler(pointer wakeupData, int result, pointer pReadmask) { int i; @@ -992,10 +1084,7 @@ DRIWakeupHandler( } void -DRIBlockHandler( - pointer blockData, - OSTimePtr pTimeout, - pointer pReadmask) +DRIBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask) { int i; @@ -1011,11 +1100,8 @@ DRIBlockHandler( } void -DRIDoWakeupHandler( - int screenNum, - pointer wakeupData, - unsigned long result, - pointer pReadmask) +DRIDoWakeupHandler(int screenNum, pointer wakeupData, + unsigned long result, pointer pReadmask) { ScreenPtr pScreen = screenInfo.screens[screenNum]; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -1033,11 +1119,8 @@ DRIDoWakeupHandler( } void -DRIDoBlockHandler( - int screenNum, - pointer blockData, - pointer pTimeout, - pointer pReadmask) +DRIDoBlockHandler(int screenNum, pointer blockData, + pointer pTimeout, pointer pReadmask) { ScreenPtr pScreen = screenInfo.screens[screenNum]; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -1055,11 +1138,7 @@ DRIDoBlockHandler( } void -DRISwapContext( - int drmFD, - void *oldctx, - void *newctx -) +DRISwapContext(int drmFD, void *oldctx, void *newctx) { DRIContextPrivPtr oldContext = (DRIContextPrivPtr)oldctx; DRIContextPrivPtr newContext = (DRIContextPrivPtr)newctx; @@ -1214,10 +1293,7 @@ DRIGetContextStore(DRIContextPrivPtr context) } void -DRIPaintWindow( - WindowPtr pWin, - RegionPtr prgn, - int what) +DRIPaintWindow(WindowPtr pWin, RegionPtr prgn, int what) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -1279,10 +1355,7 @@ DRIPaintWindow( } void -DRICopyWindow( - WindowPtr pWin, - DDXPointRec ptOldOrg, - RegionPtr prgnSrc) +DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -1376,10 +1449,7 @@ DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */) } int -DRIValidateTree( - WindowPtr pParent, - WindowPtr pChild, - VTKind kind) +DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) { ScreenPtr pScreen = pParent->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -1434,10 +1504,7 @@ DRIValidateTree( } void -DRIPostValidateTree( - WindowPtr pParent, - WindowPtr pChild, - VTKind kind) +DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) { ScreenPtr pScreen; DRIScreenPrivPtr pDRIPriv; @@ -1468,10 +1535,7 @@ DRIPostValidateTree( } void -DRIClipNotify( - WindowPtr pWin, - int dx, - int dy) +DRIClipNotify(WindowPtr pWin, int dx, int dy) { DRIScreenPrivPtr pDRIPriv; DRIDrawablePrivPtr pDRIDrawablePriv; @@ -1484,8 +1548,7 @@ DRIClipNotify( } CARD32 -DRIGetDrawableIndex( - WindowPtr pWin) +DRIGetDrawableIndex(WindowPtr pWin) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -1502,10 +1565,26 @@ DRIGetDrawableIndex( return index; } +unsigned int +DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + return pDRIPriv->pSAREA->drawableTable[drawable_index].stamp; +} + + void -DRILock(ScreenPtr pScreen, int flags) { +DRIPrintDrawableLock(ScreenPtr pScreen, char *msg) +{ DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + + ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock); +} +void +DRILock(ScreenPtr pScreen, int flags) { + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + if (!lockRefCount) DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext, flags); lockRefCount++; @@ -1528,17 +1607,38 @@ DRIUnlock(ScreenPtr pScreen) { DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pSAREA, pDRIPriv->myContext); } -void *DRIGetSAREAPrivate(ScreenPtr pScreen) +void * +DRIGetSAREAPrivate(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (!pDRIPriv) return 0; - return ((void*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec); + return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec)); } -drmContext DRIGetContext(ScreenPtr pScreen) +drmContext +DRIGetContext(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (!pDRIPriv) return 0; return pDRIPriv->myContext; } +/* This lets get at the unwrapped functions so that they can correctly + * call the lowerlevel functions, and choose whether they will be + * called at every level of recursion (eg in validatetree). + */ +DRIWrappedFuncsRec * +DRIGetWrappedFuncs(ScreenPtr pScreen) +{ + return &(DRI_SCREEN_PRIV(pScreen)->wrap); +} + +void +DRIQueryVersion(int *majorVersion, + int *minorVersion, + int *patchVersion) +{ + *majorVersion = XF86DRI_MAJOR_VERSION; + *minorVersion = XF86DRI_MINOR_VERSION; + *patchVersion = XF86DRI_PATCH_VERSION; +} diff --git a/xc/programs/Xserver/GL/dri/dri.h b/xc/programs/Xserver/GL/dri/dri.h index d82ec5359..443ba5e30 100644 --- a/xc/programs/Xserver/GL/dri/dri.h +++ b/xc/programs/Xserver/GL/dri/dri.h @@ -69,6 +69,10 @@ typedef int DRIWindowRequests; #define DRI_3D_WINDOWS_ONLY 1 #define DRI_ALL_WINDOWS 2 + +typedef void (*ClipNotifyPtr)( WindowPtr, int, int ); + + /* * These functions can be wrapped by the DRI. Each of these have * generic default funcs (initialized in DRICreateInfoRec) and can be @@ -82,8 +86,12 @@ typedef struct { CopyWindowProcPtr CopyWindow; ValidateTreeProcPtr ValidateTree; PostValidateTreeProcPtr PostValidateTree; + ClipNotifyPtr ClipNotify; } DRIWrappedFuncsRec, *DRIWrappedFuncsPtr; + + + typedef struct { /* driver call back functions */ Bool (*CreateContext)(ScreenPtr pScreen, @@ -107,6 +115,8 @@ typedef struct { DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index); + void (*TransitionTo3d)(ScreenPtr pScreen); + void (*TransitionTo2d)(ScreenPtr pScreen); /* wrapped functions */ DRIWrappedFuncsRec wrap; @@ -131,131 +141,158 @@ typedef struct { void* devPrivate; } DRIInfoRec, *DRIInfoPtr; -extern Bool DRIScreenInit( - ScreenPtr pScreen, - DRIInfoPtr pDRIInfo, - int* pDRMFD); -void DRICloseScreen(ScreenPtr pScreen); -Bool DRIExtensionInit(void); -void DRIReset(void); -Bool DRIQueryDirectRenderingCapable( ScreenPtr pScreen, Bool* isCapable); -Bool DRIOpenConnection( - ScreenPtr pScreen, - drmHandlePtr hSAREA, - char **busIdString -); -Bool DRIAuthConnection(ScreenPtr pScreen, drmMagic magic); -Bool DRICloseConnection( ScreenPtr pScreen); -Bool DRIGetClientDriverName( - ScreenPtr pScreen, - int* ddxDriverMajorVersion, - int* ddxDriverMinorVersion, - int* ddxDriverPatchVersion, - char** clientDriverName -); -Bool DRICreateContext( - ScreenPtr pScreen, - VisualPtr visual, - XID context, - drmContextPtr pHWContext -); -Bool DRIDestroyContext( ScreenPtr pScreen, XID context); -Bool DRIContextPrivDelete( - pointer pResource, - XID id); -Bool DRICreateDrawable( - ScreenPtr pScreen, - Drawable id, - DrawablePtr pDrawable, - drmDrawablePtr hHWDrawable -); -Bool DRIDestroyDrawable( ScreenPtr pScreen, - Drawable id, - DrawablePtr pDrawable); -Bool DRIDrawablePrivDelete( - pointer pResource, - XID id); -Bool DRIGetDrawableInfo( - ScreenPtr pScreen, - DrawablePtr pDrawable, - unsigned int* index, - unsigned int* stamp, - int* X, - int* Y, - int* W, - int* H, - int* numClipRects, - XF86DRIClipRectPtr* pClipRects -); -Bool DRIGetDeviceInfo( - ScreenPtr pScreen, - drmHandlePtr hFrameBuffer, - int* fbOrigin, - int* fbSize, - int* fbStride, - int* devPrivateSize, - void** pDevPrivate -); -DRIInfoPtr DRICreateInfoRec(void); -void DRIDestroyInfoRec(DRIInfoPtr DRIInfo); -Bool DRIFinishScreenInit(ScreenPtr pScreen); -void DRIWakeupHandler( - pointer wakeupData, - int result, - pointer pReadmask); -void DRIBlockHandler( - pointer blockData, - OSTimePtr pTimeout, - pointer pReadmask); -void DRIDoWakeupHandler( - int screenNum, - pointer wakeupData, - unsigned long result, - pointer pReadmask); -void DRIDoBlockHandler( - int screenNum, - pointer blockData, - pointer pTimeout, - pointer pReadmask); -void DRISwapContext( - int drmFD, - void *oldctx, - void *newctx); -void* DRIGetContextStore(DRIContextPrivPtr context); -void DRIPaintWindow( - WindowPtr pWin, - RegionPtr prgn, - int what); -void DRICopyWindow( - WindowPtr pWin, - DDXPointRec ptOldOrg, - RegionPtr prgnSrc); -int DRIValidateTree( - WindowPtr pParent, - WindowPtr pChild, - VTKind kind); -void DRIPostValidateTree( - WindowPtr pParent, - WindowPtr pChild, - VTKind kind); -void DRIClipNotify( - WindowPtr pWin, - int dx, - int dy); -CARD32 DRIGetDrawableIndex( - WindowPtr pWin); -void DRILock(ScreenPtr pScreen, int flags); -void DRIUnlock(ScreenPtr pScreen); -void *DRIGetSAREAPrivate(ScreenPtr pScreen); -DRIContextPrivPtr -DRICreateContextPriv(ScreenPtr pScreen, - drmContextPtr pHWContext, - DRIContextFlags flags); -DRIContextPrivPtr -DRICreateContextPrivFromHandle(ScreenPtr pScreen, - drmContext hHWContext, - DRIContextFlags flags); -Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv); + +extern Bool DRIScreenInit(ScreenPtr pScreen, + DRIInfoPtr pDRIInfo, + int *pDRMFD); + +extern void DRICloseScreen(ScreenPtr pScreen); + +extern Bool DRIExtensionInit(void); + +extern void DRIReset(void); + +extern Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, + Bool *isCapable); + +extern Bool DRIOpenConnection(ScreenPtr pScreen, + drmHandlePtr hSAREA, + char **busIdString); + +extern Bool DRIAuthConnection(ScreenPtr pScreen, drmMagic magic); + +extern Bool DRICloseConnection(ScreenPtr pScreen); + +extern Bool DRIGetClientDriverName(ScreenPtr pScreen, + int* ddxDriverMajorVersion, + int* ddxDriverMinorVersion, + int* ddxDriverPatchVersion, + char** clientDriverName); + +extern Bool DRICreateContext(ScreenPtr pScreen, + VisualPtr visual, + XID context, + drmContextPtr pHWContext); + +extern Bool DRIDestroyContext(ScreenPtr pScreen, XID context); + +extern Bool DRIContextPrivDelete(pointer pResource, XID id); + +extern Bool DRICreateDrawable(ScreenPtr pScreen, + Drawable id, + DrawablePtr pDrawable, + drmDrawablePtr hHWDrawable); + +extern Bool DRIDestroyDrawable(ScreenPtr pScreen, + Drawable id, + DrawablePtr pDrawable); + +extern Bool DRIDrawablePrivDelete(pointer pResource, + XID id); + +extern Bool DRIGetDrawableInfo(ScreenPtr pScreen, + DrawablePtr pDrawable, + unsigned int* index, + unsigned int* stamp, + int* X, + int* Y, + int* W, + int* H, + int* numClipRects, + XF86DRIClipRectPtr* pClipRects, + int* backX, + int* backY, + int* numBackClipRects, + XF86DRIClipRectPtr* pBackClipRects); + +extern Bool DRIGetDeviceInfo(ScreenPtr pScreen, + drmHandlePtr hFrameBuffer, + int* fbOrigin, + int* fbSize, + int* fbStride, + int* devPrivateSize, + void** pDevPrivate); + +extern DRIInfoPtr DRICreateInfoRec(void); + +extern void DRIDestroyInfoRec(DRIInfoPtr DRIInfo); + +extern Bool DRIFinishScreenInit(ScreenPtr pScreen); + +extern void DRIWakeupHandler(pointer wakeupData, + int result, + pointer pReadmask); + +extern void DRIBlockHandler(pointer blockData, + OSTimePtr pTimeout, + pointer pReadmask); + +extern void DRIDoWakeupHandler(int screenNum, + pointer wakeupData, + unsigned long result, + pointer pReadmask); + +extern void DRIDoBlockHandler(int screenNum, + pointer blockData, + pointer pTimeout, + pointer pReadmask); + +extern void DRISwapContext(int drmFD, + void *oldctx, + void *newctx); + +extern void *DRIGetContextStore(DRIContextPrivPtr context); + +extern void DRIPaintWindow(WindowPtr pWin, + RegionPtr prgn, + int what); + +extern void DRICopyWindow(WindowPtr pWin, + DDXPointRec ptOldOrg, + RegionPtr prgnSrc); + +extern int DRIValidateTree(WindowPtr pParent, + WindowPtr pChild, + VTKind kind); + +extern void DRIPostValidateTree(WindowPtr pParent, + WindowPtr pChild, + VTKind kind); + +extern void DRIClipNotify(WindowPtr pWin, + int dx, + int dy); + +extern CARD32 DRIGetDrawableIndex(WindowPtr pWin); + +extern void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg); + +extern void DRILock(ScreenPtr pScreen, int flags); + +extern void DRIUnlock(ScreenPtr pScreen); + +extern DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen); + +extern void *DRIGetSAREAPrivate(ScreenPtr pScreen); + +extern unsigned int DRIGetDrawableStamp(ScreenPtr pScreen, + CARD32 drawable_index); + +extern DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, + drmContextPtr pHWContext, + DRIContextFlags flags); + +extern DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen, + drmContext hHWContext, + DRIContextFlags flags); + +extern Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv); + +extern drmContext DRIGetContext(ScreenPtr pScreen); + +extern void DRIQueryVersion(int *majorVersion, + int *minorVersion, + int *patchVersion); #define _DRI_H_ diff --git a/xc/programs/Xserver/GL/dri/xf86dri.c b/xc/programs/Xserver/GL/dri/xf86dri.c index b39b57450..f6a637d7c 100644 --- a/xc/programs/Xserver/GL/dri/xf86dri.c +++ b/xc/programs/Xserver/GL/dri/xf86dri.c @@ -210,12 +210,21 @@ ProcXF86DRIAuthConnection( register ClientPtr client ) { + xXF86DRIAuthConnectionReply rep; + REQUEST(xXF86DRIAuthConnectionReq); REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq); - if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) - ErrorF("Failed to authenticate %u\n", stuff->magic); + rep.type = X_Reply; + rep.length = 0; + rep.sequenceNumber = client->sequence; + rep.authenticated = 1; + if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) { + ErrorF("Failed to authenticate %u\n", stuff->magic); + rep.authenticated = 0; + } + WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep); return (client->noClientException); } @@ -388,6 +397,8 @@ ProcXF86DRIGetDrawableInfo( DrawablePtr pDrawable; int X, Y, W, H; XF86DRIClipRectPtr pClipRects; + XF86DRIClipRectPtr pBackClipRects; + int backX, backY; REQUEST(xXF86DRIGetDrawableInfoReq); REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq); @@ -411,7 +422,11 @@ ProcXF86DRIGetDrawableInfo( (int*)&W, (int*)&H, (int*)&rep.numClipRects, - &pClipRects)) { + &pClipRects, + &backX, + &backY, + (int*)&rep.numBackClipRects, + &pBackClipRects)) { return BadValue; } @@ -419,18 +434,32 @@ ProcXF86DRIGetDrawableInfo( rep.drawableY = Y; rep.drawableWidth = W; rep.drawableHeight = H; + rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - + SIZEOF(xGenericReply)); + + rep.backX = backX; + rep.backY = backY; + + if (rep.numBackClipRects) + rep.length += sizeof(XF86DRIClipRectRec) * rep.numBackClipRects; + + if (rep.numClipRects) + rep.length += sizeof(XF86DRIClipRectRec) * rep.numClipRects; + + WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep); - rep.length = 0; if (rep.numClipRects) { - rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - - SIZEOF(xGenericReply) + - sizeof(XF86DRIClipRectRec) * rep.numClipRects); + WriteToClient(client, + sizeof(XF86DRIClipRectRec) * rep.numClipRects, + (char *)pClipRects); } - WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep); - if (rep.length) { - WriteToClient(client, rep.length, (char *)pClipRects); + if (rep.numBackClipRects) { + WriteToClient(client, + sizeof(XF86DRIClipRectRec) * rep.numBackClipRects, + (char *)pBackClipRects); } + return (client->noClientException); } diff --git a/xc/programs/Xserver/GL/glx/glxscreens.c b/xc/programs/Xserver/GL/glx/glxscreens.c index d10696847..9e4a3c91c 100644 --- a/xc/programs/Xserver/GL/glx/glxscreens.c +++ b/xc/programs/Xserver/GL/glx/glxscreens.c @@ -246,9 +246,14 @@ void __glXScreenInit(GLint numscreens) if ((*__glXScreens[j]->screenProbe)(i)) { __glXActiveScreens[i] = *__glXScreens[j]; +#if 0 + /* we don't use this since matchVisuals doesn't allow alpha */ __glXActiveScreens[i].numUsableVisuals = matchVisuals(__glXActiveScreens[i].pGlxVisual, __glXActiveScreens[i].numVisuals, i); +#else + __glXActiveScreens[i].numUsableVisuals = __glXActiveScreens[i].numVisuals; +#endif __glXActiveScreens[i].GLXvendor = __glXStrdup(GLXServerVendorName); __glXActiveScreens[i].GLXversion = __glXStrdup(GLXServerVersion); __glXActiveScreens[i].GLXextensions = __glXStrdup(GLXServerExtensions); diff --git a/xc/programs/Xserver/GL/mesa/src/X/xf86glx.c b/xc/programs/Xserver/GL/mesa/src/X/xf86glx.c index f305e3488..656c7af5a 100644 --- a/xc/programs/Xserver/GL/mesa/src/X/xf86glx.c +++ b/xc/programs/Xserver/GL/mesa/src/X/xf86glx.c @@ -29,6 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> + * Brian E. Paul <brian@precisioninsight.com> * */ @@ -93,12 +94,13 @@ __GLXextensionInfo __glDDXExtensionInfo = { __MESA_setVisualConfigs }; -__MESA_screen MESAScreens[MAXSCREENS]; -__GLcontext *MESA_CC = NULL; +static __MESA_screen MESAScreens[MAXSCREENS]; +static __GLcontext *MESA_CC = NULL; + +static int numConfigs = 0; +static __GLXvisualConfig *visualConfigs = NULL; +static void **visualPrivates = NULL; -int numConfigs = 0; -__GLXvisualConfig *visualConfigs = NULL; -void **visualPrivates = NULL; static int count_bits(unsigned int n) { @@ -111,6 +113,7 @@ static int count_bits(unsigned int n) return bits; } + static XMesaVisual find_mesa_visual(int screen, VisualID vid) { XMesaVisual xm_vis = NULL; @@ -129,251 +132,148 @@ static XMesaVisual find_mesa_visual(int screen, VisualID vid) return xm_vis; } -#define VISUAL_CONFIG(rgba,accum,back,depth,stencil,rating) \ -{ \ - -1, /* vid */ \ - -1, /* class */ \ - rgba, /* rgba */ \ - -1, -1, -1, 0, /* rgba sizes, alpha not supported, yet */ \ - -1, -1, -1, 0, /* rgba masks, alpha not supported, yet */ \ - accum, accum, accum, accum, /* rgba accum sizes */ \ - back, /* doubleBuffer */ \ - GL_FALSE, /* stereo */ \ - -1, /* bufferSize */ \ - depth, /* depthSize */ \ - stencil, /* stencilSize */ \ - 0, /* auxBuffers */ \ - 0, /* level */ \ - rating, /* visualRating */ \ - 0, /* transparentPixel */ \ - 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ \ - 0 /* transparentIndex */ \ -} -#define IS_RGBA GL_TRUE -#define IS_CI GL_FALSE -#define HAS_ACCUM ACCUM_BITS -#define NO_ACCUM 0 -#define HAS_BACK GL_TRUE -#define NO_BACK GL_FALSE -#define HAS_DEPTH DEPTH_BITS -#define NO_DEPTH 0 -#define HAS_STENCIL STENCIL_BITS -#define NO_STENCIL 0 - -static __GLXvisualConfig __MESAvisualConfigs[] = { - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), - VISUAL_CONFIG(IS_RGBA, HAS_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, NO_BACK, NO_DEPTH, NO_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), - VISUAL_CONFIG( IS_CI, NO_ACCUM, HAS_BACK, HAS_DEPTH, HAS_STENCIL, 0), +/* + * In the case the driver has no GLX visuals we'll use these. + * [0] = RGB, double buffered + * [1] = RGB, double buffered, stencil, accum + * [2] = CI, double buffered + */ +#define NUM_FALLBACK_CONFIGS 3 +static __GLXvisualConfig FallbackConfigs[NUM_FALLBACK_CONFIGS] = { + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE_EXT, /* visualRating */ + 0, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + { + -1, /* vid */ + -1, /* class */ + True, /* rgba */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 16, 16, 16, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 8, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE_EXT, /* visualRating */ + 0, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, + { + -1, /* vid */ + -1, /* class */ + False, /* color index */ + -1, -1, -1, 0, /* rgba sizes */ + -1, -1, -1, 0, /* rgba masks */ + 0, 0, 0, 0, /* rgba accum sizes */ + True, /* doubleBuffer */ + False, /* stereo */ + -1, /* bufferSize */ + 16, /* depthSize */ + 0, /* stencilSize */ + 0, /* auxBuffers */ + 0, /* level */ + GLX_NONE_EXT, /* visualRating */ + 0, /* transparentPixel */ + 0, 0, 0, 0, /* transparent rgba color (floats scaled to ints) */ + 0 /* transparentIndex */ + }, }; -static int __numMESAvisualConfigs = - sizeof(__MESAvisualConfigs)/sizeof(__GLXvisualConfig); -static int __numRGBconfigs = -1; -static int __numCIconfigs = -1; static Bool init_visuals(int *nvisualp, VisualPtr *visualp, VisualID *defaultVisp, int ndepth, DepthPtr pdepth, int rootDepth) { + int numRGBconfigs; + int numCIconfigs; int numVisuals = *nvisualp; - int numMesaVisuals = 0; - int numMergedVisualConfigs = 0; + int numNewVisuals; + int numNewConfigs; VisualPtr pVisual = *visualp; VisualPtr pVisualNew = NULL; VisualID *orig_vid = NULL; __GLXvisualConfig *glXVisualPtr = NULL; - __GLXvisualConfig *pMergedVisualConfigs = NULL; + __GLXvisualConfig *pNewVisualConfigs = NULL; void **glXVisualPriv; - void **pMergedVisualPriv; - int *mesaConfigUsed; - int *driverConfigUsed; - int found_default = FALSE; + void **pNewVisualPriv; + int found_default; int i, j, k; - int is_rgb; - Bool match; - - /* Alloc space for the list of merged GLX visuals */ - pMergedVisualConfigs = - (__GLXvisualConfig *)__glXMalloc((numConfigs + - __numMESAvisualConfigs) * - sizeof(__GLXvisualConfig)); - if (!pMergedVisualConfigs) { - return FALSE; - } - - /* Alloc space for the list of merged GLX visual privates */ - pMergedVisualPriv = - (void **)__glXMalloc((numConfigs + __numMESAvisualConfigs) * - sizeof(void *)); - if (!pMergedVisualPriv) { - __glXFree(pMergedVisualConfigs); - return FALSE; - } - /* Compute the intersection of the driver's visual configs */ - mesaConfigUsed = __glXCalloc(__numMESAvisualConfigs, sizeof(int)); - driverConfigUsed = __glXCalloc(numConfigs, sizeof(int)); - - for (i = j = 0; i < numConfigs; i++) { - k = 0; - while ((k < __numMESAvisualConfigs) && (!driverConfigUsed[i])) { - if (!mesaConfigUsed[k]) { - -#ifdef DEBUG_VISUAL_CONFIG -#define TEST_AND_COPY(fld) do { \ - if (match) { \ - if ((__MESAvisualConfigs[k].fld == visualConfigs[i].fld) || \ - (__MESAvisualConfigs[k].fld == -1)) { \ - pMergedVisualConfigs[j].fld = visualConfigs[i].fld; \ - } \ - else if (visualConfigs[i].fld == -1) { \ - pMergedVisualConfigs[j].fld = __MESAvisualConfigs[k].fld; \ - } \ - else { \ - match = FALSE; \ - xf86DrvMsg (0, 0, "[GLXVisualInit] mismatch: " \ - "(%s) DriverVisualConfig[%d] MesaVisualConfig[%d]\n", \ - #fld, i, k); \ - } \ - } \ - } while (0) -#else -#define TEST_AND_COPY(fld) do { \ - if (match) { \ - if ((__MESAvisualConfigs[k].fld == visualConfigs[i].fld) || \ - (__MESAvisualConfigs[k].fld == -1)) { \ - pMergedVisualConfigs[j].fld = visualConfigs[i].fld; \ - } \ - else if (visualConfigs[i].fld == -1) { \ - pMergedVisualConfigs[j].fld = __MESAvisualConfigs[k].fld; \ - } \ - else { \ - match = FALSE; \ - } \ - } \ - } while (0) -#endif + if (numConfigs > 0) + numNewConfigs = numConfigs; + else + numNewConfigs = NUM_FALLBACK_CONFIGS; - match = TRUE; - TEST_AND_COPY(class); - TEST_AND_COPY(rgba); - TEST_AND_COPY(redSize); - TEST_AND_COPY(greenSize); - TEST_AND_COPY(blueSize); - TEST_AND_COPY(alphaSize); - TEST_AND_COPY(redMask); - TEST_AND_COPY(greenMask); - TEST_AND_COPY(blueMask); - TEST_AND_COPY(alphaMask); - TEST_AND_COPY(accumRedSize); - TEST_AND_COPY(accumGreenSize); - TEST_AND_COPY(accumBlueSize); - TEST_AND_COPY(accumAlphaSize); - TEST_AND_COPY(doubleBuffer); - TEST_AND_COPY(stereo); - TEST_AND_COPY(bufferSize); - TEST_AND_COPY(depthSize); - TEST_AND_COPY(stencilSize); - TEST_AND_COPY(auxBuffers); - TEST_AND_COPY(level); - TEST_AND_COPY(visualRating); - TEST_AND_COPY(transparentPixel); - TEST_AND_COPY(transparentRed); - TEST_AND_COPY(transparentGreen); - TEST_AND_COPY(transparentBlue); - TEST_AND_COPY(transparentAlpha); - TEST_AND_COPY(transparentIndex); - if (match) { - driverConfigUsed[i] = TRUE; - mesaConfigUsed[k] = TRUE; - pMergedVisualPriv[j] = visualPrivates[i]; - j++; -#ifdef DEBUG_VISUAL_CONFIG - xf86DrvMsg (0, 0, "[GLXVisualInit] MATCH: " - "DriverVisualConfig[%d] MesaVisualConfig[%d]\n", i, k); -#endif - } - } - k++; - } + /* Alloc space for the list of new GLX visuals */ + pNewVisualConfigs = (__GLXvisualConfig *) + __glXMalloc(numNewConfigs * sizeof(__GLXvisualConfig)); + if (!pNewVisualConfigs) { + return FALSE; } - /* - ** If SetVisualConfigs was not called, then just make all of Mesa's - ** visual configs available. - */ - if (!numConfigs) { - memcpy(pMergedVisualConfigs, __MESAvisualConfigs, - sizeof(__GLXvisualConfig) * __numMESAvisualConfigs); - memset(pMergedVisualPriv, 0, sizeof(void *) * __numMESAvisualConfigs); - memset(mesaConfigUsed, TRUE, sizeof(int) * __numMESAvisualConfigs); - j = __numMESAvisualConfigs; + /* Alloc space for the list of new GLX visual privates */ + pNewVisualPriv = (void **) __glXMalloc(numNewConfigs * sizeof(void *)); + if (!pNewVisualPriv) { + __glXFree(pNewVisualConfigs); + return FALSE; } /* - ** This code is not currently used. When the visual caveat - ** extension is supported by the DRI and Mesa, we can take advantage - ** of this code. + ** If SetVisualConfigs was not called, then use default GLX + ** visual configs. */ -#if 0 - /* Add any unclaimed MESA configs w/ slow caveat */ - for (i = 0; i < __numMESAvisualConfigs; i++) { - if (!mesaConfigUsed[i]) { - memcpy(&pMergedVisualConfigs[j], &__MESAvisualConfigs[i], - sizeof(__GLXvisualConfig)); - pMergedVisualConfigs[j].visualRating = GLX_SLOW_VISUAL_EXT; - j++; -#ifdef DEBUG_VISUAL_CONFIG - xf86DrvMsg (0, 0, "[GLXVisualInit] slow config: " - "MesaVisualConfig[%d]\n", i); -#endif - } + if (numConfigs == 0) { + memcpy(pNewVisualConfigs, FallbackConfigs, + NUM_FALLBACK_CONFIGS * sizeof(__GLXvisualConfig)); + memset(pNewVisualPriv, 0, NUM_FALLBACK_CONFIGS * sizeof(void *)); } - - /* Add any unclaimed driver configs w/ nonconformant caveat */ - for (i = 0; i < numConfigs; i++) { - if (!driverConfigUsed[i]) { - memcpy(&pMergedVisualConfigs[j], &visualConfigs[i], - sizeof(__GLXvisualConfig)); - pMergedVisualConfigs[j].visualRating = GLX_NON_CONFORMANT_VISUAL_EXT; - j++; -#ifdef DEBUG_VISUAL_CONFIG - xf86DrvMsg (0, 0, "[GLXVisualInit] non-conformant config: " - "DriverVisualConfig[%d]\n", i); -#endif - } + else { + /* copy driver's visual config info */ + for (i = 0; i < numConfigs; i++) { + pNewVisualConfigs[i] = visualConfigs[i]; + pNewVisualPriv[i] = visualPrivates[i]; + } } -#endif - numMergedVisualConfigs = j; /* Count the number of RGB and CI visual configs */ - __numRGBconfigs = __numCIconfigs = 0; - for (i = 0; i < numMergedVisualConfigs; i++) { - if (pMergedVisualConfigs[i].rgba) - __numRGBconfigs++; + numRGBconfigs = 0; + numCIconfigs = 0; + for (i = 0; i < numNewConfigs; i++) { + if (pNewVisualConfigs[i].rgba) + numRGBconfigs++; else - __numCIconfigs++; + numCIconfigs++; } /* Count the total number of visuals to compute */ + numNewVisuals = 0; for (i = 0; i < numVisuals; i++) { - numMesaVisuals += + numNewVisuals += (pVisual[i].class == TrueColor || pVisual[i].class == DirectColor) - ? __numRGBconfigs : __numCIconfigs; + ? numRGBconfigs : numCIconfigs; } /* Reset variables for use with the next screen/driver's visual configs */ @@ -381,51 +281,52 @@ 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(numMesaVisuals * sizeof(VisualID)); + orig_vid = (VisualID *)__glXMalloc(numNewVisuals * sizeof(VisualID)); if (!orig_vid) { - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); return FALSE; } /* Alloc space for the list of glXVisuals */ - glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numMesaVisuals * + glXVisualPtr = (__GLXvisualConfig *)__glXMalloc(numNewVisuals * sizeof(__GLXvisualConfig)); if (!glXVisualPtr) { __glXFree(orig_vid); - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); return FALSE; } /* Alloc space for the list of glXVisualPrivates */ - glXVisualPriv = (void **)__glXMalloc(numMesaVisuals * sizeof(void *)); + glXVisualPriv = (void **)__glXMalloc(numNewVisuals * sizeof(void *)); if (!glXVisualPriv) { __glXFree(glXVisualPtr); __glXFree(orig_vid); - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); return FALSE; } /* Alloc space for the new list of the X server's visuals */ - pVisualNew = (VisualPtr)__glXMalloc(numMesaVisuals * sizeof(VisualRec)); + pVisualNew = (VisualPtr)__glXMalloc(numNewVisuals * sizeof(VisualRec)); if (!pVisualNew) { __glXFree(glXVisualPriv); __glXFree(glXVisualPtr); __glXFree(orig_vid); - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); return FALSE; } /* Initialize the new visuals */ + found_default = FALSE; for (i = j = 0; i < numVisuals; i++) { - is_rgb = (pVisual[i].class == TrueColor || - pVisual[i].class == DirectColor); + int is_rgb = (pVisual[i].class == TrueColor || + pVisual[i].class == DirectColor); - for (k = 0; k < numMergedVisualConfigs; k++) { - if (pMergedVisualConfigs[k].rgba != is_rgb) + for (k = 0; k < numNewConfigs; k++) { + if (pNewVisualConfigs[k].rgba != is_rgb) continue; /* Initialize the new visual */ @@ -442,7 +343,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, orig_vid[j] = pVisual[i].vid; /* Initialize the glXVisual */ - glXVisualPtr[j] = pMergedVisualConfigs[k]; + glXVisualPtr[j] = pNewVisualConfigs[k]; glXVisualPtr[j].vid = pVisualNew[j].vid; /* @@ -456,23 +357,25 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, glXVisualPtr[j].redSize = count_bits(pVisual[i].redMask); glXVisualPtr[j].greenSize = count_bits(pVisual[i].greenMask); glXVisualPtr[j].blueSize = count_bits(pVisual[i].blueMask); - glXVisualPtr[j].alphaSize = 0; /* Not supported in Mesa */ + glXVisualPtr[j].alphaSize = glXVisualPtr[j].alphaSize; glXVisualPtr[j].redMask = pVisual[i].redMask; glXVisualPtr[j].greenMask = pVisual[i].greenMask; glXVisualPtr[j].blueMask = pVisual[i].blueMask; - glXVisualPtr[j].alphaMask = 0; /* Not supported in Mesa */ + glXVisualPtr[j].alphaMask = glXVisualPtr[j].alphaMask; glXVisualPtr[j].bufferSize = rootDepth; } /* Save the device-dependent private for this visual */ - glXVisualPriv[j] = pMergedVisualPriv[k]; + glXVisualPriv[j] = pNewVisualPriv[k]; j++; } } + assert(j <= numNewVisuals); + /* Save the GLX visuals in the screen structure */ - MESAScreens[screenInfo.numScreens-1].num_vis = numMesaVisuals; + MESAScreens[screenInfo.numScreens-1].num_vis = numNewVisuals; MESAScreens[screenInfo.numScreens-1].glx_vis = glXVisualPtr; MESAScreens[screenInfo.numScreens-1].private = glXVisualPriv; @@ -484,7 +387,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Count the new number of VisualIDs at this depth */ for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numMesaVisuals; k++) + for (k = 0; k < numNewVisuals; k++) if (pdepth[i].vids[j] == orig_vid[k]) numVids++; @@ -493,7 +396,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Initialize the new list of VisualIDs for this depth */ for (j = 0; j < pdepth[i].numVids; j++) - for (k = 0; k < numMesaVisuals; k++) + for (k = 0; k < numNewVisuals; k++) if (pdepth[i].vids[j] == orig_vid[k]) pVids[n++] = pVisualNew[k].vid; @@ -504,7 +407,7 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, } /* Update the X server's visuals */ - *nvisualp = numMesaVisuals; + *nvisualp = numNewVisuals; *visualp = pVisualNew; /* Free the old list of the X server's visuals */ @@ -512,11 +415,12 @@ static Bool init_visuals(int *nvisualp, VisualPtr *visualp, /* Clean up temporary allocations */ __glXFree(orig_vid); - __glXFree(pMergedVisualPriv); - __glXFree(pMergedVisualConfigs); + __glXFree(pNewVisualPriv); + __glXFree(pNewVisualConfigs); /* Free the private list created by DDX HW driver */ - if (visualPrivates) xfree(visualPrivates); + if (visualPrivates) + xfree(visualPrivates); visualPrivates = NULL; return TRUE; @@ -603,18 +507,22 @@ static void init_screen_visuals(int screen) /* Create the XMesa visual */ pXMesaVisual[i] = - XMesaCreateVisual(pScreen, - pVis, - pGLXVis->rgba, - (pGLXVis->alphaSize > 0), - pGLXVis->doubleBuffer, - pGLXVis->stereo, - GL_TRUE, /* ximage_flag */ - pGLXVis->depthSize, - pGLXVis->stencilSize, - pGLXVis->accumRedSize, - pGLXVis->level); - + XMesaCreateVisual(pScreen, + pVis, + pGLXVis->rgba, + (pGLXVis->alphaSize > 0), + pGLXVis->doubleBuffer, + pGLXVis->stereo, + GL_TRUE, /* ximage_flag */ + pGLXVis->depthSize, + pGLXVis->stencilSize, + pGLXVis->accumRedSize, + pGLXVis->accumGreenSize, + pGLXVis->accumBlueSize, + pGLXVis->accumAlphaSize, + 0, /* numSamples */ + pGLXVis->level, + pGLXVis->visualRating ); /* Set the VisualID */ pGLXVis->vid = pVis->vid; diff --git a/xc/programs/Xserver/Imakefile b/xc/programs/Xserver/Imakefile index 45300d897..cf9770537 100644 --- a/xc/programs/Xserver/Imakefile +++ b/xc/programs/Xserver/Imakefile @@ -619,7 +619,7 @@ XF86IDRVOBJS = $(XF86SRC)/input/drvConf.o XF86IDRVLIBS = $(XF86IDRIVERLIB) XF86SCANLIB = $(XF86SRC)/scanpci/LibraryTargetName(scanpci) XF86LIBS = $(XF86INIT) $(XF86COMLIB) $(XF86RACLIB) $(XF86PARSLIB) \ - $(XF86OSLIB) $(XF86INT10LIB) + $(XF86OSLIB) $(XF86INT10LIB) $(XF86DDCLIB) #else XF86LIBS = $(XF86INIT) $(XF86COMLIB) $(XF86PARSLIB) $(XF86OSLIB) #endif @@ -634,7 +634,8 @@ XF86SERVERSYSLIBS = $(FONTLIBS) $(SYSLIBS) $(LIBDL) $(LIBREGEX) #endif XF86SERVEROBJS = $(XF86DRVOBJS) $(XF86IDRVOBJS) XF86SERVERLIBS = $(XF86DRVLIBS) $(XF86IDRVLIBS) $(XF86LIBS) $(XF86LOADERLIB) \ - $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) + $(XF86COMLIB) $(XF86MAINLIBS) $(XF86SCANLIB) $(XF86OSLIB) \ + $(XF86DDCLIB) #if HasParallelMake MakeMutex($(XF86SERVERSUBDIRS) $(XF86SERVERLIBS) $(XF86SERVERSYSLIBS)) #endif diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h index 9194084e4..c6e6c889a 100644 --- a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h +++ b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h @@ -185,6 +185,8 @@ #define PCI_CHIP_MACH64GZ 0x475A #define PCI_CHIP_MACH64LB 0x4C42 #define PCI_CHIP_MACH64LD 0x4C44 +#define PCI_CHIP_RAGE128LE 0x4C45 +#define PCI_CHIP_RAGE128LF 0x4C46 #define PCI_CHIP_MACH64LG 0x4C47 #define PCI_CHIP_MACH64LI 0x4C49 #define PCI_CHIP_MACH64LM 0x4C4D @@ -192,11 +194,11 @@ #define PCI_CHIP_MACH64LP 0x4C50 #define PCI_CHIP_MACH64LR 0x4C52 #define PCI_CHIP_MACH64LS 0x4C53 +#define PCI_CHIP_RAGE128PF 0x5046 #define PCI_CHIP_RAGE128RE 0x5245 #define PCI_CHIP_RAGE128RF 0x5246 #define PCI_CHIP_RAGE128RK 0x524B #define PCI_CHIP_RAGE128RL 0x524C -#define PCI_CHIP_RAGE128PF 0x5046 #define PCI_CHIP_MACH64VT 0x5654 #define PCI_CHIP_MACH64VU 0x5655 #define PCI_CHIP_MACH64VV 0x5656 @@ -690,6 +692,8 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = { {PCI_CHIP_MACH64GZ, "Mach64 GZ",0}, {PCI_CHIP_MACH64LB, "Mach64 LB",0}, {PCI_CHIP_MACH64LD, "Mach64 LD",0}, + {PCI_CHIP_RAGE128LE, "Rage 128 Mobility LE",0}, + {PCI_CHIP_RAGE128LF, "Rage 128 Mobility LF",0}, {PCI_CHIP_MACH64LG, "Mach64 LG",0}, {PCI_CHIP_MACH64LI, "Mach64 LI",0}, {PCI_CHIP_MACH64LM, "Mach64 LM",0}, @@ -697,11 +701,11 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = { {PCI_CHIP_MACH64LP, "Mach64 LP",0}, {PCI_CHIP_MACH64LR, "Mach64 LR",0}, {PCI_CHIP_MACH64LS, "Mach64 LS",0}, + {PCI_CHIP_RAGE128PF, "Rage 128 Pro PF",0}, {PCI_CHIP_RAGE128RE, "Rage 128 RE",0}, {PCI_CHIP_RAGE128RF, "Rage 128 RF",0}, {PCI_CHIP_RAGE128RK, "Rage 128 RK",0}, {PCI_CHIP_RAGE128RL, "Rage 128 RL",0}, - {PCI_CHIP_RAGE128PF, "Rage 128 Pro PF",0}, {PCI_CHIP_MACH64VT, "Mach64 VT",0}, {PCI_CHIP_MACH64VU, "Mach64 VU",0}, {PCI_CHIP_MACH64VV, "Mach64 VV",0}, diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml new file mode 100644 index 000000000..d43c76a1f --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml @@ -0,0 +1,501 @@ +<!doctype linuxdoc system> +<!-- Created: Sun Mar 12 13:00:00 2000 by brian@precisioninsight.com --> +<!-- Revised: Fri May 19 09:36:02 2000 by martin@valinux.com --> +<!-- $Id: DRIcomp.sgml,v 1.10.2.1 2000/06/13 15:33:14 dfr Exp $ --> + + <article> + + <title>DRI Compilation Guide + <author> + <htmlurl url="http://www.precisioninsight.com/" + name="Precision Insight, Inc."> + <date>18 May 2000 + + <ident> + $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.3 2000/04/05 05:38:41 brianp Exp $ + </ident> + + <toc> + + <sect>Preamble + + <sect1>Copyright + <p> + <bf>Copyright © 2000 by Precision Insight, Inc., + Cedar Park, Texas. + All Rights Reserved.</bf> + <p> + <bf>Permission is granted to make and distribute verbatim copies + of this document provided the copyright notice and this permission + notice are preserved on all copies.</bf> + + <sect1>Trademarks + <p> + OpenGL is a registered trademark and SGI is a trademark of + Silicon Graphics, Inc. + Unix is a registered trademark of The Open Group. + The `X' device and X Window System are trademarks of The Open Group. + XFree86 is a trademark of The XFree86 Project. + Linux is a registered trademark of Linus Torvalds. + Intel is a registered trademark of Intel Corporation. + 3Dlabs, GLINT, and Oxygen are either registered trademarks or + trademarks of 3Dlabs Inc. Ltd. + 3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of + 3dfx Interactive, Incorporated. + Matrox is a registered trademark of Matrox Electronic Systems Ltd. + ATI Rage is a registered trademark of ATI Technologies, Inc. + All other trademarks mentioned are the property of their + respective owners. + + + <sect>Introduction + <p> + This document describes how to download, compile and install the + DRI project. + This information is intended for experienced Linux developers. + Beginners are probably better off installing precompiled packages. + <p> + Edits, corrections and updates to this document may be mailed + to brian@precisioninsight.com. + + + <sect>Prerequisites + <p> + You'll need the following: + <itemize> + <item>At least 400MB of free disk space. More is needed if you want + to build with debugging information or keep several build trees. + <item>A fast system. Using a PIII-550 it takes about 1/2 hour to + build everthing. + <item>GCC compiler and related tools. + <item>ssh (secure shell) for registed developer downloading of the + DRI source tree + </itemize> + + <p> + For 3dfx Voodoo3 hardware, you'll also need: + <itemize> + <item>Glide3x headers and runtime library if you want to use the + 3dfx driver. + These can be obtained from + <htmlurl url="http://linux.3dfx.com/open_source/glide_kit.htm" + name="linux.3dfx.com">. + <item>Linux kernel 2.2.x. + The DRI developers have been using stock RedHat 6.1 systems + (kernel 2.2.12-20). + Later kernel versions will be supported in the future. + </itemize> + + <p> + For Matrox G400 hardware, you'll also need: + <itemize> + <item>Linux kernel 2.3.51. Other kernel versions may work but + this one is known to work. + </itemize> + + <p> + For ATI Rage hardware, you'll also need: + <itemize> + <item>Linux kernel 2.3.51. Other kernel versions may work but + this one is known to work. + </itemize> + + + <sect>Kernel preparation + <p> + You may have to upgrade your Linux kernel in order to use the DRI. + This is because you need a kernel version which supports AGP. + Building a new Linux kernel can be difficult for beginners but + there are resouces on the Internet to help. + This document assumes experience with configuring, building and + installing Linux kernels. + <p> + Linux kernels can be downloaded from + <htmlurl url="http://www.kernel.org/pub/linux/kernel/" + name="www.kernel.org"> + <p> + Download the needed kernel and put it in /usr/src. + Create a directory for the source and unpack it. + For example: + <verb> + cd /usr/src + rm -f linux + mkdir linux-2.3.51 + ln -s linux-2.3.51 linux + bzcat linux-2.3.51.tar.bz2 | tar xf - + </verb> + <p> + Now configure your kernel. + You might, for example, use <tt>make menuconfig</tt> and do the + following: + + <itemize> + <item>Go to <em>Code maturity level options</em> + <item>Enable <em>Prompt for development and/or incomplete + code/drivers</em> + <item>hit ESC + <item>Go to <em>Character devices</em> + <item>Disable <em>Direct Rendering Manager (XFree86 DRI support)</em> + since we'll use the DRI module from the XFree86/DRI tree. + <item>Go to <em>/dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW)</em> + <item>Hit SPACE twice + <item>Enable all chipsets' support for AGP + </itemize> + + <p>It's recommended that you turn on MTRRs under <em>Processor type + and Features</em>, but not required. + + <p> + Configure the rest of the kernel as required for your system + (i.e. ethernet, scsi, etc) + <p> + Exit, saving your kernel configuration. + <p> + Edit your /etc/lilo.conf file. + Make sure you have an image entry as follows (or similar): + <verb> + image=/boot/vmlinuz + label=linux.2.3.51 + read-only + root=/dev/hda1 + </verb> + <p> + The important part is that you have /boot/vmlinuz without a + trailing version number. + If this is the first entry in your /etc/lilo.conf AND you + haven't set a default, then this will be your default kernel. + + <p> + Now compile the new kernel: + + <verb> + cd /usr/src/linux-2.3.51 + make dep ; make bzImage + make modules ; make modules_install + make install + </verb> + Note that the final part, make install, will automatically run + lilo for you. + <p> + Now reboot to use this new kernel. + + + <sect>Downloading the XFree86/DRI CVS Sources + <p> + The DRI project is hosted by VA Linux Systems' + <htmlurl url="http://sourceforge.net/project/?group_id=387" + name="SourceForge">. + The DRI source code, which is a subset of the XFree86 source tree, + is kept in a CVS repository there. + <p> + The DRI CVS sources may be accessed either anonymously or as a + registered SourceForge user. + It's recommended that you become a registered SourceForge user so + that you may submit non-annonymous bug reports and can participate + in the mailing lists. + + <sect1>Anonymous CVS download: + <p> + <enum> + <item>Create a directory to store the CVS files: + <p> + <verb> + cd ~ + mkdir DRI-CVS + </verb> + You could put your CVS directory in a different place but we'll + use <tt>~/DRI-CVS/</tt> here. + <p> + <item>Check out the CVS sources: + <p> + <verb> + cd ~/DRI-CVS + cvs -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri login + (hit ENTER when prompted for a password) + cvs -z3 -d:pserver:anonymous@cvs.dri.sourceforge.net:/cvsroot/dri co xc + </verb> + <p> + The -z3 flag causes compression to be used in order to reduce + the download time. + </enum> + + + <sect1>Registered CVS download: + <p> + <enum> + <item>Create a directory to store the CVS files: + <p> + <verb> + cd ~ + mkdir DRI-CVS + </verb> + You could put your CVS directory in a different place but we'll + use <tt>~/DRI-CVS/</tt> here. + <p> + <item>Set the CVS_RSH environment variable: + <p> + <verb> + setenv CVS_RSH ssh // if using csh or tcsh + export CVS_RSH=ssh // if using sh or bash + </verb> + <item>Check out the CVS sources: + <p> + <verb> + cd ~/DRI-CVS + cvs -z3 -dYOURID@cvs.dri.sourceforge.net:/cvsroot/dri co xc + </verb> + Replace <tt>YOURID</tt> with your CVS login name. + You'll be prompted to enter your sourceforge password. + <p> + The -z3 flag causes compression to be used in order to reduce + the download time. + </enum> + + + <sect>Updating your CVS sources + <p> + In the future you'll want to occasionally update your local copy of + the DRI source code to get the latest changes. + This can be done with: + <verb> + cd ~/DRI-CVS + cvs -z3 update -dA xc + </verb> + The -d flag causes any new subdirectories to be created and -A causes + most recent trunc sources to be fetched, not branch sources. + + + <sect>Compiling the XFree86/DRI tree + <sect1>Make a build tree + <p> + Rather than placing object files and library files right in the + source tree, they're instead put into a parallel <em>build</em> tree. + The build tree is made with the <tt>lndir</tt> command: + <verb> + cd ~/DRI-CVS + ln -s xc XFree40 + mkdir build + cd build + lndir -silent -ignorelinks ../XFree40 + </verb> + <p> + The build tree will be populated with symbolic links which point + back into the CVS source tree. + <p> + Advanced users may have several build trees for compiling and + testing with different options. + + <sect1>Edit the host.def file + <p> + The <tt>~/DRI-CVS/build/xc/config/cf/host.def</tt> file is used + to configure the XFree86 build process. + You can change it to customize your build options or make adjustments + for your particular system configuration + <p> + The default <tt>host.def</tt> file will look something like this: + <verb> + #define DefaultCCOptions -Wall + #define DefaultGcc2i386Opt -O2 + #define LibraryCDebugFlags -O2 + #define BuildServersOnly YES + #define XF86CardDrivers vga tdfx mga r128 + #define LinuxDistribution LinuxRedHat + #define DefaultCCOptions -ansi GccWarningOptions -pipe + #define BuildXF86DRI YES + #define HasGlide3 YES + /* Optionally turn these on for debugging */ + /* #define GlxBuiltInTdfx YES */ + /* #define GlxBuiltInMga YES */ + /* #define GlxBuiltInR128 YES */ + /* #define DoLoadableServer NO */ + #define SharedLibFont NO + </verb> + The <tt>ProjectRoot</tt> variable specifies where the XFree86 files + will be installed. + You probably don't want to use <tt>/usr/X11R6/</tt> because that + would overwrite your default X files. + The following is recommended: + <verb> + #define ProjectRoot /usr/XF86-main + </verb> + <p> + Especially note the <em>XF86CardDrivers</em> line to be sure your + driver is listed. + <p> + If you have 3dfx hardware be sure that the Glide 3x headers are + installed in <tt>/usr/include/glide3/</tt> and that the Glide 3x + library is installed at <tt>/usr/lib/libglide3x.so</tt>. + <p> + If you do not have 3dfx hardware comment out the <tt>HasGlide3</tt> + line in <tt>host.def</tt>. + <p> + + <sect1>Compile + <p> + To compile the complete DRI tree: + <verb> + cd ~/DRI-CVS/build/xc/ + make World >& World.LOG + </verb> + Or if you want to watch the compilation progress: + <verb> + cd ~/DRI-CVS/build/xc/ + make World >& World.LOG & + tail -f World.LOG + </verb> + With the default compilation flags it's normal to get a lot of + warnings during compilation. + <p> + Building will take some time so you may want to go check your + email or visit slashdot. + + <sect1>Check for compilation errors + <p> + Using your text editor, examine <tt>World.LOG</tt> for errors + by searching for the pattern <tt>***</tt>. + <p> + Verify that the DRI kernel module(s) for your system were built: + <verb> + cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel + ls + </verb> + <p> + For the 3dfx Voodoo, you should see <em>tdfx.o</em>. + For the Matrox G400, you should see <em>mga.o</em>. + For the ATI Rage 128, you should see <em>r128.o</em>. + <p> + If the DRI kernel module(s) failed to build you should verify + that you're using the right version of the Linux kernel. + The most recent kernels are not always supported. + <p> + If your build machine is running a different version of the kernel + than your target machine (i.e. 2.2.12-20 vs. 2.3.99-pre6), make will + select the wrong kernel headers. This can be fixed by explicitly + setting the value of <tt>TREE</tt>. + If the path to your kernel source is + <tt>/bigdisk/linux-2.3.99-pre6</tt>, + <verb> + cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel + make TREE=/bigdisk/linux-2.3.99-pre6 + </verb> + or alternatively, edit Makefile to include this change. + <p> + After fixing the errors, do <tt>make World</tt> again. + Later, you might just compile parts of the source tree but it's + important that the whole tree will build first. + + + <sect>Installing + <p> + After the DRI tree has been compiled you can install the XFree86 + headers, libraries, programs, etc for testing. + + <sect1>X Installation + <p> + As mentioned above, the install directory is specified by the + <tt>ProjectRoot</tt> variable in the <tt>host.def</tt> file. + Create that directory now if it doesn't already exist: + <verb> + mkdir /usr/XF86-main + </verb> + <p> + You'll have to change to root since the install process puts + several files in <tt>/etc/X11/</tt> and sets the setuid flag on + the X server executable. + <verb> + cd ~/DRI-CVS/build/xc + su + make install + </verb> + Edit your <tt>/etc/ld.so.conf</tt> file and put + <tt>/usr/XF86-main/lib</tt> as the first line. + Continue with: + <verb> + ldconfig + exit + </verb> + <p> + Look in <tt>/usr/XF86-main</tt> to be sure the files installed + there. + <P> + Strictly speaking, installing the DRI tree isn't required. + It's possible to run and test the X server directly from the + build directory but it's a bit error prone. + + <sect1>Update Locale Information + <p> + To update your X locale information do the following: + <verb> + cd ~/DRI-CVS/build/xc/nls + xmkmf -a + make + make install + </verb> + This will prevent a locale error message from being printed + when you run Xlib programs. + + <sect>X Server Configuration + <p> + If your X server is currently running you'll have to stop it + and return to a virtual terminal. + <p> + First, setup your XF86Config file. + It should load the GLX and DRI modules and specify the driver to + use for your hardware. + See the <htmlurl url="http://dri.sourceforge.net/DRIuserguide.html" + name="DRI User Guide"> for detailed information. + <p> + You may want to make a backup copy of your existing + <tt>/etc/X11/XF86Config</tt> file first. + <p> + It's very important that you set the <tt>ModulePath</tt> option to + point to your installation directory: + <verb> + ModulePath "/usr/XF86-main/lib/modules" + </verb> + <p> + Double check with this: + <verb> + grep ModulePath /etc/X11/XF86Config + </verb> + <p> + Next, your <tt>~/.xinitrc</tt> file controls which clients will be + launched when your X server starts. + You might put the following in yours: + <verb> + xset b off + xsetroot -solid "#004070" + xmodmap -e "clear mod4" + xrdb -merge ~/.Xdefaults + xterm -geometry +0+0 & + xterm -geometry +512+0 & + fvwm + </verb> + <p> + + <sect>X Server Start-up + <p> + The X server can be started with: + <p> + <verb> + xinit -- /usr/XF86-main/bin/XFree86 + </verb> + <p> + Automatic loading of DRM kernel modules was added to the X server + in XFree86 4.0.1. + This feature, and manual loading of kernel modules, is documented + in the DRI user guide. + <p> + At this point your X server should be up and running with + hardware-accelerated direct rendering. + Please read the + <htmlurl url="http://dri.sourceforge.net/DRIuserguide.html" + name="DRI User Guide"> for trouble shooting information. + + + </article> + + + <!-- Local Variables: --> + <!-- fill-column: 72 --> + <!-- End: --> diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile index c8624e19f..d72589c49 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile @@ -14,10 +14,12 @@ DRIINCLUDES=-I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri SRCS = glint_driver.c pm2_dac.c pm2ramdac.c pm2_accel.c pm_dac.c IBMramdac.c \ pm_accel.c tx_dac.c tx_accel.c pm2v_dac.c pm2vramdac.c pm2_video.c \ - TIramdac.c dualmx_dac.c dualmx_accel.c glint_shadow.c $(DRISRC) + TIramdac.c dualmx_dac.c dualmx_accel.c glint_shadow.c $(DRISRC) \ + glint_dga.c OBJS = glint_driver.o pm2_dac.o pm2ramdac.o pm2_accel.o pm_dac.o IBMramdac.o \ pm_accel.o tx_dac.o tx_accel.o pm2v_dac.o pm2vramdac.o pm2_video.o \ - TIramdac.o dualmx_dac.o dualmx_accel.o glint_shadow.o $(DRIOBJ) + TIramdac.o dualmx_dac.o dualmx_accel.o glint_shadow.o $(DRIOBJ) \ + glint_dga.o #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c index a6d34a4bf..c8ec93434 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c @@ -105,7 +105,6 @@ DualMXInitializeEngine(ScrnInfoPtr pScrn) GLINTPtr pGlint = GLINTPTR(pScrn); pGlint->rasterizerMode = RMMultiGLINT; - pGlint->pprod |= FBRM_ScanlineInt2; /* Initialize the Accelerator Engine to defaults */ @@ -120,8 +119,10 @@ DualMXInitializeEngine(ScrnInfoPtr pScrn) /* Make sure the rest of the register writes go to both MX's */ GLINT_SLOW_WRITE_REG(3, BroadcastMask); + GLINT_SLOW_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode); - GLINT_SLOW_WRITE_REG(pGlint->pprod, LBReadMode); + GLINT_SLOW_WRITE_REG(pGlint->pprod | LBRM_ScanlineInt2, LBReadMode); + pGlint->pprod |= FBRM_ScanlineInt2; GLINT_SLOW_WRITE_REG(pGlint->pprod, FBReadMode); GLINT_SLOW_WRITE_REG(0, dXSub); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWriteMode); @@ -149,7 +150,6 @@ DualMXInitializeEngine(ScrnInfoPtr pScrn) GLINT_SLOW_WRITE_REG(0x400, FilterMode); GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask); GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask); - GLINT_SLOW_WRITE_REG(pGlint->rasterizerMode, RasterizerMode); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTDepth); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceOffset); GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBPixelOffset); @@ -172,6 +172,7 @@ DualMXInitializeEngine(ScrnInfoPtr pScrn) GLINT_SLOW_WRITE_REG(0x0, PixelSize); break; } + pGlint->ROP = 0xFF; pGlint->ClippingOn = FALSE; pGlint->startxsub = 0; @@ -212,32 +213,34 @@ DualMXAccelInit(ScreenPtr pScreen) infoPtr->SetClippingRectangle = DualMXSetClippingRectangle; infoPtr->DisableClipping = DualMXDisableClipping; infoPtr->ClippingFlags = HARDWARE_CLIP_MONO_8x8_FILL | +#if 0 HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | +#endif HARDWARE_CLIP_SOLID_FILL; infoPtr->SolidFillFlags = 0; infoPtr->SetupForSolidFill = DualMXSetupForFillRectSolid; infoPtr->SubsequentSolidFillRect = DualMXSubsequentFillRectSolid; - /* - * The following optimized routines are copied from tx_accel.c, - * but haven't been ported to a dual MX board. - */ -#ifdef NOT_DONE infoPtr->SolidLineFlags = 0; infoPtr->PolySegmentThinSolidFlags = 0; infoPtr->PolylinesThinSolidFlags = 0; infoPtr->SetupForSolidLine = DualMXSetupForSolidLine; infoPtr->SubsequentSolidHorVertLine = DualMXSubsequentHorVertLine; - infoPtr->SubsequentSolidBresenhamLine = + if (!(pScrn->overlayFlags & OVERLAY_8_32_PLANAR)) + { + infoPtr->SubsequentSolidBresenhamLine = DualMXSubsequentSolidBresenhamLine; + } infoPtr->PolySegmentThinSolid = DualMXPolySegmentThinSolidWrapper; infoPtr->PolylinesThinSolid = DualMXPolylinesThinSolidWrapper; +#if 0 infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY | ONLY_LEFT_TO_RIGHT_BITBLT; infoPtr->SetupForScreenToScreenCopy = DualMXSetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = DualMXSubsequentScreenToScreenCopy; +#endif infoPtr->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_ORIGIN | HARDWARE_PATTERN_SCREEN_ORIGIN | @@ -246,6 +249,7 @@ DualMXAccelInit(ScreenPtr pScreen) infoPtr->SubsequentMono8x8PatternFillRect = DualMXSubsequentMono8x8PatternFillRect; +#if 0 if (!pGlint->UsePCIRetry) { infoPtr->ScanlineCPUToScreenColorExpandFillFlags = TRANSPARENCY_ONLY | @@ -285,6 +289,7 @@ DualMXAccelInit(ScreenPtr pScreen) infoPtr->SubsequentCPUToScreenColorExpandFill = DualMXSubsequentCPUToScreenColorExpandFill; } +#endif infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES; @@ -299,7 +304,6 @@ DualMXAccelInit(ScreenPtr pScreen) pScrn->bitsPerPixel / 8); xf86InitFBManager(pScreen, &AvailFBArea); -#endif /* NOT_DONE */ return (XAAInit(pScreen, infoPtr)); } @@ -312,11 +316,6 @@ static void DualMXLoadCoord( ){ GLINTPtr pGlint = GLINTPTR(pScrn); - /* - * Optimization from tx_accel.c where these values are cached on the - * host doesn't appear to work. We definitely need to reload at least - * the StartXDom value. I'll play it safe and reload them all. - */ GLINT_WRITE_REG(w<<16, StartXSub); GLINT_WRITE_REG(x<<16,StartXDom); GLINT_WRITE_REG(y<<16,StartY); @@ -686,14 +685,15 @@ DualMXSubsequentMono8x8PatternFillRect( if (pGlint->FrameBufferReadMode != -1) { if (pGlint->ROP == GXcopy) { GLINT_WRITE_REG(pGlint->BackGroundColor, FBBlockColor); - GLINT_WRITE_REG(PrimitiveTrapezoid | FastFillEnable,Render); + span = 0; } else { GLINT_WRITE_REG(pGlint->BackGroundColor, PatternRamData0); - GLINT_WRITE_REG(2<<1|2<<4|patternx<<7|patterny<<12|ASM_InvertPattern | + span = SpanOperation; + } + GLINT_WRITE_REG(2<<1|2<<4|patternx<<7|patterny<<12|ASM_InvertPattern | UNIT_ENABLE, AreaStippleMode); - GLINT_WRITE_REG(AreaStippleEnable | SpanOperation | FastFillEnable | + GLINT_WRITE_REG(AreaStippleEnable | span | FastFillEnable | PrimitiveTrapezoid, Render); - } } if (pGlint->ROP == GXcopy) { @@ -749,7 +749,7 @@ DualMXWriteBitmap(ScrnInfoPtr pScrn, DualMXLoadCoord(pScrn, x, y, x+w, h, 0, 1); if(bg == -1) { - /* >>>>> set fg <<<<<<<< */ + /* === set fg === */ REPLICATE(fg); GLINT_WAIT(3); if (rop == GXcopy) { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c index a17ab1c8b..0a7728ded 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c @@ -454,8 +454,7 @@ DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode) pReg->glintRegs[VTGVSyncStart >> 3] = temp2; pReg->glintRegs[VTGVBlankEnd >> 3] = mode->CrtcVTotal - mode->CrtcVDisplay; - pReg->glintRegs[VTGPolarity >> 3] = (((mode->Flags & V_PHSYNC) ? 0:2)<<2) | - ((mode->Flags & V_PVSYNC) ? 0 : 2) | (0xb0); + pReg->glintRegs[VTGPolarity >> 3] = 0xba; pReg->glintRegs[VClkCtl >> 3] = 0; pReg->glintRegs[VTGVGateStart >> 3] = pReg->glintRegs[VTGVBlankEnd>>3] - 1; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h index 48c1d1a5e..9ef168854 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h @@ -45,6 +45,13 @@ #include "glint_dripriv.h" #endif +#define GLINT_VERSION 4000 +#define GLINT_NAME "GLINT" +#define GLINT_DRIVER_NAME "glint" +#define GLINT_MAJOR_VERSION 1 +#define GLINT_MINOR_VERSION 0 +#define GLINT_PATCHLEVEL 0 + #define GLINT_MAX_MX_DEVICES 2 #define GLINT_VGA_MMIO_OFF 0x6000 @@ -98,6 +105,10 @@ typedef struct { unsigned char * IOBaseVGA; unsigned char * FbBase; long FbMapSize; + DGAModePtr DGAModes; + int numDGAModes; + Bool DGAactive; + int DGAViewportStatus; Bool DoubleBuffer; Bool NoAccel; Bool FBDev; @@ -188,17 +199,20 @@ Bool Permedia2HWCursorInit(ScreenPtr pScreen); void PermediaRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void PermediaSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); Bool PermediaInit(ScrnInfoPtr pScrn, DisplayModePtr mode); +void PermediaInitializeEngine(ScrnInfoPtr pScrn); Bool PermediaAccelInit(ScreenPtr pScreen); void Permedia2VRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void Permedia2VSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); Bool Permedia2VInit(ScrnInfoPtr pScrn, DisplayModePtr mode); Bool Permedia2vHWCursorInit(ScreenPtr pScreen); +void TXInitializeEngine(ScrnInfoPtr pScrn); void TXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void TXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); Bool TXInit(ScrnInfoPtr pScrn, DisplayModePtr mode); Bool TXAccelInit(ScreenPtr pScreen); +void DualMXInitializeEngine(ScrnInfoPtr pScrn); void DualMXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); void DualMXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg); Bool DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c new file mode 100644 index 000000000..f3aa7ebe5 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c @@ -0,0 +1,294 @@ +/* + * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Alan Hourihane not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Alan Hourihane makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk> + */ +/* $XFree86: $ */ + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Pci.h" +#include "xf86PciInfo.h" +#include "xaa.h" +#include "xaalocal.h" +#include "glint.h" +#include "glint_regs.h" +#include "dgaproc.h" + +static Bool GLINT_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **, + int *, int *, int *); +static Bool GLINT_SetMode(ScrnInfoPtr, DGAModePtr); +static void GLINT_Sync(ScrnInfoPtr); +static int GLINT_GetViewport(ScrnInfoPtr); +static void GLINT_SetViewport(ScrnInfoPtr, int, int, int); +static void GLINT_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long); +static void GLINT_BlitRect(ScrnInfoPtr, int, int, int, int, int, int); +static void GLINT_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int, + unsigned long); + +static +DGAFunctionRec GLINTDGAFuncs = { + GLINT_OpenFramebuffer, + NULL, + GLINT_SetMode, + GLINT_SetViewport, + GLINT_GetViewport, + GLINT_Sync, + GLINT_FillRect, + NULL, +#if 0 + GLINT_BlitRect, + GLINT_BlitTransRect +#else + NULL +#endif +}; + +Bool +GLINTDGAInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + GLINTPtr pGlint = GLINTPTR(pScrn); + DGAModePtr modes = NULL, newmodes = NULL, currentMode; + DisplayModePtr pMode, firstMode; + int Bpp = pScrn->bitsPerPixel >> 3; + int num = 0; + Bool oneMore; + + pMode = firstMode = pScrn->modes; + + while(pMode) { + + if(0 /*pScrn->displayWidth != pMode->HDisplay*/) { + newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec)); + oneMore = TRUE; + } else { + newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec)); + oneMore = FALSE; + } + + if(!newmodes) { + xfree(modes); + return FALSE; + } + modes = newmodes; + +SECOND_PASS: + + currentMode = modes + num; + num++; + + currentMode->mode = pMode; + currentMode->flags = DGA_CONCURRENT_ACCESS /*| DGA_PIXMAP_AVAILABLE*/; + if(!pGlint->NoAccel) + currentMode->flags |= DGA_FILL_RECT /*| DGA_BLIT_RECT*/; + if(pMode->Flags & V_DBLSCAN) + currentMode->flags |= DGA_DOUBLESCAN; + if(pMode->Flags & V_INTERLACE) + currentMode->flags |= DGA_INTERLACED; + currentMode->byteOrder = pScrn->imageByteOrder; + currentMode->depth = pScrn->depth; + currentMode->bitsPerPixel = pScrn->bitsPerPixel; + currentMode->red_mask = pScrn->mask.red; + currentMode->green_mask = pScrn->mask.green; + currentMode->blue_mask = pScrn->mask.blue; + currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor; + currentMode->viewportWidth = pMode->HDisplay; + currentMode->viewportHeight = pMode->VDisplay; + currentMode->xViewportStep = 1; + currentMode->yViewportStep = 1; + currentMode->viewportFlags = DGA_FLIP_RETRACE; + currentMode->offset = 0; + currentMode->address = pGlint->FbBase; + + if(oneMore) { /* first one is narrow width */ + currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L; + currentMode->imageWidth = pMode->HDisplay; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + oneMore = FALSE; + goto SECOND_PASS; + } else { + currentMode->bytesPerScanline = + ((pScrn->displayWidth * Bpp) + 3) & ~3L; + currentMode->imageWidth = pScrn->displayWidth; + currentMode->imageHeight = pMode->VDisplay; + currentMode->pixmapWidth = currentMode->imageWidth; + currentMode->pixmapHeight = currentMode->imageHeight; + currentMode->maxViewportX = currentMode->imageWidth - + currentMode->viewportWidth; + /* this might need to get clamped to some maximum */ + currentMode->maxViewportY = currentMode->imageHeight - + currentMode->viewportHeight; + } + + pMode = pMode->next; + if(pMode == firstMode) + break; + } + + pGlint->numDGAModes = num; + pGlint->DGAModes = modes; + + return DGAInit(pScreen, &GLINTDGAFuncs, modes, num); +} + + +static Bool +GLINT_SetMode( + ScrnInfoPtr pScrn, + DGAModePtr pMode +){ + static int OldDisplayWidth[MAXSCREENS]; + int index = pScrn->pScreen->myNum; + GLINTPtr pGlint = GLINTPTR(pScrn); + + if(!pMode) { /* restore the original mode */ + /* put the ScreenParameters back */ + + pScrn->displayWidth = OldDisplayWidth[index]; + + GLINTSwitchMode(index, pScrn->currentMode, 0); + pGlint->DGAactive = FALSE; + } else { + if(!pGlint->DGAactive) { /* save the old parameters */ + OldDisplayWidth[index] = pScrn->displayWidth; + + pGlint->DGAactive = TRUE; + } + + pScrn->displayWidth = pMode->bytesPerScanline / + (pMode->bitsPerPixel >> 3); + + GLINTSwitchMode(index, pMode->mode, 0); + } + + return TRUE; +} + +static int +GLINT_GetViewport( + ScrnInfoPtr pScrn +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + + return pGlint->DGAViewportStatus; +} + +static void +GLINT_SetViewport( + ScrnInfoPtr pScrn, + int x, int y, + int flags +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + + GLINTAdjustFrame(pScrn->pScreen->myNum, x, y, flags); + pGlint->DGAViewportStatus = 0; /* GLINTAdjustFrame loops until finished */ +} + +static void +GLINT_FillRect ( + ScrnInfoPtr pScrn, + int x, int y, int w, int h, + unsigned long color +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + + if(pGlint->AccelInfoRec) { + (*pGlint->AccelInfoRec->SetupForSolidFill)(pScrn, color, GXcopy, ~0); + (*pGlint->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h); + SET_SYNC_FLAG(pGlint->AccelInfoRec); + } +} + +static void +GLINT_Sync( + ScrnInfoPtr pScrn +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + + if(pGlint->AccelInfoRec) { + (*pGlint->AccelInfoRec->Sync)(pScrn); + } +} + +static void +GLINT_BlitRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + + if(pGlint->AccelInfoRec) { + int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1; + int ydir = (srcy < dsty) ? -1 : 1; + + (*pGlint->AccelInfoRec->SetupForScreenToScreenCopy)( + pScrn, xdir, ydir, GXcopy, ~0, -1); + (*pGlint->AccelInfoRec->SubsequentScreenToScreenCopy)( + pScrn, srcx, srcy, dstx, dsty, w, h); + SET_SYNC_FLAG(pGlint->AccelInfoRec); + } +} + + +static void +GLINT_BlitTransRect( + ScrnInfoPtr pScrn, + int srcx, int srcy, + int w, int h, + int dstx, int dsty, + unsigned long color +){ + /* this one should be separate since the XAA function would + prohibit usage of ~0 as the key */ +} + + +static Bool +GLINT_OpenFramebuffer( + ScrnInfoPtr pScrn, + char **name, + unsigned char **mem, + int *size, + int *offset, + int *flags +){ + GLINTPtr pGlint = GLINTPTR(pScrn); + + *name = NULL; /* no special device */ + *mem = (unsigned char*)pGlint->FbAddress; + *size = pGlint->FbMapSize; + *offset = 0; + *flags = DGA_NEED_ROOT; + + return TRUE; +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c index 9acce4b54..9aa55de42 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c @@ -40,11 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86PciInfo.h" #include "xf86Pci.h" -#define PSZ 8 -#include "cfb.h" -#undef PSZ -#include "cfb16.h" -#include "cfb32.h" +#include "fb.h" #include "miline.h" @@ -61,18 +57,7 @@ static void GLINTDestroyContext(ScreenPtr pScreen, drmContext hwContext, DRIContextType contextStore); static int -GLINTDRIControlInitSingleMX(int drmSubFD, int irq) -{ - - int retcode; - - /* Perhaps add flag to for single mx here? */ - if ((retcode = drmCtlInstHandler(drmSubFD, irq))) return 1; - return 0; -} - -static int -GLINTDRIControlInitDualMX(int drmSubFD, int irq) +GLINTDRIControlInit(int drmSubFD, int irq) { int retcode; @@ -105,7 +90,7 @@ GLINTInitVisualConfigs(ScreenPtr pScreen) case 32: /* if(pGlint->Overlay): differentiate overlays when we support either alpha buffer or 3D rendering in Overlay */ - numConfigs = 5; + numConfigs = 4; if (!(pConfigs = (__GLXvisualConfig *)xnfcalloc( sizeof(__GLXvisualConfig), @@ -260,6 +245,7 @@ GLINTInitVisualConfigs(ScreenPtr pScreen) pConfigs[3].transparentIndex = 0; pGlintConfigs[3].index = 3; +#if 0 /* config 4: db=TRUE, depth=16, stencil=8, conformant (a lie) */ pConfigs[4].vid = -1; pConfigs[4].class = -1; @@ -291,6 +277,7 @@ GLINTInitVisualConfigs(ScreenPtr pScreen) pConfigs[4].transparentAlpha = 0; pConfigs[4].transparentIndex = 0; pGlintConfigs[4].index = 4; +#endif break; } @@ -359,6 +346,18 @@ GLINTDRIScreenInit(ScreenPtr pScreen) if (!LoaderSymbol("drmAvailable")) return FALSE; #endif + /* Check the DRI version */ + { + int major, minor, patch; + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "GLINTDRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + } + if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_GAMMA) return FALSE; if (pGlint->numMXDevices > 2) return FALSE; @@ -377,9 +376,9 @@ GLINTDRIScreenInit(ScreenPtr pScreen) ((pciConfigPtr)pGlint->PciInfo->thisCard)->busnum, ((pciConfigPtr)pGlint->PciInfo->thisCard)->devnum, ((pciConfigPtr)pGlint->PciInfo->thisCard)->funcnum); - pDRIInfo->ddxDriverMajorVersion = 0; - pDRIInfo->ddxDriverMinorVersion = 1; - pDRIInfo->ddxDriverPatchVersion = 0; + pDRIInfo->ddxDriverMajorVersion = GLINT_MAJOR_VERSION; + pDRIInfo->ddxDriverMinorVersion = GLINT_MINOR_VERSION; + pDRIInfo->ddxDriverPatchVersion = GLINT_PATCHLEVEL; pDRIInfo->frameBufferPhysicalAddress = pGlint->FbAddress; pDRIInfo->frameBufferSize = pGlint->FbMapSize; pDRIInfo->frameBufferStride = @@ -412,6 +411,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen) DRIDestroyInfoRec(pGlint->pDRIInfo); return FALSE; } + pDRIInfo->devPrivate = pGlintDRI; pDRIInfo->devPrivateSize = sizeof(GLINTDRIRec); pDRIInfo->contextSize = sizeof(GLINTDRIContextRec); @@ -430,6 +430,32 @@ GLINTDRIScreenInit(ScreenPtr pScreen) return FALSE; } + /* Check the MGA DRM version */ + { + drmVersionPtr version = drmGetVersion(pGlint->drmSubFD); + if (version) { + if (version->version_major != 1 || + version->version_minor != 0 || + version->version_patchlevel < 0) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, + "GLINTDRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + version->version_major, + version->version_minor, + version->version_patchlevel); + GLINTDRICloseScreen(pScreen); + drmFreeVersion(version); + return FALSE; + } + drmFreeVersion(version); + } + } + + /* Tell the client driver how many MX's we have */ + pGlintDRI->numMXDevices = pGlint->numMXDevices; + /* Tell the client about our screen size setup */ + pGlintDRI->pprod = pGlint->pprod; + /* setup device specific direct rendering memory maps */ /* pci region 0: control regs, first 4k page, priveledged writes */ @@ -510,6 +536,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen) if ((bufs = drmAddBufs(pGlint->drmSubFD, xf86ConfigDRI.bufs[i].count, xf86ConfigDRI.bufs[i].size, + 0, 0 /* flags */)) <= 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] failure adding %d %d byte DMA buffers\n", @@ -530,6 +557,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen) if ((bufs = drmAddBufs(pGlint->drmSubFD, GLINT_DRI_BUF_COUNT, GLINT_DRI_BUF_SIZE, + 0, 0 /* flags */)) <= 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] failure adding %d %d byte DMA buffers\n", @@ -567,26 +595,13 @@ GLINTDRIScreenInit(ScreenPtr pScreen) ->thisCard)->funcnum); } - if (pGlint->numMXDevices == 2) { - if ( (pGlint->irq <= 0) || - GLINTDRIControlInitDualMX(pGlint->drmSubFD, pGlint->irq) ) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] cannot initialize dma with IRQ %d\n", - pGlint->irq); - DRICloseScreen(pScreen); - return FALSE; - } - } - - if (pGlint->numMXDevices == 1) { - if ( (pGlint->irq <= 0) || - GLINTDRIControlInitSingleMX(pGlint->drmSubFD, pGlint->irq) ) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] cannot initialize dma with IRQ %d\n", - pGlint->irq); - DRICloseScreen(pScreen); - return FALSE; - } + if ( (pGlint->irq <= 0) || + GLINTDRIControlInit(pGlint->drmSubFD, pGlint->irq) ) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[drm] cannot initialize dma with IRQ %d\n", + pGlint->irq); + DRICloseScreen(pScreen); + return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -634,7 +649,8 @@ Bool GLINTCreateContext(ScreenPtr pScreen, VisualPtr visual, drmContext hwContext, - void *pVisualConfigPriv) + void *pVisualConfigPriv, + DRIContextType contextStore) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; GLINTPtr pGlint = GLINTPTR(pScrn); @@ -730,9 +746,9 @@ GLINTDRISwapContext( ScreenPtr pScreen, DRISyncType syncType, DRIContextType readContextType, - void** readContextStore, + void *readContextStore, DRIContextType writeContextType, - void** writeContextStore) + void *writeContextStore) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; GLINTPtr pGlint = GLINTPTR(pScrn); @@ -1125,7 +1141,7 @@ GLINTDRISwapContext( /* send gamma the context dump command */ GLINT_WAIT(3); - if (pGlint->numMXDevices > 1) + if (pGlint->numMXDevices == 2) GLINT_WRITE_REG(1, BroadcastMask); GLINT_WRITE_REG(3<<14, FilterMode); /* context bits on gamma */ GLINT_WRITE_REG(GLINT_GAMMA_CONTEXT_MASK, ContextDump); @@ -1170,7 +1186,7 @@ dumpIndex,readValue); /* send context restore command */ GLINT_WAIT(1); - if (pGlint->numMXDevices > 1) + if (pGlint->numMXDevices == 2) GLINT_WRITE_REG(1, BroadcastMask); GLINT_WAIT(3); @@ -1199,7 +1215,7 @@ dumpIndex,pWC->Gamma[dumpIndex]); pGlint->AccelInfoRec->NeedToSync = TRUE; /* finally the MX portions */ - if (pGlint->numMXDevices > 1) + if (pGlint->numMXDevices == 2) GLINT_SLOW_WRITE_REG(1, BroadcastMask); GLINT_SLOW_WRITE_REG(pWC->MX1.CSStart, SStart); GLINT_SLOW_WRITE_REG(pWC->MX1.CdSdx, dSdx); @@ -1452,7 +1468,7 @@ dumpIndex,pWC->Gamma[dumpIndex]); /* restore the 2D portion of the new context */ /* Restore MX1's registers */ - if (pGlint->numMXDevices > 1) + if (pGlint->numMXDevices == 2) GLINT_SLOW_WRITE_REG(1, BroadcastMask); GLINT_SLOW_WRITE_REG(pWC->MX1.CStartXDom, StartXDom); GLINT_SLOW_WRITE_REG(pWC->MX1.CdXDom, dXDom); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h index 03f4d9fed..9e11edda8 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h @@ -50,6 +50,8 @@ typedef struct { drmMapFlags flagsControlRegs1; drmMapFlags flagsControlRegs2; drmMapFlags flagsControlRegs3; + int numMXDevices; + int pprod; } GLINTDRIRec, *GLINTDRIPtr; #define GLINT_DRI_BUF_COUNT 20 diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h index fe29ffccf..e026f8b18 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h @@ -42,14 +42,15 @@ extern void GlxSetVisualConfigs( extern Bool GLINTCreateContext(ScreenPtr pScreen, VisualPtr visual, drmContext hwContext, - void* pVisualConfigPriv); + void* pVisualConfigPriv, + DRIContextType contextStore); extern void GLINTDRISwapContext( ScreenPtr pScreen, DRISyncType syncType, DRIContextType readContextType, - void** readContextStore, + void* readContextStore, DRIContextType writeContextType, - void** writeContextStore); + void* writeContextStore); /* Macros to Setup Generic Kernel Device Driver to Handle DMA for gamma */ diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c index 8c33db140..f0b316729 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c @@ -123,13 +123,6 @@ static Bool GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); static int pix24bpp = 0; static Bool FBDevProbed = FALSE; -#define VERSION 4000 -#define GLINT_NAME "GLINT" -#define GLINT_DRIVER_NAME "glint" -#define GLINT_MAJOR_VERSION 1 -#define GLINT_MINOR_VERSION 0 -#define GLINT_PATCHLEVEL 0 - /* * This contains the functions needed by the server after loading the driver * module. It must be supplied, and gets passed back by the SetupProc @@ -139,7 +132,7 @@ static Bool FBDevProbed = FALSE; */ DriverRec GLINT = { - VERSION, + GLINT_VERSION, GLINT_DRIVER_NAME, #if 0 "accelerated driver for 3dlabs and derived chipsets", @@ -704,7 +697,7 @@ GLINTProbe(DriverPtr drv, int flags) NULL,NULL,NULL,NULL); } /* Fill in what we can of the ScrnInfoRec */ - pScrn->driverVersion = VERSION; + pScrn->driverVersion = GLINT_VERSION; pScrn->driverName = GLINT_DRIVER_NAME; pScrn->name = GLINT_NAME; pScrn->Probe = GLINTProbe; @@ -807,7 +800,7 @@ GLINTProbe(DriverPtr drv, int flags) } } /* Fill in what we can of the ScrnInfoRec */ - pScrn->driverVersion = VERSION; + pScrn->driverVersion = GLINT_VERSION; pScrn->driverName = GLINT_DRIVER_NAME; pScrn->name = GLINT_NAME; pScrn->Probe = GLINTProbe; @@ -2665,6 +2658,9 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) xf86SetBlackWhitePixels(pScreen); + if (!pGlint->ShadowFB) + GLINTDGAInit(pScreen); + if (pScrn->bitsPerPixel > 8) { /* Fixup RGB ordering */ visual = pScreen->visuals + pScreen->numVisuals; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h index f33e42c80..489bf8eed 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h @@ -35,6 +35,9 @@ #define PCI_CHIP_3DLABS_PERMEDIA 0x04 #define PCI_CHIP_3DLABS_MX 0x06 #define PCI_CHIP_3DLABS_PERMEDIA2 0x07 +#define PCI_CHIP_3DLABS_GAMMA 0x08 +#define PCI_CHIP_3DLABS_PERMEDIA2V 0x09 +#define PCI_CHIP_3DLABS_PERMEDIA3 0x0A #define PCI_CHIP_TI_PERMEDIA 0x3d04 #define CFGRevisionId 0x08 @@ -90,6 +93,10 @@ #define SCLK_SEL_MCLK_HALF (3 << 10) #define ByDMAControl 0x00D8 +/* GLINT R3 & Permedia3 Region 0 Bypass Controls */ +#define PM3ByAperture1Mode 0x0300 +#define PM3ByAperture2Mode 0x0328 + /* GLINT 500TX LocalBuffer Registers */ #define LBMemoryCtl 0x1000 #define LBNumBanksMask 0x00000001 @@ -192,6 +199,17 @@ #define PMFramebufferWriteMask 0x1140 #define PMCount 0x1180 +/* Permedia 3 & GLINT R3 Memory Control */ +#define PM3MemCounter 0x1000 +#define PM3MemBypassWriteMask 0x1008 +#define PM3MemScratch 0x1010 +#define PM3LocalMemCaps 0x1018 +#define PM3LocalMemTimings 0x1020 +#define PM3LocalMemControl 0x1028 +#define PM3LocalMemRefresh 0x1030 +#define PM3LocalMemPowerDown 0x1038 +#define PM3RemoteMemControl 0x1100 + /* Framebuffer Registers */ #define FBMemoryCtl 0x1800 #define FBModeSel 0x1808 @@ -1146,14 +1164,15 @@ #define GLINT_READ_REG(r) \ GLINT_VERB_READ_REG(pGlint,r,__FILE__,__LINE__) #else -#define GLINT_WRITE_REG(v,r) \ -do{ \ - *(volatile CARD32 *)((char *)pGlint->IOBase+(r))=v; \ - mem_barrier(); \ -}while(0) -#define GLINT_READ_REG(r) \ - (*(volatile CARD32 *)((char *)pGlint->IOBase+(r))) -#endif + +#define GLINT_WRITE_REG(v,r) MMIO_OUT32(pGlint->IOBase,(unsigned long)r, v) +#define GLINT_READ_REG(r) MMIO_IN32(pGlint->IOBase,(unsigned long)r) +#define GLINT_SECONDARY_WRITE_REG(v,r) \ + MMIO_OUT32(pGlint->IOBase,(unsigned long)r+0x10000, v) +#define GLINT_SECONDARY_READ_REG(r) \ + MMIO_IN32(pGlint->IOBase,(unsigned long)r+0x10000) + +#endif /* DEBUG */ #define GLINT_WAIT(n) \ do{ \ @@ -1179,23 +1198,12 @@ do{ \ GLINTDACDelay(5); \ }while(0) -#define GLINT_SECONDARY_WRITE_REG(v,r) \ -do{ \ - *(volatile CARD32 *)((char *)pGlint->SecondaryBase+(r))=v; \ -}while(0) - -#define GLINT_SECONDARY_READ_REG(r) \ - (*(volatile CARD32 *)((char *)pGlint->SecondaryBase+(r))) - #define GLINT_SECONDARY_SLOW_WRITE_REG(v,r) \ do{ \ while(GLINT_READ_REG(InFIFOSpace)<1); \ GLINT_SECONDARY_WRITE_REG(v,r); \ }while(0) -#define GLINT_LOAD_PAR(v,r) \ - *(unsigned long *)((char*)pGlint->IOBase+r) = *((unsigned long *) &v) - #define REPLICATE(r) \ { \ if (pScrn->bitsPerPixel == 16) { \ @@ -1208,14 +1216,21 @@ do{ \ } \ } +#ifndef XF86DRI #define LOADROP(rop) \ { \ - if (pGlint->ROP != rop) { \ + if (pGlint->ROP != rop) { \ GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode); \ pGlint->ROP = rop; \ } \ } - +#else +#define LOADROP(rop) \ + { \ + GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode); \ + pGlint->ROP = rop; \ + } +#endif #define CHECKCLIPPING \ { \ @@ -1226,6 +1241,7 @@ do{ \ } \ } +#ifndef XF86DRI #define DO_PLANEMASK(planemask) \ { \ if (planemask != pGlint->planemask) { \ @@ -1234,4 +1250,12 @@ do{ \ GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\ } \ } +#else +#define DO_PLANEMASK(planemask) \ + { \ + pGlint->planemask = planemask; \ + REPLICATE(planemask); \ + GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\ + } +#endif #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c index 6d1863f0a..b728093d7 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c @@ -1138,7 +1138,7 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn, } if(bg == -1) { - /* >>>>> set fg <<<<<<<< */ + /* === set fg === */ REPLICATE(fg); if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { GLINT_WRITE_REG(fg, FBBlockColor); @@ -1146,8 +1146,8 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn, GLINT_WRITE_REG(fg, ConstantColor); } } else if(rop == GXcopy) { - /* >>>>> set bg <<<<<<< */ - /* >>>>> draw rect (x,y,w,h) */ + /* === set bg === */ + /* === draw rect (x,y,w,h) === */ REPLICATE(bg); if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { GLINT_WRITE_REG(bg, FBBlockColor); @@ -1155,7 +1155,7 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn, GLINT_WRITE_REG(bg, ConstantColor); } GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |mode,Render); - /* >>>>>> set fg <<<<<< */ + /* === set fg === */ REPLICATE(fg); if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { GLINT_WRITE_REG(fg, FBBlockColor); @@ -1164,7 +1164,7 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn, } } else { SecondPass = TRUE; - /* >>>>> set fg <<<<<<< */ + /* === set fg === */ REPLICATE(fg); if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { GLINT_WRITE_REG(fg, FBBlockColor); @@ -1173,8 +1173,8 @@ Permedia2WriteBitmap(ScrnInfoPtr pScrn, } } - /* >>>>>>>>> initiate transfer (x,y,w,h). Skipleft pixels on the - left edge will be clipped <<<<<< */ + /* === initiate transfer (x,y,w,h). Skipleft pixels on the + left edge will be clipped === */ SECOND_PASS: GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | mode | SyncOnBitMask, Render); @@ -1192,7 +1192,7 @@ SECOND_PASS: if(SecondPass) { SecondPass = FALSE; - /* >>>>>> invert bitmask and set bg <<<<<<<< */ + /* === invert bitmask and set bg === */ REPLICATE(bg); GLINT_WAIT(3); if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c index 4a6aa676a..0604fa045 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c @@ -692,7 +692,7 @@ TXWriteBitmap(ScrnInfoPtr pScrn, TXLoadCoord(pScrn, x, y, x+w, h, 0, 1); if(bg == -1) { - /* >>>>> set fg <<<<<<<< */ + /* === set fg === */ REPLICATE(fg); GLINT_WAIT(3); if (rop == GXcopy) { diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h index 6aceea540..030b66a91 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h @@ -36,16 +36,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef _I810_H_ #define _I810_H_ - +#include "compiler.h" #include "xf86PciInfo.h" #include "xf86Pci.h" #include "i810_reg.h" #include "xaa.h" #include "xf86Cursor.h" -#undef XF86DRI - - #ifdef XF86DRI #include "xf86drm.h" #include "sarea.h" @@ -57,6 +54,14 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #endif +#define I810_VERSION 4000 +#define I810_NAME "I810" +#define I810_DRIVER_NAME "i810" +#define I810_MAJOR_VERSION 1 +#define I810_MINOR_VERSION 0 +#define I810_PATCHLEVEL 0 + + /* Globals */ typedef struct _I810Rec *I810Ptr; @@ -211,8 +216,8 @@ typedef struct _I810Rec { extern Bool I810DRIScreenInit(ScreenPtr pScreen); extern void I810DRICloseScreen(ScreenPtr pScreen); extern Bool I810DRIFinishScreenInit(ScreenPtr pScreen); -extern Bool I810drmInitDma(ScrnInfoPtr pScrn); -extern Bool I810drmCleanupDma(ScrnInfoPtr pScrn); +extern Bool I810InitDma(ScrnInfoPtr pScrn); +extern Bool I810CleanupDma(ScrnInfoPtr pScrn); #define I810PTR(p) ((I810Ptr)((p)->driverPrivate)) #define I810REGPTR(p) (&(I810PTR(p)->ModeReg)) @@ -312,7 +317,7 @@ extern void I810EmitInvarientState(ScrnInfoPtr pScrn); /* To remove all debugging, make sure I810_DEBUG is defined as a * preprocessor symbol, and equal to zero. */ -#define I810_DEBUG 0 +#define I810_DEBUG 0 #ifndef I810_DEBUG #warning "Debugging enabled - expect reduced performance" extern int I810_DEBUG; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c index c63f9ed20..e2c48f68f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c @@ -1,4 +1,4 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.2 2000/03/02 16:07:49 martin Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.3 1999/09/27 06:29:57 dawes Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -20,10 +20,6 @@ #include "i810.h" #include "i810_dri.h" -#include "xf86drm.h" -#include "dristruct.h" - - static char I810KernelDriverName[] = "i810"; static char I810ClientDriverName[] = "i810"; @@ -62,6 +58,44 @@ static int i810_pitch_flags[] = { 0 }; +Bool I810CleanupDma(ScrnInfoPtr pScrn) +{ + I810Ptr pI810 = I810PTR(pScrn); + Bool ret_val; + + ret_val = drmI810CleanupDma(pI810->drmSubFD); + if (ret_val == FALSE) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I810 Dma Cleanup Failed\n"); + return ret_val; +} + +Bool I810InitDma(ScrnInfoPtr pScrn) +{ + I810Ptr pI810 = I810PTR(pScrn); + I810RingBuffer *ring = &(pI810->LpRing); + drmI810Init info; + Bool ret_val; + + info.start = ring->mem.Start; + info.end = ring->mem.End; + info.size = ring->mem.Size; + info.ring_map_idx = 6; + info.buffer_map_idx = 5; + info.sarea_off = sizeof(XF86DRISAREARec); + + info.front_offset = 0; + info.back_offset = pI810->BackBuffer.Start; + info.depth_offset = pI810->DepthBuffer.Start; + info.w = pScrn->virtualX; + info.h = pScrn->virtualY; + info.pitch = pI810->auxPitch; + info.pitch_bits = pI810->auxPitchBits; + + ret_val = drmI810InitDma(pI810->drmSubFD, &info); + if(ret_val == FALSE) ErrorF("I810 Dma Initialization Failed\n"); + return ret_val; +} + static Bool I810InitVisualConfigs(ScreenPtr pScreen) { @@ -71,6 +105,7 @@ I810InitVisualConfigs(ScreenPtr pScreen) __GLXvisualConfig *pConfigs = 0; I810ConfigPrivPtr pI810Configs = 0; I810ConfigPrivPtr *pI810ConfigPtrs = 0; + int accum, stencil, db, depth; int i; switch (pScrn->bitsPerPixel) { @@ -79,25 +114,20 @@ I810InitVisualConfigs(ScreenPtr pScreen) case 32: break; case 16: - numConfigs = 4; + numConfigs = 8; - if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), - numConfigs))) { + pConfigs = (__GLXvisualConfig *) xnfcalloc(sizeof(__GLXvisualConfig), numConfigs); + if (!pConfigs) return FALSE; - } - if (!(pI810Configs = - (I810ConfigPrivPtr)xnfcalloc(sizeof(I810ConfigPrivRec), - numConfigs))) - { + pI810Configs = (I810ConfigPrivPtr) xnfcalloc(sizeof(I810ConfigPrivRec), numConfigs); + if (!pI810Configs) { xfree(pConfigs); return FALSE; } - if (!(pI810ConfigPtrs = - (I810ConfigPrivPtr*)xnfcalloc(sizeof(I810ConfigPrivPtr), - numConfigs))) - { + pI810ConfigPtrs = (I810ConfigPrivPtr *) xnfcalloc(sizeof(I810ConfigPrivPtr), numConfigs); + if (!pI810ConfigPtrs) { xfree(pConfigs); xfree(pI810Configs); return FALSE; @@ -106,126 +136,61 @@ I810InitVisualConfigs(ScreenPtr pScreen) for (i=0; i<numConfigs; i++) pI810ConfigPtrs[i] = &pI810Configs[i]; - /* config 0: db=FALSE, depth=0 - config 1: db=FALSE, depth=16 - config 2: db=TRUE, depth=0; - config 3: db=TRUE, depth=16 - */ - pConfigs[0].vid = -1; - pConfigs[0].class = -1; - pConfigs[0].rgba = TRUE; - pConfigs[0].redSize = 5; - pConfigs[0].greenSize = 6; - pConfigs[0].blueSize = 5; - pConfigs[0].redMask = 0x0000F800; - pConfigs[0].greenMask = 0x000007E0; - pConfigs[0].blueMask = 0x0000001F; - pConfigs[0].alphaMask = 0; - pConfigs[0].accumRedSize = 0; - pConfigs[0].accumGreenSize = 0; - pConfigs[0].accumBlueSize = 0; - pConfigs[0].accumAlphaSize = 0; - pConfigs[0].doubleBuffer = FALSE; - pConfigs[0].stereo = FALSE; - pConfigs[0].bufferSize = 16; - pConfigs[0].depthSize = 16; - pConfigs[0].stencilSize = 0; - pConfigs[0].auxBuffers = 0; - pConfigs[0].level = 0; - pConfigs[0].visualRating = 0; - pConfigs[0].transparentPixel = 0; - pConfigs[0].transparentRed = 0; - pConfigs[0].transparentGreen = 0; - pConfigs[0].transparentBlue = 0; - pConfigs[0].transparentAlpha = 0; - pConfigs[0].transparentIndex = 0; - - pConfigs[1].vid = -1; - pConfigs[1].class = -1; - pConfigs[1].rgba = TRUE; - pConfigs[1].redSize = 5; - pConfigs[1].greenSize = 6; - pConfigs[1].blueSize = 5; - pConfigs[1].redMask = 0x0000F800; - pConfigs[1].greenMask = 0x000007E0; - pConfigs[1].blueMask = 0x0000001F; - pConfigs[1].alphaMask = 0; - pConfigs[1].accumRedSize = 0; - pConfigs[1].accumGreenSize = 0; - pConfigs[1].accumBlueSize = 0; - pConfigs[1].accumAlphaSize = 0; - pConfigs[1].doubleBuffer = FALSE; - pConfigs[1].stereo = FALSE; - pConfigs[1].bufferSize = 16; - pConfigs[1].depthSize = 16; - pConfigs[1].stencilSize = 0; - pConfigs[1].auxBuffers = 0; - pConfigs[1].level = 0; - pConfigs[1].visualRating = 0; - pConfigs[1].transparentPixel = 0; - pConfigs[1].transparentRed = 0; - pConfigs[1].transparentGreen = 0; - pConfigs[1].transparentBlue = 0; - pConfigs[1].transparentAlpha = 0; - pConfigs[1].transparentIndex = 0; - - pConfigs[2].vid = -1; - pConfigs[2].class = -1; - pConfigs[2].rgba = TRUE; - pConfigs[2].redSize = 5; - pConfigs[2].greenSize = 6; - pConfigs[2].blueSize = 5; - pConfigs[2].redMask = 0x0000F800; - pConfigs[2].greenMask = 0x000007E0; - pConfigs[2].blueMask = 0x0000001F; - pConfigs[2].alphaMask = 0; - pConfigs[2].accumRedSize = 0; - pConfigs[2].accumGreenSize = 0; - pConfigs[2].accumBlueSize = 0; - pConfigs[2].accumAlphaSize = 0; - pConfigs[2].doubleBuffer = TRUE; - pConfigs[2].stereo = FALSE; - pConfigs[2].bufferSize = 16; - pConfigs[2].depthSize = 16; - pConfigs[2].stencilSize = 0; - pConfigs[2].auxBuffers = 0; - pConfigs[2].level = 0; - pConfigs[2].visualRating = 0; - pConfigs[2].transparentPixel = 0; - pConfigs[2].transparentRed = 0; - pConfigs[2].transparentGreen = 0; - pConfigs[2].transparentBlue = 0; - pConfigs[2].transparentAlpha = 0; - pConfigs[2].transparentIndex = 0; - - pConfigs[3].vid = -1; - pConfigs[3].class = -1; - pConfigs[3].rgba = TRUE; - pConfigs[3].redSize = 5; - pConfigs[3].greenSize = 6; - pConfigs[3].blueSize = 5; - pConfigs[3].redMask = 0x0000F800; - pConfigs[3].greenMask = 0x000007E0; - pConfigs[3].blueMask = 0x0000001F; - pConfigs[3].alphaMask = 0; - pConfigs[3].accumRedSize = 0; - pConfigs[3].accumGreenSize = 0; - pConfigs[3].accumBlueSize = 0; - pConfigs[3].accumAlphaSize = 0; - pConfigs[3].doubleBuffer = TRUE; - pConfigs[3].stereo = FALSE; - pConfigs[3].bufferSize = 16; - pConfigs[3].depthSize = 16; - pConfigs[3].stencilSize = 0; - pConfigs[3].auxBuffers = 0; - pConfigs[3].level = 0; - pConfigs[3].visualRating = 0; - pConfigs[3].transparentPixel = 0; - pConfigs[3].transparentRed = 0; - pConfigs[3].transparentGreen = 0; - pConfigs[3].transparentBlue = 0; - pConfigs[3].transparentAlpha = 0; - pConfigs[3].transparentIndex = 0; + i = 0; + depth = 1; + for (accum = 0; accum <= 1; accum++) { + for (stencil = 0; stencil <= 1; stencil++) { + for (db = 0; db <= 1; db++) { + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + pConfigs[i].alphaMask = 0; + if (accum) { + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 16; + } + else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + pConfigs[i].doubleBuffer = db ? TRUE : FALSE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 16; + if (depth) + pConfigs[i].depthSize = 16; + else + pConfigs[i].depthSize = 0; + if (stencil) + pConfigs[i].stencilSize = 8; + else + pConfigs[i].stencilSize = 0; + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (stencil) + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + else + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + } + assert(i == numConfigs); break; } pI810->numVisualConfigs = numConfigs; @@ -260,12 +225,29 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) int width = pScrn->displayWidth * pI810->cpp; int i; - /* ToDo : save agpHandles? */ +#if XFree86LOADER + /* Check that the GLX, DRI, and DRM modules have been loaded by testing + * for known symbols in each module. */ + if (!LoaderSymbol("GlxSetVisualConfigs")) return FALSE; + if (!LoaderSymbol("DRIScreenInit")) return FALSE; + if (!LoaderSymbol("drmAvailable")) return FALSE; +#endif + + /* Check the DRI version */ + { + int major, minor, patch; + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "I810DRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + } - pDRIInfo = DRICreateInfoRec(); if (!pDRIInfo) { - ErrorF("DRICreateInfoRec failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "DRICreateInfoRec failed\n"); return FALSE; } @@ -279,13 +261,14 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pDRIInfo->drmDriverName = I810KernelDriverName; pDRIInfo->clientDriverName = I810ClientDriverName; pDRIInfo->busIdString = xalloc(64); + sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", ((pciConfigPtr)pI810->PciInfo->thisCard)->busnum, ((pciConfigPtr)pI810->PciInfo->thisCard)->devnum, ((pciConfigPtr)pI810->PciInfo->thisCard)->funcnum); - pDRIInfo->ddxDriverMajorVersion = 0; - pDRIInfo->ddxDriverMinorVersion = 1; - pDRIInfo->ddxDriverPatchVersion = 0; + pDRIInfo->ddxDriverMajorVersion = I810_MAJOR_VERSION; + pDRIInfo->ddxDriverMinorVersion = I810_MINOR_VERSION; + pDRIInfo->ddxDriverPatchVersion = I810_PATCHLEVEL; pDRIInfo->frameBufferPhysicalAddress = pI810->LinearAddr; pDRIInfo->frameBufferSize = (((pScrn->displayWidth * pScrn->virtualY * pI810->cpp) + @@ -302,8 +285,8 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) /* For now the mapping works by using a fixed size defined * in the SAREA header */ - if (sizeof(XF86DRISAREARec)+sizeof(drm_i810_sarea_t)>SAREA_MAX) { - ErrorF("Data does not fit in SAREA\n"); + if (sizeof(XF86DRISAREARec)+sizeof(I810SAREARec)>SAREA_MAX) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "Data does not fit in SAREA\n"); return FALSE; } pDRIInfo->SAREASize = SAREA_MAX; @@ -329,7 +312,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) * to allocate it. Scary stuff, hold on... */ if (!DRIScreenInit(pScreen, pDRIInfo, &pI810->drmSubFD)) { - ErrorF("DRIScreenInit failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "DRIScreenInit failed\n"); xfree(pDRIInfo->devPrivate); pDRIInfo->devPrivate=0; DRIDestroyInfoRec(pI810->pDRIInfo); @@ -337,10 +320,31 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) return FALSE; } + /* Check the i810 DRM version */ + { + drmVersionPtr version = drmGetVersion(pI810->drmSubFD); + if (version) { + if (version->version_major != 1 || + version->version_minor != 0 || + version->version_patchlevel < 0) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, + "I810DRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + version->version_major, + version->version_minor, + version->version_patchlevel); + I810DRICloseScreen(pScreen); + drmFreeVersion(version); + return FALSE; + } + drmFreeVersion(version); + } + } + pI810DRI->regsSize=I810_REG_SIZE; if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->MMIOAddr, pI810DRI->regsSize, DRM_REGISTERS, 0, &pI810DRI->regs)<0) { - ErrorF("drmAddMap(regs) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(regs) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -357,14 +361,14 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) /* Agp Support - Need this just to get the framebuffer. */ if(drmAgpAcquire(pI810->drmSubFD) < 0) { - ErrorF("drmAgpAquire failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpAquire failed\n"); DRICloseScreen(pScreen); return FALSE; } pI810->agpAcquired = TRUE; if (drmAgpEnable(pI810->drmSubFD, 0) < 0) { - ErrorF("drmAgpEnable failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpEnable failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -378,9 +382,9 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) * under the DRI. */ - dcacheHandle = drmAgpAlloc(pI810->drmSubFD, 4096 * 1024, 1, NULL); + drmAgpAlloc(pI810->drmSubFD, 4096 * 1024, 1, NULL, &dcacheHandle); pI810->dcacheHandle = dcacheHandle; - + xf86DrvMsg(pScreen->myNum, X_INFO, "dcacheHandle : %p\n", dcacheHandle); #define Elements(x) sizeof(x)/sizeof(*x) for (pitch_idx = 0 ; pitch_idx < Elements(i810_pitches) ; pitch_idx++) @@ -394,31 +398,37 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) return FALSE; } else { - back_size = i810_pitches[pitch_idx] * pScrn->virtualY; + back_size = i810_pitches[pitch_idx] * (pScrn->virtualY + 4); back_size = ((back_size + 4096 - 1) / 4096) * 4096; } sysmem_size = pScrn->videoRam * 1024; - if(dcacheHandle != 0) { - if(back_size > 4*1024*1024) { - ErrorF("Backsize is larger then 4 meg\n"); + if (dcacheHandle != 0) { + if (back_size > 4*1024*1024) { + xf86DrvMsg(pScreen->myNum, X_INFO, "Backsize is larger then 4 meg\n"); sysmem_size = sysmem_size - 2*back_size; drmAgpFree(pI810->drmSubFD, dcacheHandle); pI810->dcacheHandle = dcacheHandle = 0; - } else { + } + else { sysmem_size = sysmem_size - back_size; } - } else { + } + else { sysmem_size = sysmem_size - 2*back_size; } - - sysmem_size -= 4096; - if(sysmem_size > ((48*1024*1024) - 1) ) { - sysmem_size = (48*1024*1024) - (2*4096); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "User requested more memory then fits in the agp aperture\n" + + if(sysmem_size > 48*1024*1024) { + sysmem_size = 48*1024*1024; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "User requested more memory then fits in the agp aperture\n" "Truncating to %d bytes of memory\n", sysmem_size); } + + sysmem_size -= 4096; /* remove 4k for the hw cursor */ + pI810->SysMem.Start = 0; pI810->SysMem.Size = sysmem_size; pI810->SysMem.End = sysmem_size; @@ -428,7 +438,6 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (dcacheHandle != 0) { /* The Z buffer is always aligned to the 48 mb mark in the aperture */ - if(drmAgpBind(pI810->drmSubFD, dcacheHandle, 48*1024*1024) == 0) { xf86memset (&pI810->DcacheMem, 0, sizeof(I810MemRange)); xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -454,10 +463,10 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: no dcache memory found\n"); } - agpHandle = drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL); + drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL, &agpHandle); pI810->backHandle = agpHandle; - if(agpHandle != 0) { + if (agpHandle != 0) { /* The backbuffer is always aligned to the 56 mb mark in the aperture */ if(drmAgpBind(pI810->drmSubFD, agpHandle, 56*1024*1024) == 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, @@ -481,8 +490,8 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if(dcacheHandle == 0) { /* The Z buffer is always aligned to the 48 mb mark in the aperture */ - agpHandle = drmAgpAlloc(pI810->drmSubFD, back_size, 0, - NULL); + drmAgpAlloc(pI810->drmSubFD, back_size, 0, + NULL, &agpHandle); pI810->zHandle = agpHandle; if(agpHandle != 0) { @@ -509,43 +518,43 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) /* Now allocate and bind the agp space. This memory will include the * regular framebuffer as well as texture memory. */ - - agpHandle = drmAgpAlloc(pI810->drmSubFD, sysmem_size, 0, NULL); - if(agpHandle == 0) { - ErrorF("drmAgpAlloc failed\n"); + drmAgpAlloc(pI810->drmSubFD, sysmem_size, 0, NULL, &agpHandle); + if (agpHandle == 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpAlloc failed\n"); DRICloseScreen(pScreen); return FALSE; } pI810->sysmemHandle = agpHandle; - if(drmAgpBind(pI810->drmSubFD, agpHandle, 0) != 0) { - ErrorF("drmAgpBind failed\n"); + if (drmAgpBind(pI810->drmSubFD, agpHandle, 0) != 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpBind failed\n"); DRICloseScreen(pScreen); return FALSE; } - agpHandle = drmAgpAlloc(pI810->drmSubFD, 4096, 2, - (unsigned long *)&pI810->CursorPhysical); + drmAgpAlloc(pI810->drmSubFD, 4096, 2, + (unsigned long *)&pI810->CursorPhysical, &agpHandle); pI810->cursorHandle = agpHandle; if (agpHandle != 0) { tom = sysmem_size; - if(drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) { + if (drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: Allocated 4K for mouse cursor image\n"); pI810->CursorStart = tom; tom += 4096; - } else { + } + else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: cursor bind failed\n"); pI810->CursorPhysical = 0; } - } else { + } + else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: cursor alloc failed\n"); pI810->CursorPhysical = 0; } - I810SetTiledMemory(pScrn, 1, pI810->DepthBuffer.Start, i810_pitches[pitch_idx], @@ -558,14 +567,13 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pI810->auxPitch = i810_pitches[pitch_idx]; pI810->auxPitchBits = i810_pitch_flags[pitch_idx]; - pI810->SavedDcacheMem = pI810->DcacheMem; - pI810DRI->backbufferSize = pI810->BackBuffer.Size; + if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BackBuffer.Start, pI810->BackBuffer.Size, DRM_AGP, 0, &pI810DRI->backbuffer) < 0) { - ErrorF("drmAddMap(backbuffer) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(backbuffer) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -574,7 +582,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->DepthBuffer.Start, pI810->DepthBuffer.Size, DRM_AGP, 0, &pI810DRI->depthbuffer) < 0) { - ErrorF("drmAddMap(depthbuffer) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(depthbuffer) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -586,10 +594,21 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) I810AllocHigh( &(pI810->BufferMem), &(pI810->SysMem), I810_DMA_BUF_NR * I810_DMA_BUF_SZ); - if(drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BufferMem.Start, + xf86DrvMsg(pScreen->myNum, X_INFO, "Buffer map : %lx\n", + pI810->BufferMem.Start); + + if (pI810->BufferMem.Start == 0 || + pI810->BufferMem.End - pI810->BufferMem.Start > + I810_DMA_BUF_NR * I810_DMA_BUF_SZ) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "Not enough memory for dma buffers\n"); + DRICloseScreen(pScreen); + return FALSE; + } + if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BufferMem.Start, pI810->BufferMem.Size, DRM_AGP, 0, &pI810->buffer_map) < 0) { - ErrorF("drmAddMap(buffer_map) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(buffer_map) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -600,7 +619,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->LpRing.mem.Start, pI810->LpRing.mem.Size, DRM_AGP, 0, &pI810->ring_map) < 0) { - ErrorF("drmAddMap(ring_map) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(ring_map) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -608,7 +627,6 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) /* Use the rest of memory for textures. */ pI810DRI->textureSize = pI810->SysMem.Size; - i = mylog2(pI810DRI->textureSize / I810_NR_TEX_REGIONS); if (i < I810_LOG_MIN_TEX_REGION_SIZE) @@ -617,20 +635,19 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pI810DRI->logTextureGranularity = i; pI810DRI->textureSize = (pI810DRI->textureSize >> i) << i; /* truncate */ - if(pI810DRI->textureSize < 512*1024) { ErrorF("Less then 512k for textures\n"); DRICloseScreen(pScreen); + return FALSE; } I810AllocLow( &(pI810->TexMem), &(pI810->SysMem), pI810DRI->textureSize); - if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->TexMem.Start, pI810->TexMem.Size, DRM_AGP, 0, &pI810DRI->textures) < 0) { - ErrorF("drmAddMap(textures) failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(textures) failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -650,7 +667,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] added %d %d byte DMA buffers\n", bufs, I810_DMA_BUF_SZ); - I810drmInitDma(pScrn); + I810InitDma(pScrn); /* Okay now initialize the dma engine */ @@ -701,7 +718,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen) pI810DRI->auxPitchBits = pI810->auxPitchBits; if (!(I810InitVisualConfigs(pScreen))) { - ErrorF("I810InitVisualConfigs failed\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "I810InitVisualConfigs failed\n"); DRICloseScreen(pScreen); return FALSE; } @@ -718,7 +735,7 @@ I810DRICloseScreen(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; I810Ptr pI810 = I810PTR(pScrn); - I810drmCleanupDma(pScrn); + I810CleanupDma(pScrn); if(pI810->dcacheHandle) drmAgpFree(pI810->drmSubFD, pI810->dcacheHandle); if(pI810->backHandle) drmAgpFree(pI810->drmSubFD, pI810->backHandle); @@ -768,7 +785,7 @@ I810DestroyContext(ScreenPtr pScreen, drmContext hwContext, Bool I810DRIFinishScreenInit(ScreenPtr pScreen) { - drm_i810_sarea_t *sPriv = (drm_i810_sarea_t *)DRIGetSAREAPrivate(pScreen); + I810SAREARec *sPriv = (I810SAREARec *)DRIGetSAREAPrivate(pScreen); xf86memset( sPriv, 0, sizeof(sPriv) ); return DRIFinishScreenInit(pScreen); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c index e489d17c9..6d4c8aafb 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c @@ -95,15 +95,8 @@ static void I810DisplayPowerManagementSet(ScrnInfoPtr pScrn, int flags); #endif -#define VERSION 4000 -#define I810_NAME "I810" -#define I810_DRIVER_NAME "i810" -#define I810_MAJOR_VERSION 1 -#define I810_MINOR_VERSION 0 -#define I810_PATCHLEVEL 0 - DriverRec I810 = { - VERSION, + I810_VERSION, "Accelerated driver for Intel i810 cards", I810Identify, I810Probe, @@ -207,31 +200,19 @@ static const char *ramdacSymbols[] = { #ifdef XF86DRI static const char *drmSymbols[] = { + "drmAvailable", "drmAddBufs", "drmAddMap", - "drmAvailable", - "drmCtlAddCommand", "drmCtlInstHandler", "drmGetInterruptFromBusID", - "drmMapBufs", - "drmMarkBufs", - "drmUnmapBufs", "drmAgpAcquire", "drmAgpRelease", "drmAgpEnable", "drmAgpAlloc", "drmAgpFree", "drmAgpBind", - "drmAgpUnbind", - "drmAgpVersionMajor", - "drmAgpVersionMinor", - "drmAgpGetMode", - "drmAgpBase", - "drmAgpSize", - "drmAgpMemoryUsed", - "drmAgpMemoryAvail", - "drmAgpVendorId", - "drmAgpDeviceId", + "drmI810CleanupDma", + "drmI810InitDma", NULL }; @@ -419,7 +400,7 @@ I810Probe(DriverPtr drv, int flags) { /* Allocate new ScrnInfoRec and claim the slot */ pScrn = xf86AllocateScreen(drv, 0); - pScrn->driverVersion = VERSION; + pScrn->driverVersion = I810_VERSION; pScrn->driverName = I810_DRIVER_NAME; pScrn->name = I810_NAME; pScrn->Probe = I810Probe; @@ -1047,7 +1028,6 @@ DoRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, I810RegPtr i810Reg, pI810 = I810PTR(pScrn); hwp = VGAHWPTR(pScrn); - if (I810_DEBUG&DEBUG_VERBOSE_VGA) { ErrorF("Setting mode in I810Restore:\n"); i810PrintMode( vgaReg, i810Reg ); @@ -1113,7 +1093,7 @@ DoRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, I810RegPtr i810Reg, temp &= ~INTERLACE_ENABLE; temp |= i810Reg->InterlaceControl; hwp->writeCrtc(hwp, INTERLACE_CNTL, temp); - + temp=pI810->readControl(pI810, GRX, ADDRESS_MAPPING); temp &= 0xE0; /* Save reserved bits 7:5 */ temp |= i810Reg->AddressMapping; @@ -1553,7 +1533,6 @@ I810AllocateFront(ScrnInfoPtr pScrn) { xf86memset( &(pI810->LpRing), 0, sizeof( I810RingBuffer ) ); if(I810AllocLow( &(pI810->LpRing.mem), &(pI810->SysMem), 16*4096 )) { - if (I810_DEBUG & DEBUG_VERBOSE_MEMORY) ErrorF( "ring buffer at local %lx\n", pI810->LpRing.mem.Start); @@ -1607,6 +1586,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { /* Have to init the DRM earlier than in other drivers to get agp * memory. Wonder if this is going to be a problem... */ + #ifdef XF86DRI /* * Setup DRI after visuals have been established, but before cfbScreenInit @@ -1625,7 +1605,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { return FALSE; I810AllocateFront(pScrn); #endif - + if (!I810MapMem(pScrn)) return FALSE; pScrn->memPhysBase = (int)pI810->FbBase; @@ -1729,6 +1709,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { } } #endif + #ifdef XF86DRI if (!pI810->directRenderingEnabled) { pI810->DoneFrontAlloc = FALSE; @@ -1738,6 +1719,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { } #endif + if (!xf86InitFBManager(pScreen, &(pI810->FbMemBox))) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to init memory manager\n"); @@ -1762,7 +1744,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { } } -#if XF86DRI +#ifdef XF86DRI if (pI810->LpRing.mem.Start == 0) { pI810->directRenderingEnabled = 0; I810DRICloseScreen(pScreen); @@ -1892,9 +1874,10 @@ I810LeaveVT(int scrnIndex, int flags) { pI810->LockHeld = 1; } #endif - - I810RefreshRing( pScrn ); - I810Sync( pScrn ); + if(pI810->AccelInfoRec != NULL) { + I810RefreshRing( pScrn ); + I810Sync( pScrn ); + } I810Restore(pScrn); vgaHWLock(hwp); } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h index 2027171da..931e4a19d 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h @@ -14,9 +14,6 @@ #ifndef MGA_H #define MGA_H -/* Temporarily turn off building in DRI support */ -#undef XF86DRI - #include "compiler.h" #include "xaa.h" #include "xf86Cursor.h" @@ -33,9 +30,15 @@ #include "dri.h" #include "GL/glxint.h" #include "mga_dri.h" -#include "mga_dripriv.h" #endif +#define MGA_VERSION 4000 +#define MGA_NAME "MGA" +#define MGA_DRIVER_NAME "mga" +#define MGA_MAJOR_VERSION 1 +#define MGA_MINOR_VERSION 0 +#define MGA_PATCHLEVEL 0 + #if !defined(EXTRADEBUG) #define INREG8(addr) MMIO_IN8(pMga->IOBase, addr) #define INREG16(addr) MMIO_IN16(pMga->IOBase, addr) @@ -69,6 +72,7 @@ typedef struct { CARD32 Option3; } MGARegRec, *MGARegPtr; + typedef struct { Bool isHwCursor; int CursorMaxWidth; @@ -216,11 +220,20 @@ typedef struct { MGAConfigPrivPtr pVisualConfigsPriv; MGARegRec DRContextRegs; MGADRIServerPrivatePtr DRIServerInfo; + Bool have_quiescense; #endif XF86VideoAdaptorPtr adaptor; } MGARec, *MGAPtr; +#ifdef XF86DRI +extern void GlxSetVisualConfigs( + int nconfigs, + __GLXvisualConfig *configs, + void **configprivs +); +#endif + extern CARD32 MGAAtype[16]; extern CARD32 MGAAtypeNoBLK[16]; @@ -240,9 +253,9 @@ extern CARD32 MGAAtypeNoBLK[16]; #define TRANSPARENCY_KEY 255 #define KEY_COLOR 0 -#define MGA_FRONT 0 -#define MGA_BACK 1 -#define MGA_DEPTH 2 +#define MGA_FRONT 0x1 +#define MGA_BACK 0x2 +#define MGA_DEPTH 0x4 /* Prototypes */ @@ -271,13 +284,13 @@ Bool MGADRIScreenInit(ScreenPtr pScreen); void MGADRICloseScreen(ScreenPtr pScreen); Bool MGADRIFinishScreenInit(ScreenPtr pScreen); void MGASwapContext(ScreenPtr pScreen); -void MGALostContext(ScreenPtr pScreen); -void MGASelectBuffer(MGAPtr pMGA, int which); +void MGASelectBuffer(ScrnInfoPtr pScrn, int which); Bool mgaConfigureWarp(ScrnInfoPtr pScrn); unsigned int mgaInstallMicrocode(ScreenPtr pScreen, int agp_offset); unsigned int mgaGetMicrocodeSize(ScreenPtr pScreen); -Bool mgadrmCleanupDma(ScrnInfoPtr pScrn); -Bool mgadrmInitDma(ScrnInfoPtr pScrn, int prim_size); +Bool MgaCleanupDma(ScrnInfoPtr pScrn); +Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size); +Bool MgaLockUpdate(ScrnInfoPtr pScrn, drmLockFlags flags); void MGARefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); void MGARefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c index df23db4f6..7f91b6630 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c @@ -22,7 +22,7 @@ #include "mga.h" #include "mga_macros.h" #include "mga_dri.h" -#include "mga_dripriv.h" +#include "mga_wrap.h" static char MGAKernelDriverName[] = "mga"; static char MGAClientDriverName[] = "mga"; @@ -51,250 +51,307 @@ extern void Mga32DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index); extern void Mga32DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 index); +Bool MgaCleanupDma(ScrnInfoPtr pScrn) +{ + MGAPtr pMGA = MGAPTR(pScrn); + Bool ret_val; + + ret_val = drmMgaCleanupDma(pMGA->drmSubFD); + if (ret_val == FALSE) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Mga Dma Cleanup Failed\n"); + + return ret_val; +} + +Bool MgaLockUpdate(ScrnInfoPtr pScrn, drmLockFlags flags) +{ + MGAPtr pMGA = MGAPTR(pScrn); + Bool ret_val; + + ret_val = drmMgaLockUpdate(pMGA->drmSubFD, flags); + if (ret_val == FALSE) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "LockUpdate failed\n"); + + return ret_val; +} + +Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size) +{ + MGAPtr pMGA = MGAPTR(pScrn); + MGADRIPtr pMGADRI = (MGADRIPtr)pMGA->pDRIInfo->devPrivate; + MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; + drmMgaInit init; + Bool ret_val; + + memset(&init, 0, sizeof(drmMgaInit)); + init.reserved_map_agpstart = 0; + init.reserved_map_idx = 3; + init.buffer_map_idx = 4; + init.sarea_priv_offset = sizeof(XF86DRISAREARec); + init.primary_size = prim_size; + init.warp_ucode_size = pMGADRIServer->warp_ucode_size; + + switch(pMGA->Chipset) { + case PCI_CHIP_MGAG400: + init.chipset = MGA_CARD_TYPE_G400; + break; + case PCI_CHIP_MGAG200: + init.chipset = MGA_CARD_TYPE_G200; + break; + case PCI_CHIP_MGAG200_PCI: + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] Direct rendering not supported on this card/chipset\n"); + return FALSE; + } + + init.frontOffset = pMGADRI->frontOffset; + init.backOffset = pMGADRI->backOffset; + init.depthOffset = pMGADRI->depthOffset; + init.textureOffset = pMGADRI->textureOffset; + init.textureSize = pMGADRI->textureSize; + init.agpTextureSize = pMGADRI->agpTextureSize; + init.cpp = pMGADRI->cpp; + init.stride = pMGADRI->frontPitch; + init.mAccess = pMGA->MAccess; + init.sgram = !pMGA->HasSDRAM; + + memcpy(&init.WarpIndex, &pMGADRIServer->WarpIndex, + sizeof(drmMgaWarpIndex) * MGA_MAX_WARP_PIPES); + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Mga Dma Initialization start\n"); + + ret_val = drmMgaInitDma(pMGA->drmSubFD, &init); + if (ret_val == FALSE) + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] Mga Dma Initialization Failed\n"); + else + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Mga Dma Initialization done\n"); + return ret_val; +} + static Bool MGAInitVisualConfigs(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - MGAPtr pMGA = MGAPTR(pScrn); - int numConfigs = 0; - __GLXvisualConfig *pConfigs = 0; - MGAConfigPrivPtr pMGAConfigs = 0; - MGAConfigPrivPtr *pMGAConfigPtrs = 0; - int i; - - switch (pScrn->bitsPerPixel) { - case 8: - case 24: - case 32: - break; - case 16: - numConfigs = 4; - - if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), - numConfigs))) { - return FALSE; - } - if (!(pMGAConfigs = (MGAConfigPrivPtr)xnfcalloc(sizeof(MGAConfigPrivRec), + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMGA = MGAPTR(pScrn); + int numConfigs = 0; + __GLXvisualConfig *pConfigs = 0; + MGAConfigPrivPtr pMGAConfigs = 0; + MGAConfigPrivPtr *pMGAConfigPtrs = 0; + int i, db, depth, stencil, accum; + + switch (pScrn->bitsPerPixel) { + case 8: + case 24: + case 32: + break; + case 16: + numConfigs = 4; + + if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), numConfigs))) { - xfree(pConfigs); - return FALSE; - } - if (!(pMGAConfigPtrs = (MGAConfigPrivPtr*)xnfcalloc(sizeof(MGAConfigPrivPtr), - numConfigs))) { - xfree(pConfigs); - xfree(pMGAConfigs); - return FALSE; - } - for (i=0; i<numConfigs; i++) - pMGAConfigPtrs[i] = &pMGAConfigs[i]; + return FALSE; + } + if (!(pMGAConfigs = (MGAConfigPrivPtr)xnfcalloc(sizeof(MGAConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pMGAConfigPtrs = (MGAConfigPrivPtr*)xnfcalloc(sizeof(MGAConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pMGAConfigs); + return FALSE; + } + for (i=0; i<numConfigs; i++) + pMGAConfigPtrs[i] = &pMGAConfigs[i]; + + i = 0; + depth = 1; + for (accum = 0; accum <= 1; accum++) { + for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */ + for (db=0; db<=1; db++) { + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + pConfigs[i].alphaMask = 0; + if (accum) { + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 0; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + if (db) + pConfigs[i].doubleBuffer = TRUE; + else + pConfigs[i].doubleBuffer = FALSE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 16; + if (depth) + pConfigs[i].depthSize = 16; + else + pConfigs[i].depthSize = 0; + if (stencil) + pConfigs[i].stencilSize = 8; + else + pConfigs[i].stencilSize = 0; + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (stencil) + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + else + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + } + if (i != numConfigs) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] Incorrect initialization of visuals\n"); + return FALSE; + } + break; + default: + ; /* unexpected bits/pixelx */ + } + pMGA->numVisualConfigs = numConfigs; + pMGA->pVisualConfigs = pConfigs; + pMGA->pVisualConfigsPriv = pMGAConfigs; + GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pMGAConfigPtrs); + return TRUE; +} - /* config 0: db=FALSE, depth=0 - config 1: db=FALSE, depth=16 - config 2: db=TRUE, depth=0; - config 3: db=TRUE, depth=16 - */ - pConfigs[0].vid = -1; - pConfigs[0].class = -1; - pConfigs[0].rgba = TRUE; - pConfigs[0].redSize = 8; - pConfigs[0].greenSize = 8; - pConfigs[0].blueSize = 8; - pConfigs[0].redMask = 0x00FF0000; - pConfigs[0].greenMask = 0x0000FF00; - pConfigs[0].blueMask = 0x000000FF; - pConfigs[0].alphaMask = 0; - pConfigs[0].accumRedSize = 0; - pConfigs[0].accumGreenSize = 0; - pConfigs[0].accumBlueSize = 0; - pConfigs[0].accumAlphaSize = 0; - pConfigs[0].doubleBuffer = FALSE; - pConfigs[0].stereo = FALSE; - pConfigs[0].bufferSize = 16; - pConfigs[0].depthSize = 0; - pConfigs[0].stencilSize = 0; - pConfigs[0].auxBuffers = 0; - pConfigs[0].level = 0; - pConfigs[0].visualRating = 0; - pConfigs[0].transparentPixel = 0; - pConfigs[0].transparentRed = 0; - pConfigs[0].transparentGreen = 0; - pConfigs[0].transparentBlue = 0; - pConfigs[0].transparentAlpha = 0; - pConfigs[0].transparentIndex = 0; - - pConfigs[1].vid = -1; - pConfigs[1].class = -1; - pConfigs[1].rgba = TRUE; - pConfigs[1].redSize = 8; - pConfigs[1].greenSize = 8; - pConfigs[1].blueSize = 8; - pConfigs[1].redMask = 0x00FF0000; - pConfigs[1].greenMask = 0x0000FF00; - pConfigs[1].blueMask = 0x000000FF; - pConfigs[1].alphaMask = 0; - pConfigs[1].accumRedSize = 0; - pConfigs[1].accumGreenSize = 0; - pConfigs[1].accumBlueSize = 0; - pConfigs[1].accumAlphaSize = 0; - pConfigs[1].doubleBuffer = FALSE; - pConfigs[1].stereo = FALSE; - pConfigs[1].bufferSize = 16; - pConfigs[1].depthSize = 16; - pConfigs[1].stencilSize = 0; - pConfigs[1].auxBuffers = 0; - pConfigs[1].level = 0; - pConfigs[1].visualRating = 0; - pConfigs[1].transparentPixel = 0; - pConfigs[1].transparentRed = 0; - pConfigs[1].transparentGreen = 0; - pConfigs[1].transparentBlue = 0; - pConfigs[1].transparentAlpha = 0; - pConfigs[1].transparentIndex = 0; - - pConfigs[2].vid = -1; - pConfigs[2].class = -1; - pConfigs[2].rgba = TRUE; - pConfigs[2].redSize = 8; - pConfigs[2].greenSize = 8; - pConfigs[2].blueSize = 8; - pConfigs[2].redMask = 0x00FF0000; - pConfigs[2].greenMask = 0x0000FF00; - pConfigs[2].blueMask = 0x000000FF; - pConfigs[2].alphaMask = 0; - pConfigs[2].accumRedSize = 0; - pConfigs[2].accumGreenSize = 0; - pConfigs[2].accumBlueSize = 0; - pConfigs[2].accumAlphaSize = 0; - pConfigs[2].doubleBuffer = TRUE; - pConfigs[2].stereo = FALSE; - pConfigs[2].bufferSize = 16; - pConfigs[2].depthSize = 0; - pConfigs[2].stencilSize = 0; - pConfigs[2].auxBuffers = 0; - pConfigs[2].level = 0; - pConfigs[2].visualRating = 0; - pConfigs[2].transparentPixel = 0; - pConfigs[2].transparentRed = 0; - pConfigs[2].transparentGreen = 0; - pConfigs[2].transparentBlue = 0; - pConfigs[2].transparentAlpha = 0; - pConfigs[2].transparentIndex = 0; - - pConfigs[3].vid = -1; - pConfigs[3].class = -1; - pConfigs[3].rgba = TRUE; - pConfigs[3].redSize = 8; - pConfigs[3].greenSize = 8; - pConfigs[3].blueSize = 8; - pConfigs[3].redMask = 0x00FF0000; - pConfigs[3].greenMask = 0x0000FF00; - pConfigs[3].blueMask = 0x000000FF; - pConfigs[3].alphaMask = 0; - pConfigs[3].accumRedSize = 0; - pConfigs[3].accumGreenSize = 0; - pConfigs[3].accumBlueSize = 0; - pConfigs[3].accumAlphaSize = 0; - pConfigs[3].doubleBuffer = TRUE; - pConfigs[3].stereo = FALSE; - pConfigs[3].bufferSize = 16; - pConfigs[3].depthSize = 16; - pConfigs[3].stencilSize = 0; - pConfigs[3].auxBuffers = 0; - pConfigs[3].level = 0; - pConfigs[3].visualRating = 0; - pConfigs[3].transparentPixel = 0; - pConfigs[3].transparentRed = 0; - pConfigs[3].transparentGreen = 0; - pConfigs[3].transparentBlue = 0; - pConfigs[3].transparentAlpha = 0; - pConfigs[3].transparentIndex = 0; - break; - } - pMGA->numVisualConfigs = numConfigs; - pMGA->pVisualConfigs = pConfigs; - pMGA->pVisualConfigsPriv = pMGAConfigs; - GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pMGAConfigPtrs); - return TRUE; +static unsigned int mylog2(unsigned int n) +{ + unsigned int log2 = 1; + while (n>1) n >>= 1, log2++; + return log2; } + Bool MGADRIScreenInit(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - MGAPtr pMGA = MGAPTR(pScrn); - DRIInfoPtr pDRIInfo; - MGADRIPtr pMGADRI; - MGADRIServerPrivatePtr pMGADRIServer; - int bufs; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMGA = MGAPTR(pScrn); + DRIInfoPtr pDRIInfo; + MGADRIPtr pMGADRI; + MGADRIServerPrivatePtr pMGADRIServer; + int bufs, size; int prim_size; int init_offset; + int i; + +#if XFree86LOADER + /* Check that the GLX, DRI, and DRM modules have been loaded by testing + * for canonical symbols in each module. */ + if (!LoaderSymbol("GlxSetVisualConfigs")) return FALSE; + if (!LoaderSymbol("DRIScreenInit")) return FALSE; + if (!LoaderSymbol("drmAvailable")) return FALSE; +#endif + + /* Check the DRI version */ + { + int major, minor, patch; + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] MGADRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + } - pDRIInfo = DRICreateInfoRec(); - if (!pDRIInfo) return FALSE; - pMGA->pDRIInfo = pDRIInfo; - - pDRIInfo->drmDriverName = MGAKernelDriverName; - pDRIInfo->clientDriverName = MGAClientDriverName; - pDRIInfo->busIdString = xalloc(64); - sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", - ((pciConfigPtr)pMGA->PciInfo->thisCard)->busnum, - ((pciConfigPtr)pMGA->PciInfo->thisCard)->devnum, - ((pciConfigPtr)pMGA->PciInfo->thisCard)->funcnum); - pDRIInfo->ddxDriverMajorVersion = 0; - pDRIInfo->ddxDriverMinorVersion = 1; - pDRIInfo->ddxDriverPatchVersion = 0; - pDRIInfo->frameBufferPhysicalAddress = pMGA->FbAddress; - pDRIInfo->frameBufferSize = pMGA->FbMapSize; - pDRIInfo->frameBufferStride = pScrn->displayWidth*(pScrn->bitsPerPixel/8); - pDRIInfo->ddxDrawableTableEntry = MGA_MAX_DRAWABLES; - - if (SAREA_MAX_DRAWABLES < MGA_MAX_DRAWABLES) - pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES; - else - pDRIInfo->maxDrawableTableEntry = MGA_MAX_DRAWABLES; - -#ifdef NOT_DONE - /* FIXME need to extend DRI protocol to pass this size back to client - * for SAREA mapping that includes a device private record - */ - pDRIInfo->SAREASize = - ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */ - /* + shared memory device private rec */ -#else - /* For now the mapping works by using a fixed size defined - * in the SAREA header - */ - if (sizeof(XF86DRISAREARec)+sizeof(drm_mga_sarea_t)>SAREA_MAX) { - ErrorF("Data does not fit in SAREA\n"); - return FALSE; - } - pDRIInfo->SAREASize = SAREA_MAX; -#endif + if ((pScrn->bitsPerPixel / 8) != 2) { + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Direct Rendering only supported in 16 bpp mode\n"); + return FALSE; + } + + pDRIInfo = DRICreateInfoRec(); + if (!pDRIInfo) + return FALSE; + pMGA->pDRIInfo = pDRIInfo; + + pDRIInfo->drmDriverName = MGAKernelDriverName; + pDRIInfo->clientDriverName = MGAClientDriverName; + pDRIInfo->busIdString = xalloc(64); + sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d", + ((pciConfigPtr)pMGA->PciInfo->thisCard)->busnum, + ((pciConfigPtr)pMGA->PciInfo->thisCard)->devnum, + ((pciConfigPtr)pMGA->PciInfo->thisCard)->funcnum); + pDRIInfo->ddxDriverMajorVersion = MGA_MAJOR_VERSION; + pDRIInfo->ddxDriverMinorVersion = MGA_MINOR_VERSION; + pDRIInfo->ddxDriverPatchVersion = MGA_PATCHLEVEL; + pDRIInfo->frameBufferPhysicalAddress = pMGA->FbAddress; + pDRIInfo->frameBufferSize = pMGA->FbMapSize; + pDRIInfo->frameBufferStride = pScrn->displayWidth*(pScrn->bitsPerPixel/8); + pDRIInfo->ddxDrawableTableEntry = MGA_MAX_DRAWABLES; + + MGADRIWrapFunctions( pScreen, pDRIInfo ); + + if (SAREA_MAX_DRAWABLES < MGA_MAX_DRAWABLES) + pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES; + else + pDRIInfo->maxDrawableTableEntry = MGA_MAX_DRAWABLES; + + /* For now the mapping works by using a fixed size defined + * in the SAREA header + */ + if (sizeof(XF86DRISAREARec)+sizeof(MGASAREARec)>SAREA_MAX) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] Data does not fit in SAREA\n"); + return FALSE; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Sarea %d+%d: %d\n", + sizeof(XF86DRISAREARec), sizeof(MGASAREARec), + sizeof(XF86DRISAREARec) + sizeof(MGASAREARec)); - if (!(pMGADRI = (MGADRIPtr)xnfcalloc(sizeof(MGADRIRec),1))) { - DRIDestroyInfoRec(pMGA->pDRIInfo); - pMGA->pDRIInfo=0; - ErrorF("Failed to allocate memory for private record \n"); - return FALSE; - } + pDRIInfo->SAREASize = SAREA_MAX; + + if (!(pMGADRI = (MGADRIPtr)xnfcalloc(sizeof(MGADRIRec),1))) { + DRIDestroyInfoRec(pMGA->pDRIInfo); + pMGA->pDRIInfo=0; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] Failed to allocate memory for private record\n"); + return FALSE; + } if (!(pMGADRIServer = (MGADRIServerPrivatePtr) - xnfcalloc(sizeof(MGADRIServerPrivate),1))) { - xfree(pMGADRI); - DRIDestroyInfoRec(pMGA->pDRIInfo); - pMGA->pDRIInfo=0; - ErrorF("Failed to allocate memory for private record \n"); - return FALSE; - } + xnfcalloc(sizeof(MGADRIServerPrivateRec),1))) { + xfree(pMGADRI); + DRIDestroyInfoRec(pMGA->pDRIInfo); + pMGA->pDRIInfo=0; + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[drm] Failed to allocate memory for private record\n"); + return FALSE; + } - pDRIInfo->devPrivate = pMGADRI; - pMGA->DRIServerInfo = pMGADRIServer; - pDRIInfo->devPrivateSize = sizeof(MGADRIRec); - pDRIInfo->contextSize = sizeof(MGADRIContextRec); + pDRIInfo->devPrivate = pMGADRI; + pMGA->DRIServerInfo = pMGADRIServer; + pDRIInfo->devPrivateSize = sizeof(MGADRIRec); + pDRIInfo->contextSize = sizeof(MGADRIContextRec); - pDRIInfo->CreateContext = MGACreateContext; - pDRIInfo->DestroyContext = MGADestroyContext; - pDRIInfo->SwapContext = MGADRISwapContext; + pDRIInfo->CreateContext = MGACreateContext; + pDRIInfo->DestroyContext = MGADestroyContext; + pDRIInfo->SwapContext = MGADRISwapContext; - switch( pScrn->bitsPerPixel ) { + switch( pScrn->bitsPerPixel ) { case 8: pDRIInfo->InitBuffers = Mga8DRIInitBuffers; pDRIInfo->MoveBuffers = Mga8DRIMoveBuffers; @@ -307,172 +364,270 @@ Bool MGADRIScreenInit(ScreenPtr pScreen) case 32: pDRIInfo->InitBuffers = Mga32DRIInitBuffers; pDRIInfo->MoveBuffers = Mga32DRIMoveBuffers; - } + } - pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; + pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; + + if (!DRIScreenInit(pScreen, pDRIInfo, &pMGA->drmSubFD)) { + xfree(pMGADRIServer); + pMGA->DRIServerInfo = 0; + xfree(pDRIInfo->devPrivate); + pDRIInfo->devPrivate = 0; + DRIDestroyInfoRec(pMGA->pDRIInfo); + pMGA->pDRIInfo = 0; + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] DRIScreenInit Failed\n"); + return FALSE; + } - if (!DRIScreenInit(pScreen, pDRIInfo, &pMGA->drmSubFD)) { - xfree(pMGADRIServer); - pMGA->DRIServerInfo = 0; - xfree(pDRIInfo->devPrivate); - pDRIInfo->devPrivate = 0; - DRIDestroyInfoRec(pMGA->pDRIInfo); - pMGA->pDRIInfo = 0; - ErrorF("DRIScreenInit Failed\n"); - return FALSE; - } + /* Check the MGA DRM version */ + { + drmVersionPtr version = drmGetVersion(pMGA->drmSubFD); + if (version) { + if (version->version_major != 1 || + version->version_minor != 0 || + version->version_patchlevel < 0) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + version->version_major, + version->version_minor, + version->version_patchlevel); + MGADRICloseScreen(pScreen); + drmFreeVersion(version); + return FALSE; + } + drmFreeVersion(version); + } + } - pMGADRIServer->regsSize = MGAIOMAPSIZE; - if (drmAddMap(pMGA->drmSubFD, (drmHandle)pMGA->IOAddress, - pMGADRIServer->regsSize, DRM_REGISTERS, 0, - &pMGADRIServer->regs)<0) { - DRICloseScreen(pScreen); - ErrorF("drmAddMap failed Register MMIO region\n"); - return FALSE; - } - xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n", - pMGADRIServer->regs); + pMGADRIServer->regsSize = MGAIOMAPSIZE; + if (drmAddMap(pMGA->drmSubFD, (drmHandle)pMGA->IOAddress, + pMGADRIServer->regsSize, DRM_REGISTERS, 0, + &pMGADRIServer->regs)<0) { + DRICloseScreen(pScreen); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAddMap failed Register MMIO region\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n", + pMGADRIServer->regs); - /* Agp Support */ - if(drmAgpAcquire(pMGA->drmSubFD) < 0) { - DRICloseScreen(pScreen); - ErrorF("drmAgpAcquire failed\n"); - return FALSE; - } - pMGADRIServer->warp_ucode_size = mgaGetMicrocodeSize(pScreen); - if(pMGADRIServer->warp_ucode_size == 0) { - ErrorF("microcodeSize is zero\n"); + /* Agp Support */ + pMGADRIServer->agpAcquired = FALSE; + pMGADRIServer->agpHandle = 0; + pMGADRIServer->agpSizep = 0; + pMGADRIServer->agp_map = 0; + + if (drmAgpAcquire(pMGA->drmSubFD) < 0) { + DRICloseScreen(pScreen); + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpAcquire failed\n"); + return FALSE; + } + pMGADRIServer->agpAcquired = TRUE; + + pMGADRIServer->warp_ucode_size = mgaGetMicrocodeSize(pScreen); + if (pMGADRIServer->warp_ucode_size == 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] microcodeSize is zero\n"); + DRICloseScreen(pScreen); + return FALSE; + } + + pMGADRIServer->agpMode = drmAgpGetMode(pMGA->drmSubFD); + /* Default to 1X agp mode */ + pMGADRIServer->agpMode &= ~0x00000002; + if (drmAgpEnable(pMGA->drmSubFD, pMGADRIServer->agpMode) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n"); DRICloseScreen(pScreen); return FALSE; } + ErrorF("[drm] drmAgpEnabled succeeded\n"); - prim_size = 65536; - init_offset = ((prim_size + pMGADRIServer->warp_ucode_size + + prim_size = 65536; + init_offset = ((prim_size + pMGADRIServer->warp_ucode_size + 4096 - 1) / 4096) * 4096; - pMGADRIServer->agpSizep = drmAgpSize(pMGA->drmSubFD); - pMGADRIServer->agpBase = drmAgpBase(pMGA->drmSubFD); - if (drmAddMap(pMGA->drmSubFD, (drmHandle)pMGADRIServer->agpBase, - init_offset, DRM_AGP, 0, - &pMGADRIServer->agp_private) < 0) { - DRICloseScreen(pScreen); - ErrorF("drmAddMap failed on AGP aperture\n"); - return FALSE; - } + pMGADRIServer->agpSizep = init_offset; + pMGADRI->agpSize = (drmAgpSize(pMGA->drmSubFD)) - init_offset; + + pMGADRIServer->agpBase = (drmAddress) drmAgpBase(pMGA->drmSubFD); + if (drmAddMap(pMGA->drmSubFD, 0, + init_offset, DRM_AGP, 0, + &pMGADRIServer->agp_private) < 0) { + DRICloseScreen(pScreen); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAddMap failed on AGP aperture\n"); + return FALSE; + } - if (drmMap(pMGA->drmSubFD, (drmHandle)pMGADRIServer->agp_private, - init_offset, - (drmAddressPtr)&pMGADRIServer->agp_map) < -1) { - DRICloseScreen(pScreen); - ErrorF("drmMap failed on AGP aperture\n"); - return FALSE; - } + if (drmMap(pMGA->drmSubFD, (drmHandle)pMGADRIServer->agp_private, + init_offset, + (drmAddressPtr)&pMGADRIServer->agp_map) < -1) { + DRICloseScreen(pScreen); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmMap failed on AGP aperture\n"); + return FALSE; + } + + /* Now allocate and bind a default of 8 megs */ + drmAgpAlloc(pMGA->drmSubFD, 0x00800000, 0, 0, + &pMGADRIServer->agpHandle); + + if (pMGADRIServer->agpHandle == 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAgpAlloc failed\n"); + DRICloseScreen(pScreen); + return FALSE; + } - /* Now allocate and bind a default of 8 megs */ + if (drmAgpBind(pMGA->drmSubFD, pMGADRIServer->agpHandle, 0) < 0) { + DRICloseScreen(pScreen); + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] drmAgpBind failed\n"); + return FALSE; + } - pMGADRIServer->agpHandle = drmAgpAlloc(pMGA->drmSubFD, 0x00800000, 0, 0); - if(pMGADRIServer->agpHandle == 0) { - ErrorF("drmAgpAlloc failed\n"); - DRICloseScreen(pScreen); - return FALSE; - } - if(drmAgpBind(pMGA->drmSubFD, pMGADRIServer->agpHandle, 0) < 0) { - DRICloseScreen(pScreen); - ErrorF("drmAgpBind failed\n"); - return FALSE; - } + mgaInstallMicrocode(pScreen, prim_size); - mgaInstallMicrocode(pScreen, prim_size); + if (drmAddMap(pMGA->drmSubFD, (drmHandle)init_offset, + pMGADRI->agpSize, DRM_AGP, 0, + &pMGADRI->agp) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to map public agp area\n"); + DRICloseScreen(pScreen); + return FALSE; + } - ErrorF("init_offset: %x\n", init_offset); - pMGADRI->agpSize = pMGADRIServer->agpSizep - init_offset; - ErrorF("pMGADRI->agpSize: %x\n", pMGADRI->agpSize); - - if(drmAddMap(pMGA->drmSubFD, (drmHandle)pMGADRIServer->agpBase + init_offset, - pMGADRI->agpSize, DRM_AGP, 0, - &pMGADRI->agp) < 0) { - ErrorF("Failed to map public agp area\n"); - DRICloseScreen(pScreen); - return FALSE; - } - ErrorF("Mapped public agp area\n"); - /* Here is where we need to do initialization of the dma engine */ - - pMGADRIServer->agpMode = drmAgpGetMode(pMGA->drmSubFD); - /* Default to 1X agp mode */ - pMGADRIServer->agpMode &= ~0x00000002; - if (drmAgpEnable(pMGA->drmSubFD, pMGADRIServer->agpMode) < 0) { - ErrorF("drmAgpEnable failed\n"); - DRICloseScreen(pScreen); - return FALSE; - } - ErrorF("drmAgpEnabled succeeded\n"); - if((bufs = drmAddBufs(pMGA->drmSubFD, - /*63*/ 15, - /* 65536 */ 524288, - DRM_AGP_BUFFER, - init_offset)) <= 0) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] failure adding %d %d byte DMA buffers\n", - /* 63 */ 15, - /* 65536 */ 524288); - DRICloseScreen(pScreen); - return FALSE; - } + switch(pMGA->Chipset) { + case PCI_CHIP_MGAG400: + pMGADRI->chipset = MGA_CARD_TYPE_G400; + break; + case PCI_CHIP_MGAG200: + pMGADRI->chipset = MGA_CARD_TYPE_G200; + break; + case PCI_CHIP_MGAG200_PCI: + default: + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Direct rendering not supported on this card/chipset\n"); + return FALSE; + } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] added %d %d byte DMA buffers\n", - bufs, /* 65536 */ 524288); + pMGADRI->width = pScrn->virtualX; + pMGADRI->height = pScrn->virtualY; + pMGADRI->mem = pScrn->videoRam * 1024; + pMGADRI->cpp = pScrn->bitsPerPixel / 8; + pMGADRI->frontPitch = pScrn->displayWidth * (pScrn->bitsPerPixel / 8); - if((mgadrmInitDma(pScrn, prim_size)) != TRUE) { - ErrorF("Failed to initialize dma engine\n"); - DRICloseScreen(pScreen); - return FALSE; - } - - ErrorF("Initialized Dma Engine\n"); + pMGADRI->frontOffset = 0; /* pMGA->YDstOrg * (pScrn->bitsPerPixel / 8) */ + pMGADRI->backOffset = ((pScrn->virtualY+129) * pScrn->displayWidth * + (pScrn->bitsPerPixel / 8) + 4095) & ~0xFFF; - - if(drmMarkBufs(pMGA->drmSubFD, 0.133333, 0.266666) != 0) { + + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] calced backoffset: 0x%x\n", + pMGADRI->backOffset); + + +#if 0 + size = 2 * pScrn->virtualX * pScrn->virtualY; + pMGADRI->depthOffset = (pMGADRI->backOffset + size + 4095) & ~0xFFF; + pMGADRI->textureOffset = pMGADRI->depthOffset + size; + pMGADRI->textureSize = pMGA->FbUsableSize - pMGADRI->textureOffset; +#else + size = 2 * pScrn->virtualX * pScrn->virtualY; + size += 4095; + size &= ~4095; + pMGADRI->depthOffset = pMGA->FbUsableSize - size; + pMGADRI->depthOffset &= ~4095; + pMGADRI->textureOffset = pMGADRI->backOffset + size; + pMGADRI->textureSize = pMGADRI->depthOffset - pMGADRI->textureOffset; + + if (pMGADRI->depthOffset < pMGADRI->textureOffset + 512*1024) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Insufficient memory for direct rendering\n"); + DRICloseScreen(pScreen); + return FALSE; + } +#endif + + pMGADRI->mAccess = pMGA->MAccess; + + i = mylog2(pMGADRI->textureSize / MGA_NR_TEX_REGIONS); + if (i < MGA_LOG_MIN_TEX_REGION_SIZE) + i = MGA_LOG_MIN_TEX_REGION_SIZE; + + pMGADRI->logTextureGranularity = i; + pMGADRI->textureSize = (pMGADRI->textureSize >> i) << i; /* truncate */ + + + /* Here is where we need to do initialization of the dma engine */ + if((bufs = drmAddBufs(pMGA->drmSubFD, + MGA_DMA_BUF_NR, + MGA_DMA_BUF_SZ, + DRM_AGP_BUFFER, + init_offset)) <= 0) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] failure marking DMA buffers\n"); + "[drm] failure adding %d %d byte DMA buffers\n", + MGA_DMA_BUF_NR, + MGA_DMA_BUF_SZ); DRICloseScreen(pScreen); return FALSE; - } - if (!(pMGADRIServer->drmBufs = drmMapBufs(pMGA->drmSubFD))) { - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] failure mapping DMA buffers\n"); - DRICloseScreen(pScreen); - return FALSE; - } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] buffers mapped with %p\n", - pMGADRIServer->drmBufs); - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] %d DMA buffers mapped\n", - pMGADRIServer->drmBufs->count); - if (!pMGADRIServer->irq) { - pMGADRIServer->irq = drmGetInterruptFromBusID(pMGA->drmSubFD, - ((pciConfigPtr)pMGA->PciInfo + } + + pMGADRI->agpBufferOffset = init_offset + pMGADRIServer->agp_private; + + /* Calculate texture constants for AGP texture space + */ + { + CARD32 agpTextureOffset = MGA_DMA_BUF_SZ * MGA_DMA_BUF_NR; + CARD32 agpTextureSize = pMGADRI->agpSize - agpTextureOffset; + + i = mylog2(agpTextureSize / MGA_NR_TEX_REGIONS); + if (i < MGA_LOG_MIN_TEX_REGION_SIZE) + i = MGA_LOG_MIN_TEX_REGION_SIZE; + + pMGADRI->logAgpTextureGranularity = i; + pMGADRI->agpTextureSize = (agpTextureSize >> i) << i; + pMGADRI->agpTextureOffset = agpTextureOffset; + } + + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[drm] added %d %d byte DMA buffers\n", + bufs, MGA_DMA_BUF_SZ); + + + if ((MgaInitDma(pScrn, prim_size)) != TRUE) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to initialize dma engine\n"); + DRICloseScreen(pScreen); + return FALSE; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Initialized Dma Engine\n"); + + if (!pMGADRIServer->irq) { + pMGADRIServer->irq = drmGetInterruptFromBusID(pMGA->drmSubFD, + ((pciConfigPtr)pMGA->PciInfo ->thisCard)->busnum, ((pciConfigPtr)pMGA->PciInfo ->thisCard)->devnum, ((pciConfigPtr)pMGA->PciInfo ->thisCard)->funcnum); - drmCtlInstHandler(pMGA->drmSubFD, pMGADRIServer->irq); - } + drmCtlInstHandler(pMGA->drmSubFD, pMGADRIServer->irq); + } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] dma control initialized, using IRQ %d\n", - pMGADRIServer->irq); - - - if (!(MGAInitVisualConfigs(pScreen))) { - DRICloseScreen(pScreen); - return FALSE; - } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "visual configs initialized\n" ); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "[drm] dma control initialized, using IRQ %d\n", + pMGADRIServer->irq); - return TRUE; + + if (!(MGAInitVisualConfigs(pScreen))) { + DRICloseScreen(pScreen); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "visual configs initialized\n" ); + + return TRUE; } void @@ -481,16 +636,26 @@ MGADRICloseScreen(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; MGAPtr pMGA = MGAPTR(pScrn); MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo; - - xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "[drm] unmapping %d buffers\n", - pMGADRIServer->drmBufs->count); - if (drmUnmapBufs(pMGADRIServer->drmBufs)) { - xf86DrvMsg(pScreen->myNum, X_INFO, - "[drm] unable to unmap DMA buffers\n"); + + MgaCleanupDma(pScrn); + + if(pMGADRIServer->agp_map) { + ErrorF("Unmapped agp region\n"); + drmUnmap(pMGADRIServer->agp_map, pMGADRIServer->agpSizep); + pMGADRIServer->agp_map = 0; } - mgadrmCleanupDma(pScrn); - + if(pMGADRIServer->agpHandle) { + ErrorF("Freeing agp memory\n"); + drmAgpFree(pMGA->drmSubFD, pMGADRIServer->agpHandle); + pMGADRIServer->agpHandle = 0; + pMGADRIServer->agpSizep = 0; + } + if(pMGADRIServer->agpAcquired == TRUE) { + ErrorF("releasing agp module\n"); + drmAgpRelease(pMGA->drmSubFD); + pMGADRIServer->agpAcquired = FALSE; + } + DRICloseScreen(pScreen); if (pMGA->pDRIInfo) { @@ -518,9 +683,6 @@ MGACreateContext(ScreenPtr pScreen, VisualPtr visual, drmContext hwContext, void *pVisualConfigPriv, DRIContextType contextStore) { - MGADRIContextPtr ctx; - - ctx = (MGADRIContextPtr)contextStore; return TRUE; } @@ -528,106 +690,120 @@ static void MGADestroyContext(ScreenPtr pScreen, drmContext hwContext, DRIContextType contextStore) { - MGADRIContextPtr ctx; - ctx = (MGADRIContextPtr)contextStore; } Bool MGADRIFinishScreenInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGASAREAPtr sPriv; MGAPtr pMGA = MGAPTR(pScrn); - MGADRIPtr pMGADRI; - int size; + if (!pMGA->pDRIInfo) return FALSE; + + sPriv = (MGASAREAPtr)DRIGetSAREAPrivate(pScreen); pMGA->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; - /* pMGA->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */ - - pMGADRI = (MGADRIPtr)pMGA->pDRIInfo->devPrivate; - pMGADRI->deviceID = pMGA->PciInfo->chipType; - pMGADRI->width = pScrn->virtualX; - pMGADRI->height = pScrn->virtualY; - pMGADRI->mem = pScrn->videoRam * 1024; - pMGADRI->cpp = pScrn->bitsPerPixel / 8; - pMGADRI->stride = pScrn->displayWidth * (pScrn->bitsPerPixel / 8); - pMGADRI->backOffset = ((pScrn->virtualY+129) * pScrn->displayWidth * - (pScrn->bitsPerPixel / 8) + 4095) & ~0xFFF; - size = 2 * pScrn->virtualX * pScrn->virtualY; - pMGADRI->depthOffset = (pMGADRI->backOffset + size + 4095) & ~0xFFF; - pMGADRI->textureOffset = pMGADRI->depthOffset + size; - /* - * The rest of the framebuffer is for textures except for the - * memory for the hardware cursor. - */ - pMGADRI->textureSize = pMGA->FbUsableSize - pMGADRI->textureOffset; - pMGADRI->fbOffset = pMGA->YDstOrg * (pScrn->bitsPerPixel / 8); + + xf86memset( sPriv, 0, sizeof(MGASAREARec) ); return DRIFinishScreenInit(pScreen); } -void MGASwapContext(ScreenPtr pScreen) + +void mgaGetQuiescence( ScrnInfoPtr pScrn ) { -#if 0 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - MGAPtr pMga = MGAPTR(pScrn); - MGAFBLayout *pLayout = &pMga->CurrentLayout; - - usleep(500); - ErrorF("Syncing : swap\n"); - MGABUSYWAIT(); - ErrorF("Sync : swap 1\n"); - MGAStormSync(pScrn); - ErrorF("Syncing done\n"); - pMga->AccelInfoRec->NeedToSync = TRUE; - - WAITFIFO(12); - OUTREG(MGAREG_MACCESS, pMga->MAccess); - OUTREG(MGAREG_PITCH, pLayout->displayWidth); - OUTREG(MGAREG_YDSTORG, pMga->YDstOrg); - OUTREG(MGAREG_PLNWT, pMga->PlaneMask); - OUTREG(MGAREG_BCOL, pMga->BgColor); - OUTREG(MGAREG_FCOL, pMga->FgColor); - OUTREG(MGAREG_SRCORG, pMga->SrcOrg); - OUTREG(MGAREG_DSTORG, pMga->DstOrg); - OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT); - OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */ - OUTREG(MGAREG_YTOP, 0x00000000); /* minPixelPointer */ - OUTREG(MGAREG_YBOT, 0x007FFFFF); /* maxPixelPointer */ - pMga->AccelFlags &= ~CLIPPER_ON; -#endif + MGAPtr pMga = MGAPTR(pScrn); + + pMga->have_quiescense = 1; + + if (pMga->directRenderingEnabled) { + MGAFBLayout *pLayout = &pMga->CurrentLayout; + + MgaLockUpdate(pScrn, (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH)); + + WAITFIFO(12); + OUTREG(MGAREG_MACCESS, pMga->MAccess); + OUTREG(MGAREG_PITCH, pLayout->displayWidth); + OUTREG(MGAREG_YDSTORG, pMga->YDstOrg); + OUTREG(MGAREG_PLNWT, pMga->PlaneMask); + OUTREG(MGAREG_BCOL, pMga->BgColor); + OUTREG(MGAREG_FCOL, pMga->FgColor); + OUTREG(MGAREG_SRCORG, pMga->SrcOrg); + OUTREG(MGAREG_DSTORG, pMga->DstOrg); + OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT); + OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */ + OUTREG(MGAREG_YTOP, 0x00000000); /* minPixelPointer */ + OUTREG(MGAREG_YBOT, 0x007FFFFF); /* maxPixelPointer */ + pMga->AccelFlags &= ~CLIPPER_ON; + } } -void MGALostContext(ScreenPtr pScreen) + + +void MGASwapContext(ScreenPtr pScreen) { -#if 0 - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - MGAPtr pMga = MGAPTR(pScrn); - MGAFBLayout *pLayout = &pMga->CurrentLayout; - - ErrorF("Syncing : lost\n"); - MGAStormSync(pScrn); - ErrorF("Sync : lost 1\n"); - MGABUSYWAIT(); - ErrorF("Syncing done\n"); -#endif + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + MGAPtr pMga = MGAPTR(pScrn); + + /* Arrange for dma_quiescence and xaa sync to be called as + * appropriate. + */ + pMga->have_quiescense = 0; + pMga->AccelInfoRec->NeedToSync = TRUE; } + + +/* This is really only called from validate/postvalidate as we + * override the dri lock/unlock. Want to remove validate/postvalidate + * processing, but need to remove all client-side use of drawable lock + * first (otherwise there is noone recover when a client dies holding + * the drawable lock). + * + * What does this mean? + * + * - The above code gets executed every time a + * window changes shape or the focus changes, which isn't really + * optimal. + * - The X server therefore believes it needs to do an XAA sync + * *and* a dma quiescense ioctl each time that happens. + * + * We don't wrap wakeuphandler any longer, so at least we can say that + * this doesn't happen *every time the mouse moves*... + */ static void MGADRISwapContext(ScreenPtr pScreen, DRISyncType syncType, DRIContextType oldContextType, void *oldContext, DRIContextType newContextType, void *newContext) { - if ((syncType == DRI_3D_SYNC) && (oldContextType == DRI_2D_CONTEXT) && - (newContextType == DRI_2D_CONTEXT)) { /* Entering from Wakeup */ - MGASwapContext(pScreen); - } - if ((syncType == DRI_2D_SYNC) && (oldContextType == DRI_NO_CONTEXT) && - (newContextType == DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ - MGALostContext(pScreen); - } + if (syncType == DRI_3D_SYNC && + oldContextType == DRI_2D_CONTEXT && + newContextType == DRI_2D_CONTEXT) + { + MGASwapContext(pScreen); + } } -/* Needs to be written */ -void MGASelectBuffer(MGAPtr pMGA, int which) + +void +MGASelectBuffer(ScrnInfoPtr pScrn, int which) { + MGAPtr pMga = MGAPTR(pScrn); + MGADRIPtr pMGADRI = (MGADRIPtr)pMga->pDRIInfo->devPrivate; + + switch (which) { + case MGA_BACK: + OUTREG(MGAREG_DSTORG, pMGADRI->backOffset); + OUTREG(MGAREG_SRCORG, pMGADRI->backOffset); + break; + case MGA_DEPTH: + OUTREG(MGAREG_DSTORG, pMGADRI->depthOffset); + OUTREG(MGAREG_SRCORG, pMGADRI->depthOffset); + break; + default: + case MGA_FRONT: + OUTREG(MGAREG_DSTORG, pMGADRI->frontOffset); + OUTREG(MGAREG_SRCORG, pMGADRI->frontOffset); + break; + } } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c index 6aabc62c3..b379022af 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c @@ -148,12 +148,7 @@ static void MGASave(ScrnInfoPtr pScrn); static void MGARestore(ScrnInfoPtr pScrn); static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); -#define VERSION 4000 -#define MGA_NAME "MGA" -#define MGA_DRIVER_NAME "mga" -#define MGA_MAJOR_VERSION 1 -#define MGA_MINOR_VERSION 0 -#define MGA_PATCHLEVEL 0 + /* * This contains the functions needed by the server after loading the @@ -164,7 +159,7 @@ static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode); */ DriverRec MGA = { - VERSION, + MGA_VERSION, MGA_DRIVER_NAME, #if 0 "accelerated driver for Matrox Millennium and Mystique cards", @@ -298,31 +293,23 @@ static const char *ramdacSymbols[] = { #ifdef XF86DRI static const char *drmSymbols[] = { + "drmAvailable", "drmAddBufs", "drmAddMap", - "drmAvailable", - "drmCtlAddCommand", "drmCtlInstHandler", "drmGetInterruptFromBusID", - "drmMapBufs", - "drmMarkBufs", - "drmUnmapBufs", "drmAgpAcquire", "drmAgpRelease", "drmAgpEnable", "drmAgpAlloc", "drmAgpFree", "drmAgpBind", - "drmAgpUnbind", - "drmAgpVersionMajor", - "drmAgpVersionMinor", "drmAgpGetMode", "drmAgpBase", "drmAgpSize", - "drmAgpMemoryUsed", - "drmAgpMemoryAvail", - "drmAgpVendorId", - "drmAgpDeviceId", + "drmMgaCleanupDma", + "drmMgaLockUpdate", + "drmMgaInitDma", NULL }; @@ -601,7 +588,7 @@ MGAProbe(DriverPtr drv, int flags) pScrn = xf86AllocateScreen(drv, 0); /* Fill in what we can of the ScrnInfoRec */ - pScrn->driverVersion = VERSION; + pScrn->driverVersion = MGA_VERSION; pScrn->driverName = MGA_DRIVER_NAME; pScrn->name = MGA_NAME; pScrn->Probe = MGAProbe; @@ -794,7 +781,7 @@ static void MGASoftReset(ScrnInfoPtr pScrn) { MGAPtr pMga = MGAPTR(pScrn); - int i; +/* int i; */ pMga->FbMapSize = 8192 * 1024; MGAMapMem(pScrn); @@ -1065,7 +1052,7 @@ VgaIOEnable(void *arg) extern xf86MonPtr ConfiguredMonitor; -void +static void MGAProbeDDC(ScrnInfoPtr pScrn, int index) { vbeInfoPtr pVbe; @@ -1261,7 +1248,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) if (pScrn->depth == 8) pScrn->rgbBits = 8; - /* * Set the Chipset and ChipRev, allowing config file entries to * override. @@ -1305,8 +1291,6 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags) } xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); - - from = X_DEFAULT; pMga->HWCursor = TRUE; /* @@ -2142,13 +2126,14 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #ifdef XF86DRI if (pMga->directRenderingEnabled) { - DRILock(screenInfo.screens[pScrn->scrnIndex]); - MGASwapContext(screenInfo.screens[pScrn->scrnIndex]); + DRILock(screenInfo.screens[pScrn->scrnIndex], 0); +/* MGADRISwapContext(screenInfo.screens[pScrn->scrnIndex]); */ } #endif (*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE); - + + MGAStormSync(pScrn); /* JEFF - Check */ MGAStormEngineInit(pScrn); vgaHWProtect(pScrn, FALSE); @@ -2322,10 +2307,10 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) * is called. cfbScreenInit will eventually call into the drivers * InitGLXVisuals call back. */ - - pMga->directRenderingEnabled = MGADRIScreenInit(pScreen); - /* Force the initialization of the context */ - MGALostContext(pScreen); + if (!pMga->NoAccel) + pMga->directRenderingEnabled = MGADRIScreenInit(pScreen); + else + pMga->directRenderingEnabled = FALSE; #endif @@ -2625,7 +2610,7 @@ MGALeaveVT(int scrnIndex, int flags) pMGA = MGAPTR(pScrn); if (pMGA->directRenderingEnabled) { pScreen = screenInfo.screens[scrnIndex]; - DRILock(pScreen); + DRILock(pScreen, 0); } #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c new file mode 100644 index 000000000..7a456258a --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c @@ -0,0 +1,198 @@ +/* $XFree86: xc/programs/Xserver/GL/dri/dri.c,v 1.4 1999/09/25 14:36:41 dawes Exp $ */ +/************************************************************************** + +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: + * Keith Whitwell <keithw@precisioninsight.com> + * + */ + + +#include "xf86.h" +#include "xf86_OSproc.h" +#include "xf86_ansic.h" +#include "xf86Priv.h" + +#include "xf86PciInfo.h" +#include "xf86Pci.h" +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb32.h" + +#include "miline.h" + +#include "GL/glxtokens.h" + +#include "mga_bios.h" +#include "mga_reg.h" +#include "mga.h" +#include "mga_macros.h" +#include "mga_dri.h" +#include "mga_wrap.h" + + + +static void MGAWakeupHandler(int screenNum, + pointer wakeupData, + unsigned long result, + pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[screenNum]; + /*DRIWrappedFuncsRec *pDRIWrap = DRIGetWrappedFuncs(pScreen);*/ + + if (0) ErrorF("MGAWakeupHandler (in)\n"); + + /* Disabled: Check contention like the 3d clients do before trying + * to restore state. + */ + DRILock(pScreen, 0); + MGASwapContext( pScreen ); + +} + +static void MGABlockHandler(int screenNum, + pointer blockData, + pointer pTimeout, + pointer pReadmask) + +{ + ScreenPtr pScreen = screenInfo.screens[screenNum]; + /*DRIWrappedFuncsRec *pDRIWrap = DRIGetWrappedFuncs(pScreen);*/ + MGASAREAPtr sa = (MGASAREAPtr)DRIGetSAREAPrivate( pScreen ); + + if (0) ErrorF("MGABlockHandler (out)\n"); + + + /* Examine the cliprects for the most recently used 3d drawable. + * If they've changed, attempt to push the updated values into the + * sarea. + * + * This avoids the protocol round trip in all single-client + * frontbuffer rendering cases providing the cliprects fit into the + * sarea, and in all single-client backbuffer rendering with arbitary + * numbers of cliprects, for all operations except swapbuffers. + * + * Thus the number of round trips in the cases where comparison is + * possible is reduced to no more (and usually fewer) than the number + * Utah requires. + */ + + if (sa->req_drawable != sa->exported_drawable || + sa->exported_stamp != DRIGetDrawableStamp( pScreen, sa->exported_index )) + { + int i; + XF86DRIClipRectPtr frontboxes, backboxes; + XF86DRIClipRectPtr boxes = (XF86DRIClipRectPtr)sa->exported_boxes; + WindowPtr window = LookupIDByType( sa->req_drawable, RT_WINDOW ); + + if (0) + ErrorF("Trying to update req_drawable: %d (exp %d), stamp %d/%d\n", + sa->req_drawable, sa->exported_drawable); + + sa->exported_drawable = 0; + + if (!window) { + if (0) + ErrorF("Couldn't retreive window\n"); + sa->req_drawable = 0; + goto finished; + } + + if (!DRIGetDrawableInfo( pScreen, &(window->drawable), + &sa->exported_index, + &sa->exported_stamp, + &sa->exported_front_x, + &sa->exported_front_y, + &sa->exported_w, + &sa->exported_h, + &sa->exported_nfront, + &frontboxes, + &sa->exported_back_x, + &sa->exported_back_y, + &sa->exported_nback, + &backboxes )) + { + if (0) + ErrorF("Couldn't get DRI info\n"); + sa->req_drawable = 0; + goto finished; + } + + /* If we can't fit both sets of cliprects into the sarea, try to + * fit the current draw buffer. Otherwise return. + */ + + sa->exported_buffers = MGA_FRONT | MGA_BACK; + + if (sa->exported_nback + sa->exported_nfront >= MGA_NR_SAREA_CLIPRECTS) { + if (sa->req_draw_buffer == MGA_FRONT) { + sa->exported_buffers = MGA_FRONT; + if (sa->exported_nfront >= MGA_NR_SAREA_CLIPRECTS) + goto finished; + } else { + sa->exported_buffers = MGA_BACK; + if (sa->exported_nback >= MGA_NR_SAREA_CLIPRECTS) + goto finished; + } + } + + if (sa->exported_buffers & MGA_BACK) { + for (i = 0 ; i < sa->exported_nback ; i++) + *boxes++ = backboxes[i]; + } + + if (sa->exported_buffers & MGA_FRONT) { + for (i = 0 ; i < sa->exported_nfront ; i++) + *boxes++ = frontboxes[i]; + } + + sa->exported_drawable = sa->req_drawable; + } + + finished: + DRIUnlock(pScreen); +} + + + + +/* Just wrap validate tree for now to remove the quiescense hack. + * This is more of a win for the i810 than the mga, but should be useful + * here too. + */ +void MGADRIWrapFunctions(ScreenPtr pScreen, DRIInfoPtr pDRIInfo) +{ + pDRIInfo->wrap.BlockHandler = MGABlockHandler; + pDRIInfo->wrap.WakeupHandler = MGAWakeupHandler; +/* pDRIInfo->wrap.ValidateTree = NULL; */ +/* pDRIInfo->wrap.PostValidateTree = NULL; */ +} + + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h index d5d120153..e948cb6b9 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h @@ -1,8 +1,8 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.8 2000/02/23 04:47:18 martin Exp $ */ /************************************************************************** -Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. +Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -40,10 +40,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */ #define R128_MMIOSIZE 0x80000 + /* R128_NAME is used for the server-side + ddx driver, the client-side DRI driver, + and the kernel-level DRM driver. */ #define R128_NAME "r128" #define R128_VERSION_MAJOR 3 -#define R128_VERSION_MINOR 0 -#define R128_VERSION_PATCH 0 +#define R128_VERSION_MINOR 1 +#define R128_VERSION_PATCH 1 #define R128_VERSION ((R128_VERSION_MAJOR << 16) \ | (R128_VERSION_MINOR << 8) \ | R128_VERSION_PATCH) @@ -100,7 +103,7 @@ typedef struct { CARD32 amcgpio_en_reg; CARD32 amcgpio_mask; - /* Crtc registers */ + /* CRTC registers */ CARD32 crtc_gen_cntl; CARD32 crtc_ext_cntl; CARD32 dac_cntl; @@ -112,6 +115,21 @@ typedef struct { CARD32 crtc_offset_cntl; CARD32 crtc_pitch; + /* CRTC2 registers */ + CARD32 crtc2_gen_cntl; + + /* Flat panel registers */ + CARD32 fp_crtc_h_total_disp; + CARD32 fp_crtc_v_total_disp; + CARD32 fp_gen_cntl; + CARD32 fp_h_sync_strt_wid; + CARD32 fp_horz_stretch; + CARD32 fp_panel_cntl; + CARD32 fp_v_sync_strt_wid; + CARD32 fp_vert_stretch; + CARD32 lvds_gen_cntl; + CARD32 tmds_crc; + /* Computed values for PLL */ int dot_clock_freq; int pll_output_freq; @@ -157,10 +175,24 @@ typedef struct { unsigned char *FB; /* Map of frame buffer */ CARD32 MemCntl; - CARD32 BusCntl; + CARD32 BusCntl; unsigned long FbMapSize; /* Size of frame buffer, in bytes */ int Flags; /* Saved copy of mode flags */ + Bool EnableFP; /* Enable use of FP registers */ + Bool CRTOnly; /* Only use External CRT instead of FP */ + Bool HasPanelRegs; /* Current chip can connect to a FP */ + + /* Computed values for FPs */ + int PanelXRes; + int PanelYRes; + int PanelHNonVis; + int PanelHOverPlus; + int PanelHSyncWidth; + int PanelVNonVis; + int PanelVOverPlus; + int PanelVSyncWidth; + R128PLLRec pll; R128RAMPtr ram; @@ -168,6 +200,8 @@ typedef struct { R128SaveRec ModeReg; /* Current mode */ Bool (*CloseScreen)(int, ScreenPtr); + Bool PaletteSavedOnVT; /* Palette saved on last VT switch */ + I2CBusPtr i2c; XAAInfoRecPtr accel; xf86CursorInfoPtr cursor; @@ -199,8 +233,98 @@ typedef struct { int scanline_words; int scanline_direct; int scanline_bpp; /* Only used for ImageWrite */ + +#ifdef XF86DRI + Bool directRenderingEnabled; + DRIInfoPtr pDRIInfo; + int drmFD; + int numVisualConfigs; + __GLXvisualConfig *pVisualConfigs; + R128ConfigPrivPtr pVisualConfigsPriv; + + drmHandle fbHandle; + + drmSize registerSize; + drmHandle registerHandle; + + Bool IsPCI; /* Current card is a PCI card */ + + drmSize agpSize; + drmHandle agpMemHandle; /* Handle from drmAgpAlloc */ + unsigned long agpOffset; + unsigned char *AGP; /* Map */ + int agpMode; + + Bool CCEInUse; /* CCE is currently active */ + int CCEMode; /* CCE mode that server/clients use */ + int CCEFifoSize; /* Size of the CCE command FIFO */ + Bool CCESecure; /* CCE security enabled */ + int CCEusecTimeout; /* CCE timeout in usecs */ + Bool CCE2D; /* CCE is used for X server 2D prims */ + + /* CCE ring buffer data */ + unsigned long ringStart; /* Offset into AGP space */ + drmHandle ringHandle; /* Handle from drmAddMap */ + drmSize ringMapSize; /* Size of map */ + int ringSize; /* Size of ring (in MB) */ + unsigned char *ring; /* Map */ + int ringSizeLog2QW; + + unsigned long ringReadOffset; /* Offset into AGP space */ + drmHandle ringReadPtrHandle; /* Handle from drmAddMap */ + drmSize ringReadMapSize; /* Size of map */ + unsigned char *ringReadPtr; /* Map */ + + /* CCE vertex buffer data */ + unsigned long vbStart; /* Offset into AGP space */ + drmHandle vbHandle; /* Handle from drmAddMap */ + drmSize vbMapSize; /* Size of map */ + int vbSize; /* Size of vert bufs (in MB) */ + unsigned char *vb; /* Map */ + int vbBufSize; /* Size of individual vert buf */ + int vbNumBufs; /* Number of vert bufs */ + drmBufMapPtr vbBufs; /* Buffer map */ + + /* CCE indirect buffer data */ + unsigned long indStart; /* Offset into AGP space */ + drmHandle indHandle; /* Handle from drmAddMap */ + drmSize indMapSize; /* Size of map */ + int indSize; /* Size of indirect bufs (in MB) */ + unsigned char *ind; /* Map */ + + /* CCE AGP Texture data */ + unsigned long agpTexStart; /* Offset into AGP space */ + drmHandle agpTexHandle; /* Handle from drmAddMap */ + drmSize agpTexMapSize; /* Size of map */ + int agpTexSize; /* Size of AGP tex space (in MB) */ + unsigned char *agpTex; /* Map */ + int log2AGPTexGran; + + /* DRI screen private data */ + int fbX; + int fbY; + int backX; + int backY; + int depthX; + int depthY; + int textureX; + int textureY; + int textureSize; + int log2TexGran; +#endif } R128InfoRec, *R128InfoPtr; +#define R128WaitForFifo(pScrn, entries) \ +do { \ + if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \ + info->fifo_slots -= entries; \ +} while (0) + +extern void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries); +extern void R128WaitForIdle(ScrnInfoPtr pScrn); +extern void R128EngineReset(ScrnInfoPtr pScrn); +extern void R128EngineFlush(ScrnInfoPtr pScrn); + extern int INPLL(ScrnInfoPtr pScrn, int addr); extern void R128WaitForVerticalSync(ScrnInfoPtr pScrn); @@ -208,4 +332,16 @@ extern Bool R128AccelInit(ScreenPtr pScreen); extern void R128EngineInit(ScrnInfoPtr pScrn); extern Bool R128CursorInit(ScreenPtr pScreen); +extern int R128MinBits(int val); + +#ifdef XF86DRI +extern Bool R128DRIScreenInit(ScreenPtr pScreen); +extern void R128DRICloseScreen(ScreenPtr pScreen); +extern Bool R128DRIFinishScreenInit(ScreenPtr pScreen); +extern void R128CCEStart(ScrnInfoPtr pScrn); +extern void R128CCEStop(ScrnInfoPtr pScrn); +extern void R128CCEResetRing(ScrnInfoPtr pScrn); +extern void R128CCEWaitForIdle(ScrnInfoPtr pScrn); +#endif + #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c new file mode 100644 index 000000000..329100c43 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c @@ -0,0 +1,1284 @@ +/* $XFree86$ */ +/************************************************************************** + +Copyright 1999, 2000 ATI Technologies Inc. and 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 +on 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 +ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, +DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Kevin E. Martin <kevin@precisioninsight.com> + * Rickard E. Faith <faith@precisioninsight.com> + * Daryll Strauss <daryll@precisioninsight.com> + * + */ + + + /* X and server generic header files */ +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Resources.h" +#include "xf86RAC.h" +#include "xf86cmap.h" +#include "xf86fbman.h" + + /* Backing store, software cursor, and + colormap initialization */ +#include "mibstore.h" +#include "mipointer.h" +#include "micmap.h" + + /* CFB support */ +#define PSZ 8 +#include "cfb.h" +#undef PSZ +#include "cfb16.h" +#include "cfb24.h" +#include "cfb32.h" +#include "cfb24_32.h" + + /* XAA and Cursor Support */ +#include "xaa.h" +#include "xf86Cursor.h" + + /* PCI support */ +#include "xf86PciInfo.h" +#include "xf86Pci.h" + + /* DDC support */ +#include "xf86DDC.h" + + /* DRI support */ +#include "GL/glxint.h" +#include "GL/glxtokens.h" +#include "xf86drm.h" +#include "xf86drmR128.h" +#include "sarea.h" +#define _XF86DRI_SERVER_ +#include "xf86dri.h" +#include "dri.h" +#include "r128_dri.h" +#include "r128_sarea.h" +#include "r128_dripriv.h" + + /* Driver data structures */ +#include "r128.h" +#include "r128_reg.h" + +#define R128_WATERMARK_L 16 +#define R128_WATERMARK_M 8 +#define R128_WATERMARK_N 8 +#define R128_WATERMARK_K 128 + +static int CCEFifoSlots = 0; + +#define R128CCEWaitForFifo(pScrn, entries) \ +do { \ + if (CCEFifoSlots < entries) R128WaitForFifoFunction(pScrn, entries); \ + CCEFifoSlots -= entries; \ +} while (0) + +/* Wait for at least `entries' slots are free. The actual number of + slots available is stored in info->CCEFifoSize. */ +static void R128CCEWaitForFifoFunction(ScrnInfoPtr pScrn, int entries) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + CCEFifoSlots = INREG(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK; + if (CCEFifoSlots >= entries) return; + } + R128EngineReset(pScrn); + if (info->CCE2D) R128CCEStart(pScrn); + } +} + +/* Wait until the CCE is completely idle: the FIFO has drained and the + CCE is idle. */ +void R128CCEWaitForIdle(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + int i; + + if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; + + if (R128CCE_USE_RING_BUFFER(info->CCEMode)) { + volatile CARD32 *r128RingReadPtr = + (volatile CARD32 *)(info->ringReadPtr); + R128SAREAPrivPtr pSAREAPriv; + + OUTREGP(R128_PM4_BUFFER_DL_WPTR, + R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE); + + pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen); + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + if (*r128RingReadPtr == pSAREAPriv->ringWrite) { + int pm4stat = INREG(R128_PM4_STAT); + if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= info->CCEFifoSize + && !(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) + return; + } + } + R128EngineReset(pScrn); + if (info->CCE2D) R128CCEStart(pScrn); + } + } else { + R128CCEWaitForFifoFunction(pScrn, info->CCEFifoSize); + + for (;;) { + for (i = 0; i < R128_TIMEOUT; i++) { + if (!(INREG(R128_PM4_STAT) + & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) { + R128EngineFlush(pScrn); + return; + } + } + R128EngineReset(pScrn); + if (info->CCE2D) R128CCEStart(pScrn); + } + } +} + +/* Reset the ring buffer status, if the engine was reset */ +void R128CCEResetRing(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + R128SAREAPrivPtr pSAREAPriv; + volatile CARD32 *r128RingReadPtr; + + if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; + + r128RingReadPtr = (volatile CARD32 *)(info->ringReadPtr); + pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen); + + OUTREG(R128_PM4_BUFFER_DL_WPTR, 0); + OUTREG(R128_PM4_BUFFER_DL_RPTR, 0); + pSAREAPriv->ringWrite = 0; + *r128RingReadPtr = 0; + + /* Resetting the ring turns off the CCE */ + info->CCEInUse = FALSE; +} + +/* Start the CCE, but only if it is not already in use and the requested + mode is a CCE mode. The mode is stored in info->CCEMode. */ +void R128CCEStart(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + if (info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; + + R128WaitForIdle(pScrn); + OUTREG(R128_PM4_BUFFER_CNTL, info->CCEMode | info->ringSizeLog2QW); + (void)INREG(R128_PM4_BUFFER_ADDR); /* as per the sample code */ + OUTREG(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN); + info->CCEInUse = TRUE; +} + +/* Stop the CCE, but only if it is in use and the requested mode is not + the non-CCE mode. This function also flushes any outstanding + requests before switching modes.*/ +void R128CCEStop(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return; + + R128CCEWaitForIdle(pScrn); + OUTREG(R128_PM4_MICRO_CNTL, 0); + OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4); + R128EngineReset(pScrn); + info->CCEInUse = FALSE; +} + +/* Initialize the visual configs that are supported by the hardware. + These are combined with the visual configs that the indirect + rendering core supports, and the intersection is exported to the + client. */ +static Bool R128InitVisualConfigs(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr pR128 = R128PTR(pScrn); + int numConfigs = 0; + __GLXvisualConfig *pConfigs = 0; + R128ConfigPrivPtr pR128Configs = 0; + R128ConfigPrivPtr *pR128ConfigPtrs = 0; + int i, accum, stencil; + + switch (pR128->pixel_code) { + case 8: /* 8bpp mode is not support */ + case 15: /* FIXME */ + case 24: /* FIXME */ + return FALSE; + +#define R128_USE_ACCUM 1 +#define R128_USE_STENCIL 0 /* Only in 24 depth mode */ + + case 16: + numConfigs = 1; + if (R128_USE_ACCUM) numConfigs *= 2; + + if (!(pConfigs + = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), + numConfigs))) { + return FALSE; + } + if (!(pR128Configs + = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pR128ConfigPtrs + = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pR128Configs); + return FALSE; + } + + i = 0; + for (accum = 0; accum <= R128_USE_ACCUM; accum++) { + pR128ConfigPtrs[i] = &pR128Configs[i]; + + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + + pConfigs[i].alphaMask = 0; + if (accum) { /* Simulated in software */ + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 0; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + pConfigs[i].doubleBuffer = TRUE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 16; + pConfigs[i].depthSize = 16; + pConfigs[i].stencilSize = 0; + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (accum) + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + else + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + break; + case 32: + numConfigs = 1; + if (R128_USE_ACCUM) numConfigs *= 2; + if (R128_USE_STENCIL) numConfigs *= 2; + + if (!(pConfigs + = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), + numConfigs))) { + return FALSE; + } + if (!(pR128Configs + = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec), + numConfigs))) { + xfree(pConfigs); + return FALSE; + } + if (!(pR128ConfigPtrs + = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr), + numConfigs))) { + xfree(pConfigs); + xfree(pR128Configs); + return FALSE; + } + + i = 0; + for (accum = 0; accum <= R128_USE_ACCUM; accum++) { + for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) { + pR128ConfigPtrs[i] = &pR128Configs[i]; + + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 8; + pConfigs[i].greenSize = 8; + pConfigs[i].blueSize = 8; + pConfigs[i].redMask = 0x00FF0000; + pConfigs[i].greenMask = 0x0000FF00; + pConfigs[i].blueMask = 0x000000FF; + + pConfigs[i].alphaMask = 0; + if (accum) { /* Simulated in software */ + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 0; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + pConfigs[i].doubleBuffer = TRUE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 24; + if (stencil) { + pConfigs[i].depthSize = 24; + pConfigs[i].stencilSize = 8; + } else { + pConfigs[i].depthSize = 32; + pConfigs[i].stencilSize = 0; + } + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (accum) + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + else + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + break; + } + + pR128->numVisualConfigs = numConfigs; + pR128->pVisualConfigs = pConfigs; + pR128->pVisualConfigsPriv = pR128Configs; + GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pR128ConfigPtrs); + return TRUE; +} + +/* Create the Rage 128-specific context information */ +static Bool R128CreateContext(ScreenPtr pScreen, VisualPtr visual, + drmContext hwContext, void *pVisualConfigPriv, + DRIContextType contextStore) +{ + /* Nothing yet */ + return TRUE; +} + +/* Destroy the Rage 128-specific context information */ +static void R128DestroyContext(ScreenPtr pScreen, drmContext hwContext, + DRIContextType contextStore) +{ + /* Nothing yet */ +} + +/* Called when the X server is woken up to allow the last client's + context to be saved and the X server's context to be loaded. This is + not necessary for the Rage 128 since the client detects when it's + context is not currently loaded and then load's it itself. Since the + registers to start and stop the CCE are privileged, only the X server + can start/stop the engine. */ +static void R128EnterServer(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr pR128 = R128PTR(pScrn); + + if (pR128->accel) pR128->accel->NeedToSync = TRUE; + +#if 1 + if (!pR128->CCE2D) R128CCEStop(pScrn); +#else + if (pR128->CCE2D) R128CCEWaitForIdle(pScrn); + else R128CCEStop(pScrn); +#endif +} + +/* Called when the X server goes to sleep to allow the X server's + context to be saved and the last client's context to be loaded. This + is not necessary for the Rage 128 since the client detects when it's + context is not currently loaded and then load's it itself. Since the + registers to start and stop the CCE are privileged, only the X server + can start/stop the engine. */ +static void R128LeaveServer(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr pR128 = R128PTR(pScrn); + +#if 1 + if (!pR128->CCE2D) R128CCEStart(pScrn); +#else + if (pR128->CCE2D) R128CCEWaitForIdle(pScrn); + else R128CCEStart(pScrn); +#endif +} + +/* Contexts can be swapped by the X server if necessary. This callback + is currently only used to perform any functions necessary when + entering or leaving the X server, and in the future might not be + necessary. */ +static void R128DRISwapContext(ScreenPtr pScreen, DRISyncType syncType, + DRIContextType oldContextType, void *oldContext, + DRIContextType newContextType, void *newContext) +{ + if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ + R128EnterServer(pScreen); + } + if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ + R128LeaveServer(pScreen); + } +} + +/* Initialize the state of the back and depth buffers. */ +static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index) +{ + /* FIXME: This routine needs to have acceleration turned on */ + ScreenPtr pScreen = pWin->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr pR128 = R128PTR(pScrn); + BoxPtr pbox; + int nbox; + int depth; + + /* FIXME: Use accel when CCE 2D code is written */ + if (pR128->CCE2D) return; + + /* FIXME: This should be based on the __GLXvisualConfig info */ + switch (pScrn->bitsPerPixel) { + case 8: depth = 0x000000ff; break; + case 16: depth = 0x0000ffff; break; + case 24: depth = 0x00ffffff; break; + case 32: depth = 0xffffffff; break; + default: depth = 0x00000000; break; + } + + /* FIXME: Copy XAAPaintWindow() and use REGION_TRANSLATE() */ + /* FIXME: Only initialize the back and depth buffers for contexts + that request them */ + + pbox = REGION_RECTS(prgn); + nbox = REGION_NUM_RECTS(prgn); + + (*pR128->accel->SetupForSolidFill)(pScrn, 0, GXcopy, -1); + for (; nbox; nbox--, pbox++) { + (*pR128->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + pR128->fbX, + pbox->y1 + pR128->fbY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + (*pR128->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + pR128->backX, + pbox->y1 + pR128->backY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + } + + (*pR128->accel->SetupForSolidFill)(pScrn, depth, GXcopy, -1); + for (; nbox; nbox--, pbox++) + (*pR128->accel->SubsequentSolidFillRect)(pScrn, + pbox->x1 + pR128->depthX, + pbox->y1 + pR128->depthY, + pbox->x2 - pbox->x1, + pbox->y2 - pbox->y1); + + pR128->accel->NeedToSync = TRUE; +} + +/* Copy the back and depth buffers when the X server moves a window. */ +static void R128DRIMoveBuffers(WindowPtr pWin, DDXPointRec ptOldOrg, + RegionPtr prgnSrc, CARD32 index) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr pR128 = R128PTR(pScrn); + + /* FIXME: This routine needs to have acceleration turned on */ + /* FIXME: Copy XAACopyWindow() and use REGION_TRANSLATE() */ + /* FIXME: Only initialize the back and depth buffers for contexts + that request them */ + + /* FIXME: Use accel when CCE 2D code is written */ + if (pR128->CCE2D) return; +} + +/* Initialize the AGP state. Request memory for use in AGP space, and + initialize the Rage 128 registers to point to that memory. */ +static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen) +{ + unsigned char *R128MMIO = pR128->MMIO; + unsigned long mode; + unsigned int vendor, device; + int ret; + unsigned long cntl; + int s, l; + int flags; + + if (drmAgpAcquire(pR128->drmFD) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not available\n"); + return FALSE; + } + + /* Modify the mode if the default mode is + not appropriate for this particular + combination of graphics card and AGP + chipset. */ + + mode = drmAgpGetMode(pR128->drmFD); /* Default mode */ + vendor = drmAgpVendorId(pR128->drmFD); + device = drmAgpDeviceId(pR128->drmFD); + + mode &= ~R128_AGP_MODE_MASK; + switch (pR128->agpMode) { + case 2: mode |= R128_AGP_2X_MODE; + case 1: default: mode |= R128_AGP_1X_MODE; + } + + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n", + mode, vendor, device, + pR128->PciInfo->vendor, + pR128->PciInfo->chipType); + + if (drmAgpEnable(pR128->drmFD, mode) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n"); + drmAgpRelease(pR128->drmFD); + return FALSE; + } + + pR128->agpOffset = 0; + + if ((ret = drmAgpAlloc(pR128->drmFD, pR128->agpSize*1024*1024, 0, NULL, + &pR128->agpMemHandle)) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Out of memory (%d)\n", ret); + drmAgpRelease(pR128->drmFD); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] %d kB allocated with handle 0x%08x\n", + pR128->agpSize*1024, pR128->agpMemHandle); + + if (drmAgpBind(pR128->drmFD, pR128->agpMemHandle, pR128->agpOffset) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not bind\n"); + drmAgpFree(pR128->drmFD, pR128->agpMemHandle); + drmAgpRelease(pR128->drmFD); + return FALSE; + } + + /* Initialize the CCE ring buffer data */ + pR128->ringStart = pR128->agpOffset; + pR128->ringMapSize = pR128->ringSize*1024*1024 + 4096; + pR128->ringSizeLog2QW = R128MinBits(pR128->ringSize*1024*1024/8) - 1; + + pR128->ringReadOffset = pR128->ringStart + pR128->ringMapSize; + pR128->ringReadMapSize = 4096; + + /* Reserve space for the vertex buffer */ + pR128->vbStart = pR128->ringReadOffset + pR128->ringReadMapSize; + pR128->vbMapSize = pR128->vbSize*1024*1024; + + /* Reserve space for the indirect buffer */ + pR128->indStart = pR128->vbStart + pR128->vbMapSize; + pR128->indMapSize = pR128->indSize*1024*1024; + + /* Reserve the rest for AGP textures */ + pR128->agpTexStart = pR128->indStart + pR128->indMapSize; + s = (pR128->agpSize*1024*1024 - pR128->agpTexStart); + l = R128MinBits((s-1) / R128_NR_TEX_REGIONS); + if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; + pR128->agpTexMapSize = (s >> l) << l; + pR128->log2AGPTexGran = l; + + if (pR128->CCESecure) flags = DRM_READ_ONLY; + else flags = 0; + + if (drmAddMap(pR128->drmFD, pR128->ringStart, pR128->ringMapSize, + DRM_AGP, flags, &pR128->ringHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add ring mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] ring handle = 0x%08lx\n", pR128->ringHandle); + + if (drmMap(pR128->drmFD, pR128->ringHandle, pR128->ringMapSize, + (drmAddressPtr)&pR128->ring) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not map ring\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Ring mapped at 0x%08lx\n", + (unsigned long)pR128->ring); + + if (drmAddMap(pR128->drmFD, pR128->ringReadOffset, pR128->ringReadMapSize, + DRM_AGP, flags, &pR128->ringReadPtrHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add ring read ptr mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] ring read ptr handle = 0x%08lx\n", + pR128->ringReadPtrHandle); + + if (drmMap(pR128->drmFD, pR128->ringReadPtrHandle, pR128->ringReadMapSize, + (drmAddressPtr)&pR128->ringReadPtr) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map ring read ptr\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Ring read ptr mapped at 0x%08lx\n", + (unsigned long)pR128->ringReadPtr); + + if (drmAddMap(pR128->drmFD, pR128->vbStart, pR128->vbMapSize, + DRM_AGP, 0, &pR128->vbHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add vertex buffers mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] vertex buffers handle = 0x%08lx\n", pR128->vbHandle); + + if (drmMap(pR128->drmFD, pR128->vbHandle, pR128->vbMapSize, + (drmAddressPtr)&pR128->vb) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map vertex buffers\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Vertex buffers mapped at 0x%08lx\n", + (unsigned long)pR128->vb); + + if (drmAddMap(pR128->drmFD, pR128->indStart, pR128->indMapSize, + DRM_AGP, flags, &pR128->indHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add indirect buffers mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] indirect buffers handle = 0x%08lx\n", pR128->indHandle); + + if (drmMap(pR128->drmFD, pR128->indHandle, pR128->indMapSize, + (drmAddressPtr)&pR128->ind) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map indirect buffers\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] Indirect buffers mapped at 0x%08lx\n", + (unsigned long)pR128->ind); + + if (drmAddMap(pR128->drmFD, pR128->agpTexStart, pR128->agpTexMapSize, + DRM_AGP, 0, &pR128->agpTexHandle) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not add AGP texture map mapping\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] AGP texture map handle = 0x%08lx\n", + pR128->agpTexHandle); + + if (drmMap(pR128->drmFD, pR128->agpTexHandle, pR128->agpTexMapSize, + (drmAddressPtr)&pR128->agpTex) < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Could not map AGP texture map\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[agp] AGP Texture map mapped at 0x%08lx\n", + (unsigned long)pR128->agpTex); + + /* Initialize Rage 128's AGP registers */ + cntl = INREG(R128_AGP_CNTL); + cntl &= ~R128_AGP_APER_SIZE_MASK; + switch (pR128->agpSize) { + case 256: cntl |= R128_AGP_APER_SIZE_256MB; break; + case 128: cntl |= R128_AGP_APER_SIZE_128MB; break; + case 64: cntl |= R128_AGP_APER_SIZE_64MB; break; + case 32: cntl |= R128_AGP_APER_SIZE_32MB; break; + case 16: cntl |= R128_AGP_APER_SIZE_16MB; break; + case 8: cntl |= R128_AGP_APER_SIZE_8MB; break; + case 4: cntl |= R128_AGP_APER_SIZE_4MB; break; + default: + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[agp] Illegal aperture size %d kB\n", + pR128->agpSize*1024); + return FALSE; + } + OUTREG(R128_AGP_BASE, pR128->ringHandle); /* Ring buf is at AGP offset 0 */ + OUTREG(R128_AGP_CNTL, cntl); + + return TRUE; +} + +/* Add a map for the MMIO registers that will be accessed by any + DRI-based clients. */ +static Bool R128DRIMapInit(R128InfoPtr pR128, ScreenPtr pScreen) +{ + int flags; + + if (pR128->CCESecure) flags = DRM_READ_ONLY; + else flags = 0; + + /* Map registers */ + pR128->registerSize = R128_MMIOSIZE; + if (drmAddMap(pR128->drmFD, pR128->MMIOAddr, pR128->registerSize, + DRM_REGISTERS, flags, &pR128->registerHandle) < 0) { + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] register handle = 0x%08lx\n", pR128->registerHandle); + + return TRUE; +} + +/* Initialize the ring buffer state for use in the X server and any + DRI-based clients. */ +static void R128DRICCEInitRingBuffer(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + unsigned long addr; + + /* FIXME: When we use the CCE for the X server, we should move this + function (and the support functions above) to r128_accel.c */ + + /* The manual (p. 2) says this address is + in "VM space". This means it's an + offset from the start of AGP space. */ + OUTREG(R128_PM4_BUFFER_OFFSET, info->ringStart | 0x02000000); + + OUTREG(R128_PM4_BUFFER_DL_WPTR, 0); + OUTREG(R128_PM4_BUFFER_DL_RPTR, 0); + + /* DL_RPTR_ADDR is a physical address. + This should be in the SAREA. */ + *(volatile long unsigned *)(info->ringReadPtr) = 0; + OUTREG(R128_PM4_BUFFER_DL_RPTR_ADDR, (info->ringReadPtrHandle)); + + /* Set watermark control */ + OUTREG(R128_PM4_BUFFER_WM_CNTL, + ((R128_WATERMARK_L/4) << R128_WMA_SHIFT) + | ((R128_WATERMARK_M/4) << R128_WMB_SHIFT) + | ((R128_WATERMARK_N/4) << R128_WMC_SHIFT) + | ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT)); + + addr = INREG(R128_PM4_BUFFER_ADDR); /* Force read. Why? Because it's + in the examples... */ + +#if 0 + R128CCEWaitForIdle(pScrn); +#endif + + /* Turn on bus mastering */ + info->BusCntl &= ~R128_BUS_MASTER_DIS; + OUTREGP(R128_BUS_CNTL, 0, ~R128_BUS_MASTER_DIS); +} + +/* Initialize the kernel data structures. */ +static int R128DRIKernelInit(R128InfoPtr pR128, ScreenPtr pScreen) +{ + drmR128Init drmInfo; + + drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec); + drmInfo.is_pci = pR128->IsPCI; + drmInfo.cce_mode = pR128->CCEMode; + drmInfo.cce_fifo_size = pR128->CCEFifoSize; + drmInfo.cce_secure = pR128->CCESecure; + drmInfo.ring_size = pR128->ringSize*1024*1024; + drmInfo.usec_timeout = pR128->CCEusecTimeout; + + drmInfo.fb_offset = pR128->LinearAddr; + drmInfo.agp_ring_offset = pR128->ringHandle; + drmInfo.agp_read_ptr_offset = pR128->ringReadPtrHandle; + drmInfo.agp_vertbufs_offset = pR128->vbHandle; + drmInfo.agp_indbufs_offset = pR128->indHandle; + drmInfo.agp_textures_offset = pR128->agpTexHandle; + drmInfo.mmio_offset = pR128->registerHandle; + + if (drmR128InitCCE(pR128->drmFD, &drmInfo) < 0) return FALSE; + + return TRUE; +} + +/* Add a map for the vertex buffers that will be accessed by any + DRI-based clients. */ +static Bool R128DRIBufInit(R128InfoPtr pR128, ScreenPtr pScreen) +{ + /* Initialize vertex buffers */ + if ((pR128->vbNumBufs = drmAddBufs(pR128->drmFD, + pR128->vbMapSize / pR128->vbBufSize, + pR128->vbBufSize, + DRM_AGP_BUFFER, + pR128->vbStart)) <= 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Could not create vertex buffers list\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Added %d %d byte vertex buffers\n", + pR128->vbNumBufs, pR128->vbBufSize); + + if (drmMarkBufs(pR128->drmFD, 0.133333, 0.266666)) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to mark vertex buffers list\n"); + return FALSE; + } + + if (!(pR128->vbBufs = drmMapBufs(pR128->drmFD))) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "[drm] Failed to map vertex buffers list\n"); + return FALSE; + } + xf86DrvMsg(pScreen->myNum, X_INFO, + "[drm] Mapped %d vertex buffers\n", + pR128->vbBufs->count); + + return TRUE; +} + +/* Load the microcode for the CCE */ +static void R128DRILoadMicrocode(ScrnInfoPtr pScrn) +{ + unsigned char *R128MMIO = R128PTR(pScrn)->MMIO; + int i; + unsigned long R128Microcode[] = { + /* CCE microcode (from ATI) */ + 0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0, 1617039951, + 0, 774592877, 0, 1987540286, 0, 2307490946U, 0, 599558925, 0, 589505315, 0, + 596487092, 0, 589505315, 1, 11544576, 1, 206848, 1, 311296, 1, 198656, 2, + 912273422, 11, 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12, + 28, 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9, 30, 1, + 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656, 1, 15630, 1, 51200, + 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1, 15717, 1, 15718, 2, 43, 1, + 15936948, 1, 570480831, 1, 14715071, 12, 322123831, 1, 33953125, 12, 55, 1, + 33559908, 1, 15718, 2, 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1, + 509952, 1, 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1, + 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1, 15975928, 1, + 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2, 268449859, 2, 10307, 12, + 176, 1, 15734, 1, 15735, 1, 15630, 1, 15631, 1, 5253120, 6, 3145810, 16, + 2150645232U, 1, 15864, 2, 82, 1, 343310, 1, 1064207, 2, 3145813, 1, 15728, + 1, 7817, 1, 15729, 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002, + 1, 16008, 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0, + 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1, 180224, 1, + 103824738, 2, 112, 2, 3145839, 0, 536885440, 1, 114880, 14, 125, 12, + 206975, 1, 33559995, 12, 198784, 0, 33570236, 1, 15803, 0, 15804, 3, + 294912, 1, 294912, 3, 442370, 1, 11544576, 0, 811612160, 1, 12593152, 1, + 11536384, 1, 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1, + 14793, 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1, + 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1, 114880, 14, + 159, 12, 198784, 1, 1109409213, 12, 198783, 1, 1107312059, 12, 198784, 1, + 1109409212, 2, 162, 1, 1075854781, 1, 1073757627, 1, 1075854780, 1, 540672, + 1, 10485760, 6, 3145894, 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0, + 0, 0, 256, 14, 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858, + 1, 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1, 33560360, 1, + 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1, 409611, 9, 188, 0, + 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0 + }; + + R128WaitForIdle(pScrn); + + OUTREG(R128_PM4_MICROCODE_ADDR, 0); + for (i = 0; i < 256; i += 1) { + OUTREG(R128_PM4_MICROCODE_DATAH, R128Microcode[i*2]); + OUTREG(R128_PM4_MICROCODE_DATAL, R128Microcode[i*2 + 1]); + } +} + +/* Initialize the CCE state, and start the CCE (if used by the X server) */ +static void R128DRICCEInit(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + unsigned char *R128MMIO = info->MMIO; + + /* CCEMode is initialized in r128_driver.c */ + switch (info->CCEMode) { + case R128_PM4_NONPM4: info->CCEFifoSize = 0; break; + case R128_PM4_192PIO: info->CCEFifoSize = 192; break; + case R128_PM4_192BM: info->CCEFifoSize = 192; break; + case R128_PM4_128PIO_64INDBM: info->CCEFifoSize = 128; break; + case R128_PM4_128BM_64INDBM: info->CCEFifoSize = 128; break; + case R128_PM4_64PIO_128INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64BM_128INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64PIO_64VCBM_64INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64BM_64VCBM_64INDBM: info->CCEFifoSize = 64; break; + case R128_PM4_64PIO_64VCPIO_64INDPIO: info->CCEFifoSize = 64; break; + } + + if (info->CCE2D) { + /* Make sure the CCE is on for the X server */ + R128CCEStart(pScrn); + } else { + /* Make sure the CCE is off for the X server */ + OUTREG(R128_PM4_MICRO_CNTL, 0); + OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4); + } +} + +/* Initialize the screen-specific data structures for the DRI and the + Rage 128. This is the main entry point to the device-specific + initialization code. It calls device-independent DRI functions to + create the DRI data structures and initialize the DRI state. */ +Bool R128DRIScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr pR128 = R128PTR(pScrn); + DRIInfoPtr pDRIInfo; + R128DRIPtr pR128DRI; + int major, minor, patch; + drmVersionPtr version; + +#if XFree86LOADER + /* Check that the GLX, DRI, and DRM modules have been loaded by testing + * for known symbols in each module. */ + if (!LoaderSymbol("GlxSetVisualConfigs")) return FALSE; + if (!LoaderSymbol("DRIScreenInit")) return FALSE; + if (!LoaderSymbol("drmAvailable")) return FALSE; +#endif + + /* Check the DRI version */ + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "R128DRIScreenInit failed " + "(DRI version = %d.%d.%d, expected 3.0.x). " + "Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + + switch (pR128->pixel_code) { + case 8: + /* These modes are not supported (yet). */ + case 15: + case 24: + return FALSE; + + /* Only 16 and 32 color depths are supports currently. */ + case 16: + case 32: + break; + } + + /* Create the DRI data structure, and fill it in before calling the + DRIScreenInit(). */ + if (!(pDRIInfo = DRICreateInfoRec())) return FALSE; + + pR128->pDRIInfo = pDRIInfo; + pDRIInfo->drmDriverName = R128_NAME; + pDRIInfo->clientDriverName = R128_NAME; + pDRIInfo->busIdString = xalloc(64); + sprintf(pDRIInfo->busIdString, + "PCI:%d:%d:%d", + pR128->PciInfo->bus, + pR128->PciInfo->device, + pR128->PciInfo->func); + pDRIInfo->ddxDriverMajorVersion = R128_VERSION_MAJOR; + pDRIInfo->ddxDriverMinorVersion = R128_VERSION_MINOR; + pDRIInfo->ddxDriverPatchVersion = R128_VERSION_PATCH; + pDRIInfo->frameBufferPhysicalAddress = pR128->LinearAddr; + pDRIInfo->frameBufferSize = pR128->FbMapSize; + pDRIInfo->frameBufferStride = (pScrn->displayWidth + * pR128->pixel_bytes); + pDRIInfo->ddxDrawableTableEntry = R128_MAX_DRAWABLES; + pDRIInfo->maxDrawableTableEntry = (SAREA_MAX_DRAWABLES + < R128_MAX_DRAWABLES + ? SAREA_MAX_DRAWABLES + : R128_MAX_DRAWABLES); + +#ifdef NOT_DONE + /* FIXME: Need to extend DRI protocol to pass this size back to + * client for SAREA mapping that includes a device private record + */ + pDRIInfo->SAREASize = + ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */ + /* + shared memory device private rec */ +#else + /* For now the mapping works by using a fixed size defined + * in the SAREA header + */ + if (sizeof(XF86DRISAREARec)+sizeof(R128SAREAPriv)>SAREA_MAX) { + ErrorF("Data does not fit in SAREA\n"); + return FALSE; + } + pDRIInfo->SAREASize = SAREA_MAX; +#endif + + if (!(pR128DRI = (R128DRIPtr)xnfcalloc(sizeof(R128DRIRec),1))) { + DRIDestroyInfoRec(pR128->pDRIInfo); + pR128->pDRIInfo = NULL; + return FALSE; + } + pDRIInfo->devPrivate = pR128DRI; + pDRIInfo->devPrivateSize = sizeof(R128DRIRec); + pDRIInfo->contextSize = sizeof(R128DRIContextRec); + + pDRIInfo->CreateContext = R128CreateContext; + pDRIInfo->DestroyContext = R128DestroyContext; + pDRIInfo->SwapContext = R128DRISwapContext; + pDRIInfo->InitBuffers = R128DRIInitBuffers; + pDRIInfo->MoveBuffers = R128DRIMoveBuffers; + pDRIInfo->bufferRequests = DRI_ALL_WINDOWS; + + if (!DRIScreenInit(pScreen, pDRIInfo, &pR128->drmFD)) { + xfree(pDRIInfo->devPrivate); + pDRIInfo->devPrivate = NULL; + DRIDestroyInfoRec(pDRIInfo); + pDRIInfo = NULL; + return FALSE; + } + + /* Check the r128 DRM version */ + version = drmGetVersion(pR128->drmFD); + if (version) { + if (version->version_major != 1 || + version->version_minor != 0 || + version->version_patchlevel < 0) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, + "R128DRIScreenInit failed " + "(DRM version = %d.%d.%d, expected 1.0.x). " + "Disabling DRI.\n", + version->version_major, + version->version_minor, + version->version_patchlevel); + drmFreeVersion(version); + R128DRICloseScreen(pScreen); + return FALSE; + } + drmFreeVersion(version); + } + + /* Initialize AGP */ + if (!pR128->IsPCI && !R128DRIAgpInit(pR128, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* DRIScreenInit doesn't add all the + common mappings. Add additional + mappings here. */ + if (!R128DRIMapInit(pR128, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize the ring buffer */ + if (!pR128->IsPCI) R128DRICCEInitRingBuffer(pScrn); + + /* Initialize the kernel data structures */ + if (!R128DRIKernelInit(pR128, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* Initialize vertex buffers list */ + if (!pR128->IsPCI && !R128DRIBufInit(pR128, pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + + /* FIXME: When are these mappings unmapped? */ + + if (!R128InitVisualConfigs(pScreen)) { + R128DRICloseScreen(pScreen); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Visual configs initialized\n"); + + /* Load the CCE Microcode */ + R128DRILoadMicrocode(pScrn); + + /* Reset the Graphics Engine */ + R128EngineReset(pScrn); + + return TRUE; +} + +/* Finish initializing the device-dependent DRI state, and call + DRIFinishScreenInit() to complete the device-independent DRI + initialization. */ +Bool R128DRIFinishScreenInit(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr pR128 = R128PTR(pScrn); + R128SAREAPrivPtr pSAREAPriv; + R128DRIPtr pR128DRI; + + /* Init and start the CCE */ + R128DRICCEInit(pScrn); + + pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen); + memset(pSAREAPriv, 0, sizeof(*pSAREAPriv)); + + pR128->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT; + /* pR128->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */ + + pR128DRI = (R128DRIPtr)pR128->pDRIInfo->devPrivate; + pR128DRI->registerHandle = pR128->registerHandle; + pR128DRI->registerSize = pR128->registerSize; + + pR128DRI->ringHandle = pR128->ringHandle; + pR128DRI->ringMapSize = pR128->ringMapSize; + pR128DRI->ringSize = pR128->ringSize*1024*1024; + + pR128DRI->ringReadPtrHandle = pR128->ringReadPtrHandle; + pR128DRI->ringReadMapSize = pR128->ringReadMapSize; + + pR128DRI->vbHandle = pR128->vbHandle; + pR128DRI->vbMapSize = pR128->vbMapSize; + pR128DRI->vbOffset = pR128->vbStart; + pR128DRI->vbBufSize = pR128->vbBufSize; + + pR128DRI->indHandle = pR128->indHandle; + pR128DRI->indMapSize = pR128->indMapSize; + + pR128DRI->agpTexHandle = pR128->agpTexHandle; + pR128DRI->agpTexMapSize = pR128->agpTexMapSize; + pR128DRI->log2AGPTexGran = pR128->log2AGPTexGran; + pR128DRI->agpTexOffset = pR128->agpTexStart; + + pR128DRI->deviceID = pR128->Chipset; + pR128DRI->width = pScrn->virtualX; + pR128DRI->height = pScrn->virtualY; + pR128DRI->depth = pScrn->depth; + pR128DRI->bpp = pScrn->bitsPerPixel; + + pR128DRI->fbX = pR128->fbX; + pR128DRI->fbY = pR128->fbY; + pR128DRI->backX = pR128->backX; + pR128DRI->backY = pR128->backY; + pR128DRI->depthX = pR128->depthX; + pR128DRI->depthY = pR128->depthY; + pR128DRI->textureX = pR128->textureX; + pR128DRI->textureY = pR128->textureY; + pR128DRI->textureSize = pR128->textureSize; + pR128DRI->log2TexGran = pR128->log2TexGran; + + pR128DRI->IsPCI = pR128->IsPCI; + + pR128DRI->CCEMode = pR128->CCEMode; + pR128DRI->CCEFifoSize = pR128->CCEFifoSize; + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "0x%08lx %d\n", + pR128DRI->registerHandle, pR128DRI->registerSize); + return DRIFinishScreenInit(pScreen); +} + +/* The screen is being closed, so clean up any state and free any + resources used by the DRI. */ +void R128DRICloseScreen(ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + R128InfoPtr pR128 = R128PTR(pScrn); + + /* Stop the CCE if it is still in use */ + if (pR128->CCE2D) R128CCEStop(pScrn); + + /* De-allocate vertex buffers */ + if (pR128->vbBufs) { + drmUnmapBufs(pR128->vbBufs); + pR128->vbBufs = NULL; + } + + /* De-allocate all kernel resources */ + drmR128CleanupCCE(pR128->drmFD); + + /* De-allocate all AGP resources */ + if (pR128->agpTex) { + drmUnmap(pR128->agpTex, pR128->agpTexMapSize); + pR128->agpTex = NULL; + } + if (pR128->ind) { + drmUnmap(pR128->ind, pR128->indMapSize); + pR128->ind = NULL; + } + if (pR128->vb) { + drmUnmap(pR128->vb, pR128->vbMapSize); + pR128->vb = NULL; + } + if (pR128->ringReadPtr) { + drmUnmap(pR128->ringReadPtr, pR128->ringReadMapSize); + pR128->ringReadPtr = NULL; + } + if (pR128->ring) { + drmUnmap(pR128->ring, pR128->ringMapSize); + pR128->ring = NULL; + } + if (pR128->agpMemHandle) { + drmAgpUnbind(pR128->drmFD, pR128->agpMemHandle); + drmAgpFree(pR128->drmFD, pR128->agpMemHandle); + pR128->agpMemHandle = 0; + drmAgpRelease(pR128->drmFD); + } + + /* De-allocate all DRI resources */ + DRICloseScreen(pScreen); + + /* De-allocate all DRI data structures */ + if (pR128->pDRIInfo) { + if (pR128->pDRIInfo->devPrivate) { + xfree(pR128->pDRIInfo->devPrivate); + pR128->pDRIInfo->devPrivate = NULL; + } + DRIDestroyInfoRec(pR128->pDRIInfo); + pR128->pDRIInfo = NULL; + } + if (pR128->pVisualConfigs) { + xfree(pR128->pVisualConfigs); + pR128->pVisualConfigs = NULL; + } + if (pR128->pVisualConfigsPriv) { + xfree(pR128->pVisualConfigsPriv); + pR128->pVisualConfigsPriv = NULL; + } +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c index b5da4cb6e..ea0742a99 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c @@ -1,8 +1,8 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.26 2000/03/06 23:17:44 martin Exp $ */ /************************************************************************** -Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. +Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -107,6 +107,19 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* VESA support */ #include "vbe.h" + /* DRI support */ +#ifdef XF86DRI +#include "GL/glxint.h" +#include "xf86drm.h" +#include "sarea.h" +#define _XF86DRI_SERVER_ +#include "xf86dri.h" +#include "dri.h" +#include "r128_dri.h" +#include "r128_dripriv.h" +#include "r128_sarea.h" +#endif + /* Driver data structures */ #include "r128.h" #include "r128_reg.h" @@ -158,6 +171,8 @@ static SymTabRec R128Chipsets[] = { { PCI_CHIP_RAGE128RK, "ATI Rage 128 RK (PCI)" }, { PCI_CHIP_RAGE128RL, "ATI Rage 128 RL (AGP)" }, { PCI_CHIP_RAGE128PF, "ATI Rage 128 Pro PF (AGP)" }, + { PCI_CHIP_RAGE128LE, "ATI Rage 128 Mobility LE (PCI)" }, + { PCI_CHIP_RAGE128LF, "ATI Rage 128 Mobility LF (AGP)" }, { -1, NULL } }; @@ -167,6 +182,8 @@ static PciChipsets R128PciChipsets[] = { { PCI_CHIP_RAGE128RK, PCI_CHIP_RAGE128RK, RES_SHARED_VGA }, { PCI_CHIP_RAGE128RL, PCI_CHIP_RAGE128RL, RES_SHARED_VGA }, { PCI_CHIP_RAGE128PF, PCI_CHIP_RAGE128PF, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128LE, PCI_CHIP_RAGE128LE, RES_SHARED_VGA }, + { PCI_CHIP_RAGE128LF, PCI_CHIP_RAGE128LF, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } }; @@ -176,17 +193,45 @@ typedef enum { OPTION_HW_CURSOR, OPTION_DAC_6BIT, OPTION_DAC_8BIT, +#ifdef XF86DRI + OPTION_IS_PCI, + OPTION_CCE_PIO, + OPTION_NO_SECURITY, + OPTION_USEC_TIMEOUT, + OPTION_AGP_MODE, + OPTION_AGP_SIZE, + OPTION_RING_SIZE, + OPTION_VERT_SIZE, + OPTION_VBUF_SIZE, + OPTION_USE_CCE_2D, +#endif + OPTION_ENABLE_FP, + OPTION_CRT, OPTION_FBDEV } R128Opts; static OptionInfoRec R128Options[] = { - { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, TRUE }, - { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE }, - { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, - { -1, NULL, OPTV_NONE, {0}, FALSE } + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, TRUE }, + { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE }, +#ifdef XF86DRI + { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CCE_PIO, "CCEPIOMode", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NO_SECURITY, "CCENoSecurity", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_USEC_TIMEOUT, "CCEusecTimeout", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE }, + { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_VERT_SIZE, "VBListSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_VBUF_SIZE, "VBSize", OPTV_INTEGER, {0}, FALSE }, + { OPTION_USE_CCE_2D, "UseCCEfor2D", OPTV_BOOLEAN, {0}, FALSE }, +#endif + { OPTION_ENABLE_FP, "EnableFP", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_CRT, "CRTOnly", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } }; R128RAMRec R128RAM[] = { /* Memory Specifications @@ -299,6 +344,38 @@ static const char *ramdacSymbols[] = { NULL }; +#ifdef XF86DRI +static const char *drmSymbols[] = { + "drmAddBufs", + "drmAddMap", + "drmAvailable", + "drmCtlAddCommand", + "drmCtlInstHandler", + "drmGetInterruptFromBusID", + "drmMapBufs", + "drmMarkBufs", + "drmUnmapBufs", + NULL +}; + +static const char *driSymbols[] = { + "DRIGetDrawableIndex", + "DRIFinishScreenInit", + "DRIDestroyInfoRec", + "DRICloseScreen", + "DRIDestroyInfoRec", + "DRIScreenInit", + "DRIDestroyInfoRec", + "DRICreateInfoRec", + "DRILock", + "DRIUnlock", + "DRIGetSAREAPrivate", + "DRIGetContext", + "GlxSetVisualConfigs", + NULL +}; +#endif + static MODULESETUPPROTO(R128Setup); static XF86ModuleVersionInfo R128VersRec = @@ -347,6 +424,10 @@ static pointer R128Setup(pointer module, pointer opts, int *errmaj, xaaSymbols, xf8_32bppSymbols, ramdacSymbols, +#ifdef XF86DRI + drmSymbols, + driSymbols, +#endif fbdevHWSymbols, vbeSymbols, 0 /* ddcsymbols */, @@ -518,7 +599,7 @@ static void R128Unblank(ScrnInfoPtr pScrn) } /* Compute log base 2 of val. */ -static int R128MinBits(int val) +int R128MinBits(int val) { int bits; @@ -779,6 +860,10 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) int offset = 0; /* RAM Type */ MessageType from; unsigned char *R128MMIO; + CARD32 fp_horz_stretch = 0, fp_vert_stretch = 0; + CARD32 crtc_h_total_disp = 0, crtc_v_total_disp = 0; + CARD32 crtc_h_sync_strt_wid = 0, crtc_v_sync_strt_wid = 0; + /* Chipset */ from = X_PROBED; if (dev->chipset && *dev->chipset) { @@ -861,22 +946,47 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) "BIOS at 0x%08lx\n", info->BIOSAddr); } - /* RAM */ - from = X_PROBED; + /* Flat panel (part 1) */ + /* FIXME: Make this an option */ + switch (info->Chipset) { + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128LF: info->HasPanelRegs = TRUE; break; + case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128RF: + case PCI_CHIP_RAGE128RK: + case PCI_CHIP_RAGE128RL: + case PCI_CHIP_RAGE128PF: + default: info->HasPanelRegs = FALSE; break; + } + + /* Read registers used to determine options */ + from = X_PROBED; R128MapMMIO(pScrn); - R128MMIO = info->MMIO; + R128MMIO = info->MMIO; if (info->FBDev) - pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024; + pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024; else - pScrn->videoRam = INREG(R128_CONFIG_MEMSIZE) / 1024; - info->MemCntl = INREG(R128_MEM_CNTL); - info->BusCntl = INREG(R128_BUS_CNTL); - R128MMIO = NULL; + pScrn->videoRam = INREG(R128_CONFIG_MEMSIZE) / 1024; + info->MemCntl = INREG(R128_MEM_CNTL); + info->BusCntl = INREG(R128_BUS_CNTL); + if (info->HasPanelRegs) { + fp_horz_stretch = INREG(R128_FP_HORZ_STRETCH); + fp_vert_stretch = INREG(R128_FP_VERT_STRETCH); + crtc_h_total_disp = INREG(R128_CRTC_H_TOTAL_DISP); + crtc_v_total_disp = INREG(R128_CRTC_V_TOTAL_DISP); + crtc_h_sync_strt_wid = INREG(R128_CRTC_H_SYNC_STRT_WID); + crtc_v_sync_strt_wid = INREG(R128_CRTC_V_SYNC_STRT_WID); + } + R128MMIO = NULL; R128UnmapMMIO(pScrn); + + /* RAM */ switch (info->MemCntl & 0x3) { case 0: /* SDR SGRAM 1:1 */ switch (info->Chipset) { - case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128LF: + case PCI_CHIP_RAGE128RE: case PCI_CHIP_RAGE128RF: offset = 0; break; /* 128-bit SDR SGRAM 1:1 */ case PCI_CHIP_RAGE128RK: case PCI_CHIP_RAGE128RL: @@ -895,12 +1005,97 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn) pScrn->videoRam); from = X_CONFIG; pScrn->videoRam = dev->videoRam; - } + } pScrn->videoRam &= ~1023; info->FbMapSize = pScrn->videoRam * 1024; xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte (%s)\n", pScrn->videoRam, info->ram->name); + /* Flat panel (part 2) */ + if ((info->EnableFP = xf86ReturnOptValBool(R128Options, + OPTION_ENABLE_FP, FALSE))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Enabling use of flat panel registers\n"); + if ((info->CRTOnly = xf86ReturnOptValBool(R128Options, + OPTION_CRT, FALSE))) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using external CRT instead of " + "flat panel for display\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Using flat panel for display\n"); + } + } + + if (info->HasPanelRegs) { + int tmp; + + info->PanelXRes = + (fp_horz_stretch & R128_HORZ_PANEL_SIZE) >> R128_HORZ_PANEL_SHIFT; + info->PanelXRes = (info->PanelXRes + 1) * 8; + info->PanelYRes = + (fp_vert_stretch & R128_VERT_PANEL_SIZE) >> R128_VERT_PANEL_SHIFT; + info->PanelYRes += 1; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel dimensions: %dx%d\n", + info->PanelXRes, info->PanelYRes); + + info->PanelHNonVis = + (crtc_h_total_disp & R128_CRTC_H_TOTAL) >> R128_CRTC_H_TOTAL_SHIFT; + info->PanelHNonVis += 4; /* Add 4 since we are in VGA mode */ + tmp = + (crtc_h_total_disp & R128_CRTC_H_DISP) >> R128_CRTC_H_DISP_SHIFT; + info->PanelHNonVis -= tmp; + info->PanelHOverPlus = + (crtc_h_sync_strt_wid & R128_CRTC_H_SYNC_STRT_CHAR) + >> R128_CRTC_H_SYNC_STRT_CHAR_SHIFT; + info->PanelHOverPlus -= tmp; + switch (info->pixel_code) { /* Adjustments are from ATI */ + case 8: info->PanelHOverPlus += 2; break; + case 15: + case 16: info->PanelHOverPlus += 1; break; + case 24: + case 32: info->PanelHOverPlus += 0; break; + } + info->PanelHSyncWidth = + (crtc_h_sync_strt_wid & R128_CRTC_H_SYNC_WID) + >> R128_CRTC_H_SYNC_WID_SHIFT; + info->PanelHSyncWidth += 14; /* ??? */ + + info->PanelVNonVis = + (crtc_v_total_disp & R128_CRTC_V_TOTAL) >> R128_CRTC_V_TOTAL_SHIFT; + info->PanelVNonVis += 1; /* Add 1 since we are in VGA mode */ + tmp = + (crtc_v_total_disp & R128_CRTC_V_DISP) >> R128_CRTC_V_DISP_SHIFT; + info->PanelVNonVis -= tmp; + info->PanelVOverPlus = + (crtc_v_sync_strt_wid & R128_CRTC_V_SYNC_STRT) + >> R128_CRTC_V_SYNC_STRT_SHIFT; + info->PanelVOverPlus -= tmp + 1; + info->PanelVSyncWidth = + (crtc_v_sync_strt_wid & R128_CRTC_V_SYNC_WID) + >> R128_CRTC_V_SYNC_WID_SHIFT; + info->PanelVSyncWidth -= 2; /* ??? */ + } + +#ifdef XF86DRI + /* AGP/PCI */ + if (xf86ReturnOptValBool(R128Options, OPTION_IS_PCI, FALSE)) { + info->IsPCI = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n"); + } else { + switch (info->Chipset) { + case PCI_CHIP_RAGE128LE: + case PCI_CHIP_RAGE128RE: + case PCI_CHIP_RAGE128RK: info->IsPCI = TRUE; break; + case PCI_CHIP_RAGE128LF: + case PCI_CHIP_RAGE128RF: + case PCI_CHIP_RAGE128RL: + case PCI_CHIP_RAGE128PF: + default: info->IsPCI = FALSE; break; + } + } +#endif + return TRUE; } @@ -1053,6 +1248,143 @@ static Bool R128PreInitInt10(ScrnInfoPtr pScrn) return TRUE; } +#ifdef XF86DRI +static Bool R128PreInitDRI(ScrnInfoPtr pScrn) +{ + R128InfoPtr info = R128PTR(pScrn); + + if (info->IsPCI) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in PIO mode\n"); + info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; + } else if (xf86ReturnOptValBool(R128Options, OPTION_CCE_PIO, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in PIO mode\n"); + info->CCEMode = R128_DEFAULT_CCE_PIO_MODE; + } else { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in BM mode\n"); + info->CCEMode = R128_DEFAULT_CCE_BM_MODE; + } + + if (xf86ReturnOptValBool(R128Options, OPTION_USE_CCE_2D, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using CCE for 2D\n"); + info->CCE2D = TRUE; + } else { + info->CCE2D = FALSE; + } + + if (xf86ReturnOptValBool(R128Options, OPTION_NO_SECURITY, FALSE)) { + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "WARNING!!! CCE Security checks disabled!!! **********\n"); + info->CCESecure = FALSE; + } else { + info->CCESecure = TRUE; + } + + info->agpMode = R128_DEFAULT_AGP_MODE; + info->agpSize = R128_DEFAULT_AGP_SIZE; + info->ringSize = R128_DEFAULT_RING_SIZE; + info->vbSize = R128_DEFAULT_VB_SIZE; + info->indSize = R128_DEFAULT_IND_SIZE; + info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE; + + info->vbBufSize = R128_DEFAULT_VB_BUF_SIZE; + + info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT; + + if (!info->IsPCI) { + if (xf86GetOptValInteger(R128Options, + OPTION_AGP_MODE, &(info->agpMode))) { + if (info->agpMode < 1 || info->agpMode > R128_AGP_MAX_MODE) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP Mode: %d\n", info->agpMode); + return FALSE; + } + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using AGP %dx mode\n", info->agpMode); + } + + if (xf86GetOptValInteger(R128Options, + OPTION_AGP_SIZE, (int *)&(info->agpSize))) { + switch (info->agpSize) { + case 4: + case 8: + case 16: + case 32: + case 64: + case 128: + case 256: + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal AGP size: %d MB\n", info->agpSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(R128Options, + OPTION_RING_SIZE, &(info->ringSize))) { + if (info->ringSize < 1 || info->ringSize >= info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal ring buffer size: %d MB\n", + info->ringSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(R128Options, + OPTION_VERT_SIZE, &(info->vbSize))) { + if (info->vbSize < 1 || info->vbSize >= info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal vertex buffers list size: %d MB\n", + info->vbSize); + return FALSE; + } + } + + if (xf86GetOptValInteger(R128Options, + OPTION_VBUF_SIZE, &(info->vbBufSize))) { + int numBufs = info->vbSize*1024*1024/info->vbBufSize; + if (numBufs < 2 || numBufs > 512) { /* FIXME: 512 is arbitrary */ + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Illegal individual vertex buffer size: %d bytes\n", + info->vbBufSize); + return FALSE; + } + } + + if (info->ringSize + info->vbSize + info->indSize + info->agpTexSize > + info->agpSize) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Buffers are too big for requested AGP space\n"); + return FALSE; + } + + info->agpTexSize = info->agpSize - (info->ringSize + + info->vbSize + + info->indSize); + + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using %d MB AGP aperture\n", info->agpSize); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using %d MB for the ring buffer\n", info->ringSize); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using %d MB for vertex buffers\n", info->vbSize); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using %d MB for indirect buffers\n", info->indSize); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using %d MB for AGP textures\n", info->agpTexSize); + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, + "Using %d byte vertex buffers\n", info->vbBufSize); + } + + if (xf86GetOptValInteger(R128Options, OPTION_USEC_TIMEOUT, + &(info->CCEusecTimeout))) { + /* This option checked by the R128 DRM kernel module */ + } + + return TRUE; +} +#endif + extern xf86MonPtr ConfiguredMonitor; static void @@ -1152,6 +1484,10 @@ static Bool R128PreInit(ScrnInfoPtr pScrn, int flags) if (!R128PreInitAccel(pScrn)) goto fail; +#ifdef XF86DRI + if (!R128PreInitDRI(pScrn)) goto fail; +#endif + return TRUE; fail: @@ -1231,9 +1567,20 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset)); +#ifdef XF86DRI + /* Turn off the CCE for now. */ + info->CCEInUse = FALSE; +#endif + if (!R128MapMem(pScrn)) return FALSE; pScrn->fbOffset = 0; - +#ifdef XF86DRI + info->fbX = 0; + info->fbY = 0; +#endif + + info->PaletteSavedOnVT = FALSE; + R128Save(pScrn); if (info->FBDev) { if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE; @@ -1251,6 +1598,18 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; +#ifdef XF86DRI + /* Setup DRI after visuals have been + established, but before cfbScreenInit is + called. cfbScreenInit will eventually + call the driver's InitGLXVisuals call + back. */ + if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) + info->directRenderingEnabled = R128DRIScreenInit(pScreen); + else + info->directRenderingEnabled = FALSE; +#endif + #ifdef USE_FB if (!fbScreenInit (pScreen, info->FB, pScrn->virtualX, pScrn->virtualY, @@ -1358,6 +1717,101 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, } } +#ifdef XF86DRI + /* Allocate frame buffer space for the + shared back and depth buffers as well + as for local textures. */ + if (info->directRenderingEnabled) { + FBAreaPtr fbarea; + int width_bytes = pScrn->displayWidth * info->pixel_bytes; + int maxy = info->FbMapSize / width_bytes; + int l; + + /* Allocate the shared back buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved back buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->backX = fbarea->box.x1; + info->backY = fbarea->box.y1; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n"); + info->backX = -1; + info->backY = -1; + } + + /* Allocate the shared depth buffer */ + if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY, + 32, NULL, NULL, NULL))) { + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved depth buffer from (%d,%d) to (%d,%d)\n", + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + + info->depthX = fbarea->box.x1; + info->depthY = fbarea->box.y1; + } else { + xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n"); + info->depthX = -1; + info->depthY = -1; + } + + /* Allocate local texture space */ + if (((maxy - MemBox.y2 - 1) * width_bytes) > + (pScrn->virtualX * pScrn->virtualY * 2 * info->pixel_bytes)) { + info->textureX = 0; + info->textureY = MemBox.y2 + 1; + info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes; + + l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS); + if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; + + info->log2TexGran = l; + info->textureSize = (info->textureSize >> l) << l; + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", + info->textureSize/1024, + info->textureX, info->textureY, + pScrn->displayWidth, maxy); + } else if ((fbarea = xf86AllocateOffscreenArea(pScreen, + pScrn->virtualX, + pScrn->virtualY * 2, + 32, + NULL, NULL, NULL))) { + info->textureX = fbarea->box.x1; + info->textureY = fbarea->box.y1; + info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) * + (fbarea->box.x2 - fbarea->box.x1) * + info->pixel_bytes); + + l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS); + if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY; + + info->log2TexGran = l; + info->textureSize = (info->textureSize >> l) << l; + + xf86DrvMsg(scrnIndex, X_INFO, + "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n", + info->textureSize/1024, + fbarea->box.x1, fbarea->box.y1, + fbarea->box.x2, fbarea->box.y2); + } else { + xf86DrvMsg(scrnIndex, X_ERROR, + "Unable to reserve texture space in frame buffer\n"); + info->textureX = -1; + info->textureY = -1; + } + } +#endif + /* Backing store setup */ miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); @@ -1453,6 +1907,21 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, if (serverGeneration == 1) xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); +#ifdef XF86DRI + /* DRI finalization */ + if (info->directRenderingEnabled) { + /* Now that mi, cfb, drm and others have + done their thing, complete the DRI + setup. */ + info->directRenderingEnabled = R128DRIFinishScreenInit(pScreen); + } + if (info->directRenderingEnabled) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n"); + } else { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n"); + } +#endif + return TRUE; } @@ -1473,7 +1942,7 @@ static void R128RestoreCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) OUTREG(R128_GEN_INT_CNTL, restore->gen_int_cntl); OUTREG(R128_CAP0_TRIG_CNTL, restore->cap0_trig_cntl); OUTREG(R128_CAP1_TRIG_CNTL, restore->cap1_trig_cntl); - OUTREG(R128_BUS_CNTL, restore->bus_cntl); + OUTREG(R128_BUS_CNTL, restore->bus_cntl); } /* Write CRTC registers. */ @@ -1498,6 +1967,24 @@ static void R128RestoreCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) OUTREG(R128_CRTC_PITCH, restore->crtc_pitch); } +/* Write flat panel registers */ +static void R128RestoreFPRegisters(ScrnInfoPtr pScrn, R128SavePtr restore) +{ + R128MMIO_VARS(); + + OUTREG(R128_CRTC2_GEN_CNTL, restore->crtc2_gen_cntl); + OUTREG(R128_FP_CRTC_H_TOTAL_DISP, restore->fp_crtc_h_total_disp); + OUTREG(R128_FP_CRTC_V_TOTAL_DISP, restore->fp_crtc_v_total_disp); + OUTREG(R128_FP_GEN_CNTL, restore->fp_gen_cntl); + OUTREG(R128_FP_H_SYNC_STRT_WID, restore->fp_h_sync_strt_wid); + OUTREG(R128_FP_HORZ_STRETCH, restore->fp_horz_stretch); + OUTREG(R128_FP_PANEL_CNTL, restore->fp_panel_cntl); + OUTREG(R128_FP_V_SYNC_STRT_WID, restore->fp_v_sync_strt_wid); + OUTREG(R128_FP_VERT_STRETCH, restore->fp_vert_stretch); + OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl); + OUTREG(R128_TMDS_CRC, restore->tmds_crc); +} + static void R128PLLWaitForReadUpdateComplete(ScrnInfoPtr pScrn) { while (INPLL(pScrn, R128_PPLL_REF_DIV) & R128_PPLL_ATOMIC_UPDATE_R); @@ -1581,6 +2068,8 @@ static void R128RestoreMode(ScrnInfoPtr pScrn, R128SavePtr restore) R128TRACE(("R128RestoreMode(%p)\n", restore)); R128RestoreCommonRegisters(pScrn, restore); R128RestoreCrtcRegisters(pScrn, restore); + if (R128PTR(pScrn)->HasPanelRegs && R128PTR(pScrn)->EnableFP) + R128RestoreFPRegisters(pScrn, restore); R128RestorePLLRegisters(pScrn, restore); R128RestoreDDARegisters(pScrn, restore); R128RestorePalette(pScrn, restore); @@ -1603,7 +2092,7 @@ static void R128SaveCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr save) save->gen_int_cntl = INREG(R128_GEN_INT_CNTL); save->cap0_trig_cntl = INREG(R128_CAP0_TRIG_CNTL); save->cap1_trig_cntl = INREG(R128_CAP1_TRIG_CNTL); - save->bus_cntl = INREG(R128_BUS_CNTL); + save->bus_cntl = INREG(R128_BUS_CNTL); } /* Read CRTC registers. */ @@ -1623,6 +2112,24 @@ static void R128SaveCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save) save->crtc_pitch = INREG(R128_CRTC_PITCH); } +/* Read flat panel registers */ +static void R128SaveFPRegisters(ScrnInfoPtr pScrn, R128SavePtr save) +{ + R128MMIO_VARS(); + + save->crtc2_gen_cntl = INREG(R128_CRTC2_GEN_CNTL); + save->fp_crtc_h_total_disp = INREG(R128_FP_CRTC_H_TOTAL_DISP); + save->fp_crtc_v_total_disp = INREG(R128_FP_CRTC_V_TOTAL_DISP); + save->fp_gen_cntl = INREG(R128_FP_GEN_CNTL); + save->fp_h_sync_strt_wid = INREG(R128_FP_H_SYNC_STRT_WID); + save->fp_horz_stretch = INREG(R128_FP_HORZ_STRETCH); + save->fp_panel_cntl = INREG(R128_FP_PANEL_CNTL); + save->fp_v_sync_strt_wid = INREG(R128_FP_V_SYNC_STRT_WID); + save->fp_vert_stretch = INREG(R128_FP_VERT_STRETCH); + save->lvds_gen_cntl = INREG(R128_LVDS_GEN_CNTL); + save->tmds_crc = INREG(R128_TMDS_CRC); +} + /* Read PLL registers. */ static void R128SavePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save) { @@ -1667,6 +2174,8 @@ static void R128SaveMode(ScrnInfoPtr pScrn, R128SavePtr save) R128SaveCommonRegisters(pScrn, save); R128SaveCrtcRegisters(pScrn, save); + if (R128PTR(pScrn)->HasPanelRegs && R128PTR(pScrn)->EnableFP) + R128SaveFPRegisters(pScrn, save); R128SavePLLRegisters(pScrn, save); R128SaveDDARegisters(pScrn, save); R128SavePalette(pScrn, save); @@ -1841,6 +2350,127 @@ static Bool R128InitCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save, return TRUE; } +/* Define CRTC registers for requested video mode. */ +static void R128InitFPRegisters(ScrnInfoPtr pScrn, R128SavePtr orig, + R128SavePtr save, DisplayModePtr mode, + R128InfoPtr info) +{ + int xres = mode->CrtcHDisplay; + int yres = mode->CrtcVDisplay; + float Hratio, Vratio; + int disp_end; + + if (info->CRTOnly) { + save->crtc_ext_cntl |= R128_CRTC_CRT_ON; + save->crtc2_gen_cntl = 0; + save->fp_gen_cntl = orig->fp_gen_cntl; + save->fp_gen_cntl &= ~(R128_FP_FPON | + R128_FP_CRTC_USE_SHADOW_VEND | + R128_FP_CRTC_HORZ_DIV2_EN | + R128_FP_CRTC_HOR_CRT_DIV2_DIS | + R128_FP_USE_SHADOW_EN); + save->fp_gen_cntl |= (R128_FP_SEL_CRTC2 | + R128_FP_CRTC_DONT_SHADOW_VPAR); + save->fp_panel_cntl = orig->fp_panel_cntl & ~R128_FP_DIGON; + save->lvds_gen_cntl = orig->lvds_gen_cntl & ~R128_LVDS_ON; + return; + } + + if (xres > info->PanelXRes) xres = info->PanelXRes; + if (yres > info->PanelYRes) yres = info->PanelYRes; + + Hratio = (float)xres/(float)info->PanelXRes; + Vratio = (float)yres/(float)info->PanelYRes; + + save->fp_horz_stretch = + (((((int)(Hratio * R128_HORZ_STRETCH_RATIO_MAX)) + & R128_HORZ_STRETCH_RATIO_MASK) << R128_HORZ_STRETCH_RATIO_SHIFT) | + (orig->fp_horz_stretch & (R128_HORZ_PANEL_SIZE | + R128_HORZ_FP_LOOP_STRETCH | + R128_HORZ_STRETCH_RESERVED))); + if (Hratio != 1.0) save->fp_horz_stretch |= (R128_HORZ_STRETCH_BLEND | + R128_HORZ_STRETCH_ENABLE); + + save->fp_vert_stretch = + (((((int)(Vratio * R128_VERT_STRETCH_RATIO_MAX)) + & R128_VERT_STRETCH_RATIO_MASK) << R128_VERT_STRETCH_RATIO_SHIFT) | + (orig->fp_vert_stretch & (R128_VERT_PANEL_SIZE | + R128_VERT_STRETCH_RESERVED | + R128_VERT_STRETCH_BLEND))); + if (Vratio == 1.0) save->fp_vert_stretch &= ~R128_VERT_STRETCH_ENABLE; + else save->fp_vert_stretch |= R128_VERT_STRETCH_ENABLE; + + save->fp_gen_cntl = ((orig->fp_gen_cntl & ~(R128_FP_SEL_CRTC2 | + R128_FP_CRTC_USE_SHADOW_VEND | + R128_FP_CRTC_HORZ_DIV2_EN | + R128_FP_CRTC_HOR_CRT_DIV2_DIS | + R128_FP_USE_SHADOW_EN)) | + R128_FP_CRTC_DONT_SHADOW_VPAR | + R128_FP_TDMS_EN); + save->fp_panel_cntl = orig->fp_panel_cntl; + save->fp_crtc_h_total_disp = orig->fp_crtc_h_total_disp; + save->fp_crtc_v_total_disp = orig->fp_crtc_v_total_disp; + save->fp_h_sync_strt_wid = orig->fp_h_sync_strt_wid; + save->fp_v_sync_strt_wid = orig->fp_v_sync_strt_wid; + save->lvds_gen_cntl = orig->lvds_gen_cntl; + + save->tmds_crc = orig->tmds_crc; + + /* Disable CRT output by disabling CRT output and setting the CRT + DAC to use CRTC2, which we set to 0's. In the future, we will + want to use the dual CRTC capabilities of the R128 to allow both + the flat panel and external CRT to either simultaneously display + the same image or display two different images. */ + save->crtc_ext_cntl &= ~R128_CRTC_CRT_ON; + save->dac_cntl |= R128_DAC_CRT_SEL_CRTC2; + save->crtc2_gen_cntl = 0; + + save->fp_panel_cntl |= (R128_FP_DIGON | R128_FP_BLON); + save->fp_gen_cntl |= (R128_FP_FPON); + + save->crtc_gen_cntl &= ~(R128_CRTC_DBL_SCAN_EN | + R128_CRTC_INTERLACE_EN | + R128_CRTC_CSYNC_EN | + R128_CRTC_CUR_EN | + R128_CRTC_CUR_MODE_MASK | + R128_CRTC_ICON_EN | + R128_CRTC_EXT_DISP_EN | + R128_CRTC_EN | + R128_CRTC_DISP_REQ_EN_B); + save->crtc_gen_cntl |= R128_CRTC_EXT_DISP_EN | R128_CRTC_EN; + + disp_end = xres/8 - 1; + save->crtc_h_total_disp = ((disp_end << R128_CRTC_H_DISP_SHIFT) | + (disp_end + info->PanelHNonVis)); + + save->crtc_h_sync_strt_wid &= ~(R128_CRTC_H_SYNC_STRT_PIX | + R128_CRTC_H_SYNC_STRT_CHAR | + R128_CRTC_H_SYNC_WID); + save->crtc_h_sync_strt_wid |= + (disp_end + info->PanelHOverPlus) << R128_CRTC_H_SYNC_STRT_CHAR_SHIFT; + switch (info->pixel_code) { /* Adjustments are from ATI */ + case 8: save->crtc_h_sync_strt_wid |= 2; break; + case 15: + case 16: save->crtc_h_sync_strt_wid |= 1; break; + case 24: save->crtc_h_sync_strt_wid |= 6; break; + case 32: save->crtc_h_sync_strt_wid |= 5; break; + } + save->crtc_h_sync_strt_wid |= + info->PanelHSyncWidth << R128_CRTC_H_SYNC_WID_SHIFT; + save->crtc_h_sync_strt_wid |= R128_CRTC_H_SYNC_POL; + + disp_end = yres - 1; + save->crtc_v_total_disp = ((disp_end << R128_CRTC_V_DISP_SHIFT) | + (disp_end + info->PanelVNonVis)); + + save->crtc_v_sync_strt_wid &= ~(R128_CRTC_V_SYNC_STRT | + R128_CRTC_V_SYNC_WID); + save->crtc_v_sync_strt_wid |= (disp_end + info->PanelVOverPlus); + save->crtc_v_sync_strt_wid |= + info->PanelVSyncWidth << R128_CRTC_V_SYNC_WID_SHIFT; + save->crtc_v_sync_strt_wid |= R128_CRTC_V_SYNC_POL; +} + /* Define PLL registers for requested video mode. */ static void R128InitPLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save, DisplayModePtr mode, R128PLLPtr pll, @@ -2022,10 +2652,12 @@ static Bool R128Init(ScrnInfoPtr pScrn, DisplayModePtr mode, R128SavePtr save) R128InitCommonRegisters(save, mode, info); if (!R128InitCrtcRegisters(pScrn, save, mode, info)) return FALSE; + if (info->HasPanelRegs && info->EnableFP) + R128InitFPRegisters(pScrn, &info->SavedReg, save, mode, info); R128InitPLLRegisters(pScrn, save, mode, &info->pll, dot_clock); if (!R128InitDDARegisters(pScrn, save, mode, &info->pll, info)) return FALSE; - R128InitPalette(save, info); + if (!info->PaletteSavedOnVT) R128InitPalette(save, info); R128TRACE(("R128Init returns %p\n", save)); return TRUE; @@ -2037,6 +2669,7 @@ static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) R128InfoPtr info = R128PTR(pScrn); if (!R128Init(pScrn, mode, &info->ModeReg)) return FALSE; + /* FIXME? DRILock/DRIUnlock here? */ R128Blank(pScrn); R128RestoreMode(pScrn, &info->ModeReg); R128Unblank(pScrn); @@ -2096,14 +2729,43 @@ static void R128AdjustFrame(int scrnIndex, int x, int y, int flags) mode. */ static Bool R128EnterVT(int scrnIndex, int flags) { - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); R128TRACE(("R128EnterVT\n")); +#ifdef XF86DRI + if (R128PTR(pScrn)->directRenderingEnabled) { + R128CCEStart(pScrn); + DRIUnlock(pScrn->pScreen); + } +#endif if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE; + info->PaletteSavedOnVT = FALSE; R128AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0); + return TRUE; } +/* Called when VT switching away from the X server. Restore the original + text mode. */ +static void R128LeaveVT(int scrnIndex, int flags) +{ + ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; + R128InfoPtr info = R128PTR(pScrn); + R128SavePtr save = &info->ModeReg; + + R128TRACE(("R128LeaveVT\n")); +#ifdef XF86DRI + if (R128PTR(pScrn)->directRenderingEnabled) { + DRILock(pScrn->pScreen, 0); + R128CCEStop(pScrn); + } +#endif + R128SavePalette(pScrn, save); + info->PaletteSavedOnVT = TRUE; + R128Restore(pScrn); +} + static Bool R128EnterVTFBDev(int scrnIndex, int flags) { @@ -2116,8 +2778,6 @@ R128EnterVTFBDev(int scrnIndex, int flags) return TRUE; } -/* Called when VT switching away from the X server. Restore the original - text mode. */ static void R128LeaveVTFBDev(int scrnIndex, int flags) { ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; @@ -2127,14 +2787,6 @@ static void R128LeaveVTFBDev(int scrnIndex, int flags) fbdevHWLeaveVT(scrnIndex,flags); } -static void R128LeaveVT(int scrnIndex, int flags) -{ - ScrnInfoPtr pScrn = xf86Screens[scrnIndex]; - - R128TRACE(("R128LeaveVT\n")); - R128Restore(pScrn); -} - /* Called at the end of each server generation. Restore the original text mode, unmap video memory, and unwrap and call the saved CloseScreen function. */ @@ -2144,6 +2796,15 @@ static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen) R128InfoPtr info = R128PTR(pScrn); R128TRACE(("R128CloseScreen\n")); + +#ifdef XF86DRI + /* Disable direct rendering */ + if (info->directRenderingEnabled) { + R128DRICloseScreen(pScreen); + info->directRenderingEnabled = FALSE; + } +#endif + if (pScrn->vtSema) { R128Restore(pScrn); R128UnmapMem(pScrn); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h index 86652affa..17a539e76 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h @@ -1,8 +1,8 @@ /* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.6 2000/02/23 04:47:19 martin Exp $ */ /************************************************************************** -Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. +Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -159,9 +159,20 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_AGP_APER_OFFSET 0x0178 #define R128_AGP_BASE 0x0170 #define R128_AGP_CNTL 0x0174 +# define R128_AGP_APER_SIZE_256MB (0x00 << 0) +# define R128_AGP_APER_SIZE_128MB (0x20 << 0) +# define R128_AGP_APER_SIZE_64MB (0x30 << 0) +# define R128_AGP_APER_SIZE_32MB (0x38 << 0) +# define R128_AGP_APER_SIZE_16MB (0x3c << 0) +# define R128_AGP_APER_SIZE_8MB (0x3e << 0) +# define R128_AGP_APER_SIZE_4MB (0x3f << 0) +# define R128_AGP_APER_SIZE_MASK (0x3f << 0) #define R128_AGP_COMMAND 0x0f58 /* PCI */ #define R128_AGP_PLL_CNTL 0x0010 /* PLL */ #define R128_AGP_STATUS 0x0f54 /* PCI */ +# define R128_AGP_1X_MODE 0x01 +# define R128_AGP_2X_MODE 0x02 +# define R128_AGP_MODE_MASK 0x03 #define R128_AMCGPIO_A_REG 0x01a0 #define R128_AMCGPIO_EN_REG 0x01a8 #define R128_AMCGPIO_MASK 0x0194 @@ -169,6 +180,15 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_ATTRDR 0x03c1 /* VGA */ #define R128_ATTRDW 0x03c0 /* VGA */ #define R128_ATTRX 0x03c0 /* VGA */ +# define R128_AUX1_SC_EN (1 << 0) +# define R128_AUX1_SC_MODE_OR (0 << 1) +# define R128_AUX1_SC_MODE_NAND (1 << 1) +# define R128_AUX2_SC_EN (1 << 2) +# define R128_AUX2_SC_MODE_OR (0 << 3) +# define R128_AUX2_SC_MODE_NAND (1 << 3) +# define R128_AUX3_SC_EN (1 << 4) +# define R128_AUX3_SC_MODE_OR (0 << 5) +# define R128_AUX3_SC_MODE_NAND (1 << 5) #define R128_AUX_SC_CNTL 0x1660 #define R128_AUX1_SC_BOTTOM 0x1670 #define R128_AUX1_SC_LEFT 0x1664 @@ -257,11 +277,12 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_BRUSH_SCALE 0x1470 #define R128_BRUSH_Y_X 0x1474 #define R128_BUS_CNTL 0x0030 -# define R128_BUS_RD_DISCARD_EN (1 << 24) -# define R128_BUS_RD_ABORT_EN (1 << 25) -# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28) -# define R128_BUS_WRT_BURST (1 << 29) -# define R128_BUS_READ_BURST (1 << 30) +# define R128_BUS_MASTER_DIS (1 << 6) +# define R128_BUS_RD_DISCARD_EN (1 << 24) +# define R128_BUS_RD_ABORT_EN (1 << 25) +# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28) +# define R128_BUS_WRT_BURST (1 << 29) +# define R128_BUS_READ_BURST (1 << 30) #define R128_BUS_CNTL1 0x0034 #define R128_CACHE_CNTL 0x1724 @@ -297,6 +318,9 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_CONFIG_REG_APER_SIZE 0x0110 #define R128_CONFIG_XSTRAP 0x00e4 #define R128_CONSTANT_COLOR_C 0x1d34 +# define R128_CONSTANT_COLOR_MASK 0x00ffffff +# define R128_CONSTANT_COLOR_ONE 0x00ffffff +# define R128_CONSTANT_COLOR_ZERO 0x00000000 #define R128_CRC_CMDFIFO_ADDR 0x0740 #define R128_CRC_CMDFIFO_DOUT 0x0744 #define R128_CRTC_CRNT_FRAME 0x0214 @@ -308,6 +332,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l # define R128_CRTC_HSYNC_DIS (1 << 8) # define R128_CRTC_VSYNC_DIS (1 << 9) # define R128_CRTC_DISPLAY_DIS (1 << 10) +# define R128_CRTC_CRT_ON (1 << 15) #define R128_CRTC_EXT_CNTL_DPMS_BYTE 0x0055 # define R128_CRTC_HSYNC_DIS_BYTE (1 << 0) # define R128_CRTC_VSYNC_DIS_BYTE (1 << 1) @@ -315,24 +340,57 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_CRTC_GEN_CNTL 0x0050 # define R128_CRTC_DBL_SCAN_EN (1 << 0) # define R128_CRTC_INTERLACE_EN (1 << 1) +# define R128_CRTC_CSYNC_EN (1 << 4) # define R128_CRTC_CUR_EN (1 << 16) # define R128_CRTC_CUR_MODE_MASK (7 << 17) +# define R128_CRTC_ICON_EN (1 << 20) # define R128_CRTC_EXT_DISP_EN (1 << 24) # define R128_CRTC_EN (1 << 25) +# define R128_CRTC_DISP_REQ_EN_B (1 << 26) #define R128_CRTC_GUI_TRIG_VLINE 0x0218 #define R128_CRTC_H_SYNC_STRT_WID 0x0204 -# define R128_CRTC_H_SYNC_POL (1 << 23) +# define R128_CRTC_H_SYNC_STRT_PIX (0x07 << 0) +# define R128_CRTC_H_SYNC_STRT_CHAR (0x1ff << 3) +# define R128_CRTC_H_SYNC_STRT_CHAR_SHIFT 3 +# define R128_CRTC_H_SYNC_WID (0x3f << 16) +# define R128_CRTC_H_SYNC_WID_SHIFT 16 +# define R128_CRTC_H_SYNC_POL (1 << 23) #define R128_CRTC_H_TOTAL_DISP 0x0200 +# define R128_CRTC_H_TOTAL (0x01ff << 0) +# define R128_CRTC_H_TOTAL_SHIFT 0 +# define R128_CRTC_H_DISP (0x00ff << 16) +# define R128_CRTC_H_DISP_SHIFT 16 #define R128_CRTC_OFFSET 0x0224 #define R128_CRTC_OFFSET_CNTL 0x0228 #define R128_CRTC_PITCH 0x022c #define R128_CRTC_STATUS 0x005c # define R128_CRTC_VBLANK_SAVE (1 << 1) #define R128_CRTC_V_SYNC_STRT_WID 0x020c -# define R128_CRTC_V_SYNC_POL (1 << 23) +# define R128_CRTC_V_SYNC_STRT (0x7ff << 0) +# define R128_CRTC_V_SYNC_STRT_SHIFT 0 +# define R128_CRTC_V_SYNC_WID (0x1f << 16) +# define R128_CRTC_V_SYNC_WID_SHIFT 16 +# define R128_CRTC_V_SYNC_POL (1 << 23) #define R128_CRTC_V_TOTAL_DISP 0x0208 +# define R128_CRTC_V_TOTAL (0x07ff << 0) +# define R128_CRTC_V_TOTAL_SHIFT 0 +# define R128_CRTC_V_DISP (0x07ff << 16) +# define R128_CRTC_V_DISP_SHIFT 16 #define R128_CRTC_VLINE_CRNT_VLINE 0x0210 # define R128_CRTC_CRNT_VLINE_MASK (0x7ff << 16) +#define R128_CRTC2_CRNT_FRAME 0x0314 +#define R128_CRTC2_DEBUG 0x031c +#define R128_CRTC2_GEN_CNTL 0x03f8 +#define R128_CRTC2_GUI_TRIG_VLINE 0x0318 +#define R128_CRTC2_H_SYNC_STRT_WID 0x0304 +#define R128_CRTC2_H_TOTAL_DISP 0x0300 +#define R128_CRTC2_OFFSET 0x0324 +#define R128_CRTC2_OFFSET_CNTL 0x0328 +#define R128_CRTC2_PITCH 0x032c +#define R128_CRTC2_STATUS 0x03fc +#define R128_CRTC2_V_SYNC_STRT_WID 0x030c +#define R128_CRTC2_V_TOTAL_DISP 0x0308 +#define R128_CRTC2_VLINE_CRNT_VLINE 0x0310 #define R128_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */ #define R128_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */ #define R128_CUR_CLR0 0x026c @@ -345,6 +403,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_DAC_CNTL 0x0058 # define R128_DAC_RANGE_CNTL (3 << 0) # define R128_DAC_BLANKING (1 << 2) +# define R128_DAC_CRT_SEL_CRTC2 (1 << 4) # define R128_DAC_8BIT_EN (1 << 8) # define R128_DAC_VGA_ADR_EN (1 << 13) # define R128_DAC_MASK_ALL (0xff << 24) @@ -360,8 +419,8 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8 # define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0) # define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16) -#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824 #define R128_DESTINATION_3D_CLR_CMP_VAL 0x1820 +#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824 #define R128_DEVICE_ID 0x0f02 /* PCI */ #define R128_DP_BRUSH_BKGD_CLR 0x1478 #define R128_DP_BRUSH_FRGD_CLR 0x147c @@ -373,6 +432,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l # define R128_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15) # define R128_DST_X_DIR_LEFT_TO_RIGHT (1 << 31) #define R128_DP_DATATYPE 0x16c4 +# define R128_HOST_BIG_ENDIAN_EN (1 << 29) #define R128_DP_GUI_MASTER_CNTL 0x146c # define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0) # define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1) @@ -388,6 +448,19 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l # define R128_GMC_BRUSH_8x8_COLOR (10 << 4) # define R128_GMC_BRUSH_1X8_COLOR (12 << 4) # define R128_GMC_BRUSH_SOLID_COLOR (13 << 4) +# define R128_GMC_BRUSH_NONE (15 << 4) +# define R128_GMC_DST_8BPP_CI (2 << 8) +# define R128_GMC_DST_15BPP (3 << 8) +# define R128_GMC_DST_16BPP (4 << 8) +# define R128_GMC_DST_24BPP (5 << 8) +# define R128_GMC_DST_32BPP (6 << 8) +# define R128_GMC_DST_8BPP_RGB (7 << 8) +# define R128_GMC_DST_Y8 (8 << 8) +# define R128_GMC_DST_RGB8 (9 << 8) +# define R128_GMC_DST_VYUY (11 << 8) +# define R128_GMC_DST_YVYU (12 << 8) +# define R128_GMC_DST_AYUV444 (14 << 8) +# define R128_GMC_DST_ARGB4444 (15 << 8) # define R128_GMC_DST_DATATYPE_MASK (0x0f << 8) # define R128_GMC_DST_DATATYPE_SHIFT 8 # define R128_GMC_SRC_DATATYPE_MASK (3 << 12) @@ -395,8 +468,11 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l # define R128_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12) # define R128_GMC_SRC_DATATYPE_COLOR (3 << 12) # define R128_GMC_BYTE_PIX_ORDER (1 << 14) +# define R128_GMC_BYTE_MSB_TO_LSB (0 << 14) # define R128_GMC_BYTE_LSB_TO_MSB (1 << 14) # define R128_GMC_CONVERSION_TEMP (1 << 15) +# define R128_GMC_CONVERSION_TEMP_6500 (0 << 15) +# define R128_GMC_CONVERSION_TEMP_9300 (1 << 15) # define R128_GMC_ROP3_MASK (0xff << 16) # define R128_DP_SRC_SOURCE_MASK (7 << 24) # define R128_DP_SRC_SOURCE_MEMORY (2 << 24) @@ -404,7 +480,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l # define R128_GMC_3D_FCN_EN (1 << 27) # define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28) # define R128_AUX_CLIP_DIS (1 << 29) -# define R128_GMC_WR_MSK_DS (1 << 30) +# define R128_GMC_WR_MSK_DIS (1 << 30) # define R128_GMC_LD_BRUSH_Y_X (1 << 31) # define R128_ROP3_ZERO 0x00000000 # define R128_ROP3_DSa 0x00880000 @@ -456,6 +532,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_DST_PITCH 0x1408 #define R128_DST_PITCH_OFFSET 0x142c #define R128_DST_PITCH_OFFSET_C 0x1c80 +# define R128_PITCH_SHIFT 21 #define R128_DST_WIDTH 0x140c #define R128_DST_WIDTH_HEIGHT 0x1598 #define R128_DST_WIDTH_X 0x1588 @@ -477,6 +554,49 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_FLUSH_5 0x1714 #define R128_FLUSH_6 0x1718 #define R128_FLUSH_7 0x171c +#define R128_FOG_3D_TABLE_START 0x1810 +#define R128_FOG_3D_TABLE_END 0x1814 +#define R128_FOG_3D_TABLE_DENSITY 0x181c +#define R128_FOG_TABLE_INDEX 0x1a14 +#define R128_FOG_TABLE_DATA 0x1a18 +#define R128_FP_CRTC_H_TOTAL_DISP 0x0250 +#define R128_FP_CRTC_V_TOTAL_DISP 0x0254 +#define R128_FP_GEN_CNTL 0x0284 +# define R128_FP_FPON (1 << 0) +# define R128_FP_TDMS_EN (1 << 2) +# define R128_FP_SEL_CRTC2 (1 << 13) +# define R128_FP_CRTC_DONT_SHADOW_VPAR (1 << 16) +# define R128_FP_CRTC_USE_SHADOW_VEND (1 << 18) +# define R128_FP_CRTC_HORZ_DIV2_EN (1 << 20) +# define R128_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21) +# define R128_FP_USE_SHADOW_EN (1 << 24) +#define R128_FP_H_SYNC_STRT_WID 0x02c4 +#define R128_FP_HORZ_STRETCH 0x028c +# define R128_HORZ_STRETCH_RATIO_MASK 0xffff +# define R128_HORZ_STRETCH_RATIO_SHIFT 0 +# define R128_HORZ_STRETCH_RATIO_MAX 4096 +# define R128_HORZ_PANEL_SIZE (0xff << 16) +# define R128_HORZ_PANEL_SHIFT 16 +# define R128_HORZ_STRETCH_PIXREP (0 << 25) +# define R128_HORZ_STRETCH_BLEND (1 << 25) +# define R128_HORZ_STRETCH_ENABLE (1 << 26) +# define R128_HORZ_FP_LOOP_STRETCH (0x7 << 27) +# define R128_HORZ_STRETCH_RESERVED 0xc0000000 + +#define R128_FP_PANEL_CNTL 0x0288 +# define R128_FP_DIGON (1 << 0) +# define R128_FP_BLON (1 << 1) +#define R128_FP_V_SYNC_STRT_WID 0x02c8 +#define R128_FP_VERT_STRETCH 0x0290 +# define R128_VERT_PANEL_SIZE (0x7ff << 0) +# define R128_VERT_PANEL_SHIFT 0 +# define R128_VERT_STRETCH_RATIO_MASK 0x3ff +# define R128_VERT_STRETCH_RATIO_SHIFT 11 +# define R128_VERT_STRETCH_RATIO_MAX 1024 +# define R128_VERT_STRETCH_ENABLE (1 << 24) +# define R128_VERT_STRETCH_LINEREP (0 << 25) +# define R128_VERT_STRETCH_BLEND (1 << 25) +# define R128_VERT_STRETCH_RESERVED 0xf8e00000 #define R128_GEN_INT_CNTL 0x0040 #define R128_GEN_INT_STATUS 0x0044 @@ -554,6 +674,9 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_LEAD_BRES_INC 0x1604 #define R128_LEAD_BRES_LNTH 0x161c #define R128_LEAD_BRES_LNTH_SUB 0x1624 +#define R128_LVDS_GEN_CNTL 0x02d0 +# define R128_LVDS_ON (1 << 0) +# define R128_LVDS_SEL_CRTC2 (1 << 23) #define R128_MAX_LATENCY 0x0f3f /* PCI */ #define R128_MCLK_CNTL 0x000f /* PLL */ @@ -573,7 +696,6 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_MEM_VGA_RP_SEL 0x003c #define R128_MEM_VGA_WP_SEL 0x0038 #define R128_MIN_GRANT 0x0f3e /* PCI */ -#define R128_MISC_3D_STATE_CNTL_REG 0x1CA0 #define R128_MM_DATA 0x0004 #define R128_MM_INDEX 0x0000 #define R128_MPLL_CNTL 0x000e /* PLL */ @@ -592,7 +714,10 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_PC_DEBUG_MODE 0x1760 #define R128_PC_GUI_CTLSTAT 0x1748 #define R128_PC_GUI_MODE 0x1744 +# define R128_PC_IGNORE_UNIFY (1 << 5) #define R128_PC_NGUI_CTLSTAT 0x0184 +# define R128_PC_FLUSH_GUI (3 << 0) +# define R128_PC_RI_GUI (1 << 2) # define R128_PC_FLUSH_ALL 0x00ff # define R128_PC_BUSY (1 << 31) #define R128_PC_NGUI_MODE 0x0180 @@ -669,11 +794,13 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_TEST_DEBUG_CNTL 0x0120 #define R128_TEST_DEBUG_MUX 0x0124 #define R128_TEST_DEBUG_OUT 0x012c +#define R128_TMDS_CRC 0x02a0 #define R128_TRAIL_BRES_DEC 0x1614 #define R128_TRAIL_BRES_ERR 0x160c #define R128_TRAIL_BRES_INC 0x1610 #define R128_TRAIL_X 0x1618 #define R128_TRAIL_X_SUB 0x1620 + #define R128_VCLK_ECP_CNTL 0x0008 /* PLL */ #define R128_VENDOR_ID 0x0f00 /* PCI */ #define R128_VGA_DDA_CONFIG 0x02e8 @@ -689,6 +816,538 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l #define R128_XDLL_CNTL 0x000c /* PLL */ #define R128_XPLL_CNTL 0x000b /* PLL */ + /* Registers for CCE and Microcode Engine */ +#define R128_PM4_MICROCODE_ADDR 0x07d4 +#define R128_PM4_MICROCODE_RADDR 0x07d8 +#define R128_PM4_MICROCODE_DATAH 0x07dc +#define R128_PM4_MICROCODE_DATAL 0x07e0 + +#define R128_PM4_BUFFER_OFFSET 0x0700 +#define R128_PM4_BUFFER_CNTL 0x0704 +# define R128_PM4_NONPM4 (0 << 28) +# define R128_PM4_192PIO (1 << 28) +# define R128_PM4_192BM (2 << 28) +# define R128_PM4_128PIO_64INDBM (3 << 28) +# define R128_PM4_128BM_64INDBM (4 << 28) +# define R128_PM4_64PIO_128INDBM (5 << 28) +# define R128_PM4_64BM_128INDBM (6 << 28) +# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28) +# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28) +# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28) +#define R128_PM4_BUFFER_WM_CNTL 0x0708 +# define R128_WMA_SHIFT 0 +# define R128_WMB_SHIFT 8 +# define R128_WMC_SHIFT 16 +# define R128_WB_WM_SHIFT 24 +#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c +#define R128_PM4_BUFFER_DL_RPTR 0x0710 +#define R128_PM4_BUFFER_DL_WPTR 0x0714 +# define R128_PM4_BUFFER_DL_DONE (1 << 31) +#define R128_PM4_VC_FPU_SETUP 0x071c +# define R128_FRONT_DIR_CW (0 << 0) +# define R128_FRONT_DIR_CCW (1 << 0) +# define R128_FRONT_DIR_MASK (1 << 0) +# define R128_BACKFACE_CULL (0 << 1) +# define R128_BACKFACE_POINTS (1 << 1) +# define R128_BACKFACE_LINES (2 << 1) +# define R128_BACKFACE_SOLID (3 << 1) +# define R128_BACKFACE_MASK (3 << 1) +# define R128_FRONTFACE_CULL (0 << 3) +# define R128_FRONTFACE_POINTS (1 << 3) +# define R128_FRONTFACE_LINES (2 << 3) +# define R128_FRONTFACE_SOLID (3 << 3) +# define R128_FRONTFACE_MASK (3 << 3) +# define R128_FPU_COLOR_SOLID (0 << 5) +# define R128_FPU_COLOR_FLAT (1 << 5) +# define R128_FPU_COLOR_GOURAUD (2 << 5) +# define R128_FPU_COLOR_GOURAUD2 (3 << 5) +# define R128_FPU_SUB_PIX_2BITS (0 << 7) +# define R128_FPU_SUB_PIX_4BITS (1 << 7) +# define R128_FPU_MODE_2D (0 << 8) +# define R128_FPU_MODE_3D (1 << 8) +# define R128_TRAP_BITS_DISABLE (1 << 9) +# define R128_EDGE_ANTIALIAS (1 << 10) +# define R128_SUPERSAMPLE (1 << 11) +# define R128_XFACTOR_2 (0 << 12) +# define R128_XFACTOR_4 (1 << 12) +# define R128_YFACTOR_2 (0 << 13) +# define R128_YFACTOR_4 (1 << 13) +# define R128_FLAT_SHADE_VERTEX_D3D (0 << 14) +# define R128_FLAT_SHADE_VERTEX_OGL (1 << 14) +# define R128_FPU_ROUND_TRUNCATE (0 << 15) +# define R128_FPU_ROUND_NEAREST (1 << 15) +# define R128_WM_SEL_8DW (0 << 16) +# define R128_WM_SEL_16DW (1 << 16) +# define R128_WM_SEL_32DW (2 << 16) +#define R128_PM4_STAT 0x07b8 +# define R128_PM4_FIFOCNT_MASK 0x0fff +# define R128_PM4_BUSY (1 << 16) +# define R128_PM4_GUI_ACTIVE (1 << 31) +#define R128_PM4_BUFFER_ADDR 0x07f0 +#define R128_PM4_MICRO_CNTL 0x07fc +# define R128_PM4_MICRO_FREERUN (1 << 30) +#define R128_PM4_FIFO_DATA_EVEN 0x1000 +#define R128_PM4_FIFO_DATA_ODD 0x1004 + #define R128_SCALE_3D_CNTL 0x1a00 +# define R128_SCALE_DITHER_ERR_DIFF (0 << 1) +# define R128_SCALE_DITHER_TABLE (1 << 1) +# define R128_TEX_CACHE_SIZE_FULL (0 << 2) +# define R128_TEX_CACHE_SIZE_HALF (1 << 2) +# define R128_DITHER_INIT_CURR (0 << 3) +# define R128_DITHER_INIT_RESET (1 << 3) +# define R128_ROUND_24BIT (1 << 4) +# define R128_TEX_CACHE_DISABLE (1 << 5) +# define R128_SCALE_3D_NOOP (0 << 6) +# define R128_SCALE_3D_SCALE (1 << 6) +# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6) +# define R128_SCALE_PIX_BLEND (0 << 8) +# define R128_SCALE_PIX_REPLICATE (1 << 8) +# define R128_TEX_CACHE_SPLIT (1 << 9) +# define R128_APPLE_YUV_MODE (1 << 10) +# define R128_TEX_CACHE_PALLETE_MODE (1 << 11) +# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12) +# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12) +# define R128_FOG_TABLE (1 << 14) +# define R128_SIGNED_DST_CLAMP (1 << 15) +# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) +# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define R128_ALPHA_BLEND_SRC_DSTALPHA (6 << 16) +# define R128_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16) +# define R128_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16) +# define R128_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16) +# define R128_ALPHA_BLEND_SRC_SAT (10 << 16) +# define R128_ALPHA_BLEND_SRC_BLEND (11 << 16) +# define R128_ALPHA_BLEND_SRC_INVBLEND (12 << 16) +# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) +# define R128_ALPHA_BLEND_DST_ONE (1 << 20) +# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define R128_ALPHA_BLEND_DST_DSTALPHA (6 << 20) +# define R128_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20) +# define R128_ALPHA_BLEND_DST_DSTCOLOR (8 << 20) +# define R128_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20) +# define R128_ALPHA_TEST_NEVER (0 << 24) +# define R128_ALPHA_TEST_LESS (1 << 24) +# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) +# define R128_ALPHA_TEST_EQUAL (3 << 24) +# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define R128_ALPHA_TEST_GREATER (5 << 24) +# define R128_ALPHA_TEST_NEQUAL (6 << 24) +# define R128_ALPHA_TEST_ALWAYS (7 << 24) +# define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28) +# define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28) +# define R128_COMPOSITE_SHADOW (1 << 29) +# define R128_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30) +# define R128_TEX_CACHE_LINE_SIZE_8QW (0 << 31) +# define R128_TEX_CACHE_LINE_SIZE_4QW (1 << 31) + +#define R128_SETUP_CNTL 0x1bc4 +# define R128_DONT_START_TRIANGLE (1 << 0) +# define R128_Z_BIAS (0 << 1) +# define R128_DONT_START_ANY_ON (1 << 2) +# define R128_COLOR_SOLID_COLOR (0 << 3) +# define R128_COLOR_FLAT_VERT_1 (1 << 3) +# define R128_COLOR_FLAT_VERT_2 (2 << 3) +# define R128_COLOR_FLAT_VERT_3 (3 << 3) +# define R128_COLOR_GOURAUD (4 << 3) +# define R128_PRIM_TYPE_TRI (0 << 7) +# define R128_PRIM_TYPE_LINE (1 << 7) +# define R128_PRIM_TYPE_POINT (2 << 7) +# define R128_PRIM_TYPE_POLY_EDGE (3 << 7) +# define R128_TEXTURE_ST_MULT_W (0 << 9) +# define R128_TEXTURE_ST_DIRECT (1 << 9) +# define R128_STARTING_VERTEX_1 (1 << 14) +# define R128_STARTING_VERTEX_2 (2 << 14) +# define R128_STARTING_VERTEX_3 (3 << 14) +# define R128_ENDING_VERTEX_1 (1 << 16) +# define R128_ENDING_VERTEX_2 (2 << 16) +# define R128_ENDING_VERTEX_3 (3 << 16) +# define R128_SU_POLY_LINE_LAST (0 << 18) +# define R128_SU_POLY_LINE_NOT_LAST (1 << 18) +# define R128_SUB_PIX_2BITS (0 << 19) +# define R128_SUB_PIX_4BITS (1 << 19) +# define R128_SET_UP_CONTINUE (1 << 31) + +#define R128_WINDOW_XY_OFFSET 0x1bcc +# define R128_WINDOW_Y_SHIFT 4 +# define R128_WINDOW_X_SHIFT 20 + +#define R128_Z_OFFSET_C 0x1c90 +#define R128_Z_PITCH_C 0x1c94 +#define R128_Z_STEN_CNTL_C 0x1c98 +# define R128_Z_PIX_WIDTH_16 (0 << 1) +# define R128_Z_PIX_WIDTH_24 (1 << 1) +# define R128_Z_PIX_WIDTH_32 (2 << 1) +# define R128_Z_PIX_WIDTH_MASK (3 << 1) +# define R128_Z_TEST_NEVER (0 << 4) +# define R128_Z_TEST_LESS (1 << 4) +# define R128_Z_TEST_LESSEQUAL (2 << 4) +# define R128_Z_TEST_EQUAL (3 << 4) +# define R128_Z_TEST_GREATEREQUAL (4 << 4) +# define R128_Z_TEST_GREATER (5 << 4) +# define R128_Z_TEST_NEQUAL (6 << 4) +# define R128_Z_TEST_ALWAYS (7 << 4) +# define R128_Z_TEST_MASK (7 << 4) +# define R128_STENCIL_TEST_NEVER (0 << 12) +# define R128_STENCIL_TEST_LESS (1 << 12) +# define R128_STENCIL_TEST_LESSEQUAL (2 << 12) +# define R128_STENCIL_TEST_EQUAL (3 << 12) +# define R128_STENCIL_TEST_GREATEREQUAL (4 << 12) +# define R128_STENCIL_TEST_GREATER (5 << 12) +# define R128_STENCIL_TEST_NEQUAL (6 << 12) +# define R128_STENCIL_TEST_ALWAYS (7 << 12) +# define R128_STENCIL_S_FAIL_KEEP (0 << 16) +# define R128_STENCIL_S_FAIL_ZERO (1 << 16) +# define R128_STENCIL_S_FAIL_REPLACE (2 << 16) +# define R128_STENCIL_S_FAIL_INC (3 << 16) +# define R128_STENCIL_S_FAIL_DEC (4 << 16) +# define R128_STENCIL_S_FAIL_INV (5 << 16) +# define R128_STENCIL_ZPASS_KEEP (0 << 20) +# define R128_STENCIL_ZPASS_ZERO (1 << 20) +# define R128_STENCIL_ZPASS_REPLACE (2 << 20) +# define R128_STENCIL_ZPASS_INC (3 << 20) +# define R128_STENCIL_ZPASS_DEC (4 << 20) +# define R128_STENCIL_ZPASS_INV (5 << 20) +# define R128_STENCIL_ZFAIL_KEEP (0 << 24) +# define R128_STENCIL_ZFAIL_ZERO (1 << 24) +# define R128_STENCIL_ZFAIL_REPLACE (2 << 24) +# define R128_STENCIL_ZFAIL_INC (3 << 24) +# define R128_STENCIL_ZFAIL_DEC (4 << 24) +# define R128_STENCIL_ZFAIL_INV (5 << 24) +#define R128_TEX_CNTL_C 0x1c9c +# define R128_Z_ENABLE (1 << 0) +# define R128_Z_WRITE_ENABLE (1 << 1) +# define R128_STENCIL_ENABLE (1 << 3) +# define R128_SHADE_ENABLE (0 << 4) +# define R128_TEXMAP_ENABLE (1 << 4) +# define R128_SEC_TEXMAP_ENABLE (1 << 5) +# define R128_FOG_ENABLE (1 << 7) +# define R128_DITHER_ENABLE (1 << 8) +# define R128_ALPHA_ENABLE (1 << 9) +# define R128_ALPHA_TEST_ENABLE (1 << 10) +# define R128_SPEC_LIGHT_ENABLE (1 << 11) +# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12) +# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13) +# define R128_ALPHA_IN_TEX_LSB_A (1 << 13) +# define R128_LIGHT_DIS (0 << 14) +# define R128_LIGHT_COPY (1 << 14) +# define R128_LIGHT_MODULATE (2 << 14) +# define R128_LIGHT_ADD (3 << 14) +# define R128_LIGHT_BLEND_CONSTANT (4 << 14) +# define R128_LIGHT_BLEND_TEXTURE (5 << 14) +# define R128_LIGHT_BLEND_VERTEX (6 << 14) +# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14) +# define R128_ALPHA_LIGHT_DIS (0 << 18) +# define R128_ALPHA_LIGHT_COPY (1 << 18) +# define R128_ALPHA_LIGHT_MODULATE (2 << 18) +# define R128_ALPHA_LIGHT_ADD (3 << 18) +# define R128_ANTI_ALIAS (1 << 21) +# define R128_TEX_CACHE_FLUSH (1 << 23) +# define R128_LOD_BIAS_SHIFT 24 +#define R128_MISC_3D_STATE_CNTL_REG 0x1ca0 +# define R128_REF_ALPHA_MASK 0xff +# define R128_MISC_SCALE_3D_NOOP (0 << 8) +# define R128_MISC_SCALE_3D_SCALE (1 << 8) +# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) +# define R128_MISC_SCALE_PIX_BLEND (0 << 10) +# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10) +# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12) +# define R128_FOG_VERTEX (0 << 14) +# define R128_FOG_TABLE (1 << 14) +# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16) +# define R128_ALPHA_BLEND_SRC_ONE (1 << 16) +# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16) +# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16) +# define R128_ALPHA_BLEND_SRC_DESTALPHA (6 << 16) +# define R128_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16) +# define R128_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16) +# define R128_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16) +# define R128_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16) +# define R128_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16) +# define R128_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16) +# define R128_ALPHA_BLEND_SRC_MASK (15 << 16) +# define R128_ALPHA_BLEND_DST_ZERO (0 << 20) +# define R128_ALPHA_BLEND_DST_ONE (1 << 20) +# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20) +# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20) +# define R128_ALPHA_BLEND_DST_DESTALPHA (6 << 20) +# define R128_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20) +# define R128_ALPHA_BLEND_DST_DESTCOLOR (8 << 20) +# define R128_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20) +# define R128_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20) +# define R128_ALPHA_BLEND_DST_MASK (15 << 20) +# define R128_ALPHA_TEST_NEVER (0 << 24) +# define R128_ALPHA_TEST_LESS (1 << 24) +# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) +# define R128_ALPHA_TEST_EQUAL (3 << 24) +# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define R128_ALPHA_TEST_GREATER (5 << 24) +# define R128_ALPHA_TEST_NEQUAL (6 << 24) +# define R128_ALPHA_TEST_ALWAYS (7 << 24) +# define R128_ALPHA_TEST_MASK (7 << 24) +#define R128_TEXTURE_CLR_CMP_CLR_C 0x1ca4 +#define R128_TEXTURE_CLR_CMP_MSK_C 0x1ca8 +#define R128_FOG_COLOR_C 0x1cac +# define R128_FOG_BLUE_SHIFT 0 +# define R128_FOG_GREEN_SHIFT 8 +# define R128_FOG_RED_SHIFT 16 +#define R128_PRIM_TEX_CNTL_C 0x1cb0 +# define R128_MIN_BLEND_NEAREST (0 << 1) +# define R128_MIN_BLEND_LINEAR (1 << 1) +# define R128_MIN_BLEND_MIPNEAREST (2 << 1) +# define R128_MIN_BLEND_MIPLINEAR (3 << 1) +# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1) +# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1) +# define R128_MIN_BLEND_MASK (7 << 1) +# define R128_MAG_BLEND_NEAREST (0 << 4) +# define R128_MAG_BLEND_LINEAR (1 << 4) +# define R128_MAG_BLEND_MASK (7 << 4) +# define R128_MIP_MAP_DISABLE (1 << 7) +# define R128_TEX_CLAMP_S_WRAP (0 << 8) +# define R128_TEX_CLAMP_S_MIRROR (1 << 8) +# define R128_TEX_CLAMP_S_CLAMP (2 << 8) +# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8) +# define R128_TEX_CLAMP_S_MASK (3 << 8) +# define R128_TEX_WRAP_S (1 << 10) +# define R128_TEX_CLAMP_T_WRAP (0 << 11) +# define R128_TEX_CLAMP_T_MIRROR (1 << 11) +# define R128_TEX_CLAMP_T_CLAMP (2 << 11) +# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11) +# define R128_TEX_CLAMP_T_MASK (3 << 11) +# define R128_TEX_WRAP_T (1 << 13) +# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14) +# define R128_DATATYPE_VQ (0 << 16) +# define R128_DATATYPE_CI4 (1 << 16) +# define R128_DATATYPE_CI8 (2 << 16) +# define R128_DATATYPE_ARGB1555 (3 << 16) +# define R128_DATATYPE_RGB565 (4 << 16) +# define R128_DATATYPE_RGB888 (5 << 16) +# define R128_DATATYPE_ARGB8888 (6 << 16) +# define R128_DATATYPE_RGB332 (7 << 16) +# define R128_DATATYPE_Y8 (8 << 16) +# define R128_DATATYPE_RGB8 (9 << 16) +# define R128_DATATYPE_CI16 (10 << 16) +# define R128_DATATYPE_YUV422 (11 << 16) +# define R128_DATATYPE_YUV422_2 (12 << 16) +# define R128_DATATYPE_AYUV444 (14 << 16) +# define R128_DATATYPE_ARGB4444 (15 << 16) +# define R128_PALLETE_EITHER (0 << 20) +# define R128_PALLETE_1 (1 << 20) +# define R128_PALLETE_2 (2 << 20) +# define R128_PSEUDOCOLOR_DT_RGB565 (0 << 24) +# define R128_PSEUDOCOLOR_DT_ARGB1555 (1 << 24) +# define R128_PSEUDOCOLOR_DT_ARGB4444 (2 << 24) +#define R128_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4 +# define R128_COMB_DIS (0 << 0) +# define R128_COMB_COPY (1 << 0) +# define R128_COMB_COPY_INP (2 << 0) +# define R128_COMB_MODULATE (3 << 0) +# define R128_COMB_MODULATE2X (4 << 0) +# define R128_COMB_MODULATE4X (5 << 0) +# define R128_COMB_ADD (6 << 0) +# define R128_COMB_ADD_SIGNED (7 << 0) +# define R128_COMB_BLEND_VERTEX (8 << 0) +# define R128_COMB_BLEND_TEXTURE (9 << 0) +# define R128_COMB_BLEND_CONST (10 << 0) +# define R128_COMB_BLEND_PREMULT (11 << 0) +# define R128_COMB_BLEND_PREV (12 << 0) +# define R128_COMB_BLEND_PREMULT_INV (13 << 0) +# define R128_COMB_ADD_SIGNED2X (14 << 0) +# define R128_COMB_BLEND_CONST_COLOR (15 << 0) +# define R128_COMB_MASK (15 << 0) +# define R128_COLOR_FACTOR_TEX (4 << 4) +# define R128_COLOR_FACTOR_NTEX (5 << 4) +# define R128_COLOR_FACTOR_ALPHA (6 << 4) +# define R128_COLOR_FACTOR_NALPHA (7 << 4) +# define R128_COLOR_FACTOR_MASK (15 << 4) +# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10) +# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10) +# define R128_INPUT_FACTOR_INT_COLOR (4 << 10) +# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10) +# define R128_INPUT_FACTOR_MASK (15 << 10) +# define R128_COMB_ALPHA_DIS (0 << 14) +# define R128_COMB_ALPHA_COPY (1 << 14) +# define R128_COMB_ALPHA_COPY_INP (2 << 14) +# define R128_COMB_ALPHA_MODULATE (3 << 14) +# define R128_COMB_ALPHA_MODULATE2X (4 << 14) +# define R128_COMB_ALPHA_MODULATE4X (5 << 14) +# define R128_COMB_ALPHA_ADD (6 << 14) +# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14) +# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14) +# define R128_COMB_ALPHA_MASK (15 << 14) +# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18) +# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18) +# define R128_ALPHA_FACTOR_MASK (15 << 18) +# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25) +# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25) +# define R128_INP_FACTOR_A_MASK (7 << 25) +#define R128_TEX_SIZE_PITCH_C 0x1cb8 +# define R128_TEX_PITCH_SHIFT 0 +# define R128_TEX_SIZE_SHIFT 4 +# define R128_TEX_HEIGHT_SHIFT 8 +# define R128_TEX_MIN_SIZE_SHIFT 12 +# define R128_SEC_TEX_PITCH_SHIFT 16 +# define R128_SEC_TEX_SIZE_SHIFT 20 +# define R128_SEC_TEX_HEIGHT_SHIFT 24 +# define R128_SEC_TEX_MIN_SIZE_SHIFT 28 +# define R128_TEX_PITCH_MASK (0x0f << 0) +# define R128_TEX_SIZE_MASK (0x0f << 4) +# define R128_TEX_HEIGHT_MASK (0x0f << 8) +# define R128_TEX_MIN_SIZE_MASK (0x0f << 12) +# define R128_SEC_TEX_PITCH_MASK (0x0f << 16) +# define R128_SEC_TEX_SIZE_MASK (0x0f << 20) +# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24) +# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28) +# define R128_TEX_SIZE_PITCH_SHIFT 0 +# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16 +# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0) +# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16) +#define R128_PRIM_TEX_0_OFFSET_C 0x1cbc +#define R128_PRIM_TEX_1_OFFSET_C 0x1cc0 +#define R128_PRIM_TEX_2_OFFSET_C 0x1cc4 +#define R128_PRIM_TEX_3_OFFSET_C 0x1cc8 +#define R128_PRIM_TEX_4_OFFSET_C 0x1ccc +#define R128_PRIM_TEX_5_OFFSET_C 0x1cd0 +#define R128_PRIM_TEX_6_OFFSET_C 0x1cd4 +#define R128_PRIM_TEX_7_OFFSET_C 0x1cd8 +#define R128_PRIM_TEX_8_OFFSET_C 0x1cdc +#define R128_PRIM_TEX_9_OFFSET_C 0x1ce0 +#define R128_PRIM_TEX_10_OFFSET_C 0x1ce4 +# define R128_TEX_NO_TILE (0 << 30) +# define R128_TEX_TILED_BY_HOST (1 << 30) +# define R128_TEX_TILED_BY_STORAGE (2 << 30) +# define R128_TEX_TILED_BY_STORAGE2 (3 << 30) + +#define R128_SEC_TEX_CNTL_C 0x1d00 +# define R128_SEC_SELECT_PRIM_ST (0 << 0) +# define R128_SEC_SELECT_SEC_ST (1 << 0) +#define R128_SEC_TEX_COMBINE_CNTL_C 0x1d04 +# define R128_INPUT_FACTOR_PREV_COLOR (8 << 10) +# define R128_INPUT_FACTOR_PREV_ALPHA (9 << 10) +# define R128_INP_FACTOR_A_PREV_ALPHA (4 << 25) +#define R128_SEC_TEX_0_OFFSET_C 0x1d08 +#define R128_SEC_TEX_1_OFFSET_C 0x1d0c +#define R128_SEC_TEX_2_OFFSET_C 0x1d10 +#define R128_SEC_TEX_3_OFFSET_C 0x1d14 +#define R128_SEC_TEX_4_OFFSET_C 0x1d18 +#define R128_SEC_TEX_5_OFFSET_C 0x1d1c +#define R128_SEC_TEX_6_OFFSET_C 0x1d20 +#define R128_SEC_TEX_7_OFFSET_C 0x1d24 +#define R128_SEC_TEX_8_OFFSET_C 0x1d28 +#define R128_SEC_TEX_9_OFFSET_C 0x1d2c +#define R128_SEC_TEX_10_OFFSET_C 0x1d30 +#define R128_CONSTANT_COLOR_C 0x1d34 +# define R128_CONSTANT_BLUE_SHIFT 0 +# define R128_CONSTANT_GREEN_SHIFT 8 +# define R128_CONSTANT_RED_SHIFT 16 +# define R128_CONSTANT_ALPHA_SHIFT 24 +#define R128_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38 +# define R128_PRIM_TEX_BORDER_BLUE_SHIFT 0 +# define R128_PRIM_TEX_BORDER_GREEN_SHIFT 8 +# define R128_PRIM_TEX_BORDER_RED_SHIFT 16 +# define R128_PRIM_TEX_BORDER_ALPHA_SHIFT 24 +#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c +# define R128_SEC_TEX_BORDER_BLUE_SHIFT 0 +# define R128_SEC_TEX_BORDER_GREEN_SHIFT 8 +# define R128_SEC_TEX_BORDER_RED_SHIFT 16 +# define R128_SEC_TEX_BORDER_ALPHA_SHIFT 24 +#define R128_STEN_REF_MASK_C 0x1d40 +# define R128_STEN_REFERENCE_SHIFT 0 +# define R128_STEN_MASK_SHIFT 16 +# define R128_STEN_WRITE_MASK_SHIFT 24 +#define R128_PLANE_3D_MASK_C 0x1d44 + + + /* Constants */ +#define R128_AGP_TEX_OFFSET 0x02000000 + +#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0 +#define R128_SWAP_AGE_REG R128_GUI_SCRATCH_REG1 + + /* CCE packet types */ +#define R128_CCE_PACKET0 0x00000000 +#define R128_CCE_PACKET0_ONE_REG_WR 0x00008000 +#define R128_CCE_PACKET1 0x40000000 +#define R128_CCE_PACKET2 0x80000000 +#define R128_CCE_PACKET3_NOP 0xC0001000 +#define R128_CCE_PACKET3_PAINT 0xC0001100 +#define R128_CCE_PACKET3_BITBLT 0xC0001200 +#define R128_CCE_PACKET3_SMALLTEXT 0xC0001300 +#define R128_CCE_PACKET3_HOSTDATA_BLT 0xC0001400 +#define R128_CCE_PACKET3_POLYLINE 0xC0001500 +#define R128_CCE_PACKET3_SCALING 0xC0001600 +#define R128_CCE_PACKET3_TRANS_SCALING 0xC0001700 +#define R128_CCE_PACKET3_POLYSCANLINES 0xC0001800 +#define R128_CCE_PACKET3_NEXT_CHAR 0xC0001900 +#define R128_CCE_PACKET3_PAINT_MULTI 0xC0001A00 +#define R128_CCE_PACKET3_BITBLT_MULTI 0xC0001B00 +#define R128_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00 +#define R128_CCE_PACKET3_SET_SCISSORS 0xC0001E00 +#define R128_CCE_PACKET3_SET_MODE24BPP 0xC0001F00 +#define R128_CCE_PACKET3_CNTL_PAINT 0xC0009100 +#define R128_CCE_PACKET3_CNTL_BITBLT 0xC0009200 +#define R128_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300 +#define R128_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400 +#define R128_CCE_PACKET3_CNTL_POLYLINE 0xC0009500 +#define R128_CCE_PACKET3_CNTL_SCALING 0xC0009600 +#define R128_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700 +#define R128_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800 +#define R128_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900 +#define R128_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00 +#define R128_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00 +#define R128_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00 +#define R128_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000 +#define R128_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100 +#define R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300 +#define R128_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500 +#define R128_CCE_PACKET3_LOAD_PALETTE 0xC0002C00 +#define R128_CCE_PACKET3_PURGE 0xC0002D00 +#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00 +# define R128_CCE_PACKET_MASK 0xC0000000 +# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000 +# define R128_CCE_PACKET_MAX_DWORDS (1 << 14) +# define R128_CCE_PACKET0_REG_MASK 0x000007ff +# define R128_CCE_PACKET1_REG0_MASK 0x000007ff +# define R128_CCE_PACKET1_REG1_MASK 0x003ff800 + +#define R128_CCE_VC_FRMT_RHW 0x00000001 +#define R128_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002 +#define R128_CCE_VC_FRMT_DIFFUSE_A 0x00000004 +#define R128_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008 +#define R128_CCE_VC_FRMT_SPEC_BGR 0x00000010 +#define R128_CCE_VC_FRMT_SPEC_F 0x00000020 +#define R128_CCE_VC_FRMT_SPEC_FRGB 0x00000040 +#define R128_CCE_VC_FRMT_S_T 0x00000080 +#define R128_CCE_VC_FRMT_S2_T2 0x00000100 +#define R128_CCE_VC_FRMT_RHW2 0x00000200 + +#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000 +#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001 +#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002 +#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006 +#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007 +#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010 +#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020 +#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030 +#define R128_CCE_VC_CNTL_NUM_SHIFT 16 #endif diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile index 4fe4392cb..e0bb04760 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile @@ -16,18 +16,11 @@ DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri DRIDEFINES = $(GLX_DEFINES) #endif -# -# Uncomment these only if you have the proprietary sources -# -PRIVSRCS = tdfx_priv.c -PRIVOBJS = tdfx_priv.o -PRIVDEFINES = -DPROP_3DFX - SRCS = tdfx_driver.c tdfx_io.c tdfx_hwcurs.c tdfx_accel.c \ - tdfx_dga.c $(DRISRCS) $(PRIVSRCS) + tdfx_dga.c tdfx_priv.c tdfx_sli.c $(DRISRCS) OBJS = tdfx_driver.o tdfx_io.o tdfx_hwcurs.o tdfx_accel.o \ - tdfx_dga.o $(DRIOBJS) $(PRIVOBJS) + tdfx_dga.o tdfx_priv.o tdfx_sli.o $(DRIOBJS) #if defined(XF86DriverSDK) INCLUDES = -I. -I../../include @@ -43,7 +36,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \ $(DRIINCLUDES) #endif -DEFINES = $(DRIDEFINES) $(PRIVDEFINES) +DEFINES = -DPROP_3DFX $(DRIDEFINES) #if MakeHasPosixVariableSubstitutions SubdirLibraryRule($(OBJS)) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h index f64489092..66e9c0d65 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h @@ -25,9 +25,22 @@ #include "tdfx_dripriv.h" #endif +#define TDFX_VERSION 4000 +#define TDFX_NAME "TDFX" +#define TDFX_DRIVER_NAME "tdfx" +#define TDFX_MAJOR_VERSION 1 +#define TDFX_MINOR_VERSION 0 +#define TDFX_PATCHLEVEL 0 + struct _TDFXRec; typedef struct _TDFXRec *TDFXPtr; +#ifdef XF86DRI +#define PIXMAP_CACHE_LINES 128 +#else +#define PIXMAP_CACHE_LINES 512 +#endif + #ifdef PROP_3DFX #include "tdfx_priv.h" #else @@ -37,6 +50,7 @@ typedef struct _TDFXRec *TDFXPtr; extern Bool TDFXInitPrivate(ScreenPtr pScreen); extern void TDFXShutdownPrivate(ScreenPtr pScreen); extern void TDFXSwapContextPrivate(ScreenPtr pScreen); +extern void TDFXLostContext(ScreenPtr pScreen); #ifdef XF86DRI extern void FillPrivateDRI(TDFXPtr pTDFX, TDFXDRIPtr pTDFXDRI); @@ -49,6 +63,7 @@ extern void FillPrivateDRI(TDFXPtr pTDFX, TDFXDRIPtr pTDFXDRI); #define TDFX_DEBUG_CMDS #define TRACECURS 1 #define REGDEBUG 1 +#define TRACEREG #endif #ifdef TRACE @@ -84,6 +99,14 @@ typedef char (*TDFXReadIndexedByteFunc)(TDFXPtr pTDFX, int addr, char index); typedef void (*TDFXWriteWordFunc)(TDFXPtr pTDFX, int addr, int value); typedef int (*TDFXReadWordFunc)(TDFXPtr pTDFX, int addr); +typedef void (*TDFXWriteChipIndexedByteFunc)(TDFXPtr pTDFX, int chip, + int addr, char index, char value); +typedef char (*TDFXReadChipIndexedByteFunc)(TDFXPtr pTDFX, int chip, + int addr, char index); +typedef void (*TDFXWriteChipWordFunc)(TDFXPtr pTDFX, int chip, + int addr, int value); +typedef int (*TDFXReadChipWordFunc)(TDFXPtr pTDFX, int chip, + int addr); typedef void (*TDFXSyncFunc)(ScrnInfoPtr pScrn); typedef void (*TDFXBufferFunc)(TDFXPtr pTDFX, int which); @@ -111,21 +134,26 @@ typedef struct TextureData_t { struct TextureData_t *next; } TextureData; +#define MAXCHIPS 4 + typedef struct _TDFXRec { - unsigned char *MMIOBase; + unsigned char *MMIOBase[MAXCHIPS]; unsigned char *FbBase; - unsigned int PIOBase; + unsigned char *myFbBase; + unsigned int PIOBase[MAXCHIPS]; long FbMapSize; + int pixelFormat; int stride; int cpp; int maxClip; int MaxClock; - int Chipset; - int LinearAddr; - int MMIOAddr; - EntityInfoPtr pEnt; + int ChipType; pciVideoPtr PciInfo; - PCITAG PciTag; + int LinearAddr[MAXCHIPS]; + int MMIOAddr[MAXCHIPS]; + EntityInfoPtr pEnt; + int numChips; + PCITAG PciTag[MAXCHIPS]; int HasSGRAM; int PciCnt; int PrevDrawState; @@ -142,6 +170,7 @@ typedef struct _TDFXRec { Bool NoAccel; DGAModePtr DGAModes; Bool DGAactive; + Bool initDone; int DGAViewportStatus; int cursorOffset; int fbOffset; @@ -153,6 +182,8 @@ typedef struct _TDFXRec { TDFXReadIndexedByteFunc readControl; TDFXWriteWordFunc writeLong; TDFXReadWordFunc readLong; + TDFXWriteChipWordFunc writeChipLong; + TDFXReadChipWordFunc readChipLong; TDFXSyncFunc sync; int syncDone; int scanlineWidth; @@ -188,6 +219,10 @@ typedef struct { #define TDFX2XCUTOFF 135000 +#ifndef PCI_CHIP_VOODOO5 +#define PCI_CHIP_VOODOO5 9 +#endif + extern Bool TDFXAccelInit(ScreenPtr pScreen); extern Bool TDFXCursorInit(ScreenPtr pScreen); extern void TDFXSync(ScrnInfoPtr pScrn); @@ -197,6 +232,7 @@ extern Bool TDFXDRIFinishScreenInit(ScreenPtr pScreen); extern Bool TDFXDGAInit(ScreenPtr pScreen); extern void TDFXCursorGrabMemory(ScreenPtr pScreen); extern void TDFXSetLFBConfig(TDFXPtr pTDFX); +extern void TDFXSendNOPPrivate(ScrnInfoPtr pScrn); extern Bool TDFXSwitchMode(int scrnIndex, DisplayModePtr mode, int flags); extern void TDFXAdjustFrame(int scrnIndex, int x, int y, int flags); @@ -221,6 +257,9 @@ extern void TDFXSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, extern void TDFXSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h); +extern void TDFXSelectBuffer(TDFXPtr pTDFX, int which); + + #ifndef PROP_3DFX #define DECLARE(a) #define DECLARE_LAUNCH(size, x) diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.man b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.man new file mode 100644 index 000000000..469b0856e --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.man @@ -0,0 +1,30 @@ +.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp,v 1.1 2000/03/03 01:05:43 dawes Exp $ +.TH TDFX 4 "Version 4.0" "XFree86" +.SH NAME +tdfx \- 3Dfx video driver +.SH SYNOPSIS +.B "Section ""Device""" +.br +.BI " Identifier """ devname """" +.br +.B " Driver ""tdfx""" +.br +\ \ ... +.br +.B EndSection +.SH DESCRIPTION +.B tdfx +is an XFree86 driver for 3Dfx video cards. +THIS MAN PAGE NEEDS TO BE FILLED IN. +.SH SUPPORTED HARDWARE +The +.B tdfx +driver supports... +.SH CONFIGURATION DETAILS +Please refer to XF86Config(5) for general configuration +details. This section only covers configuration details specific to this +driver. +.SH "SEE ALSO" +XFree86(1), XF86Config(5), xf86config(1), Xserver(1), X(1) +.SH AUTHORS +Authors include: ... diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c index 14365b441..e6db51242 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c @@ -73,21 +73,23 @@ static void TDFXSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int skipleft); static void TDFXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno); -void TDFXSelectBuffer(TDFXPtr pTDFX, int which); - void TDFXNeedSync(ScrnInfoPtr pScrn) { TDFXPtr pTDFX = TDFXPTR(pScrn); pTDFX->syncDone=FALSE; } -static void +void TDFXFirstSync(ScrnInfoPtr pScrn) { TDFXPtr pTDFX = TDFXPTR(pScrn); if (!pTDFX->syncDone) { - pTDFX->sync(pScrn); + if (pTDFX->directRenderingEnabled) { + DRILock(screenInfo.screens[pScrn->scrnIndex], 0); + TDFXSwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]); + } pTDFX->syncDone=TRUE; + pTDFX->sync(pScrn); } } @@ -98,12 +100,15 @@ TDFXCheckSync(ScrnInfoPtr pScrn) { if (pTDFX->syncDone) { pTDFX->sync(pScrn); pTDFX->syncDone=FALSE; + if (pTDFX->directRenderingEnabled) { + TDFXLostContext(screenInfo.screens[pScrn->scrnIndex]); + DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); + } } } void TDFXSelectBuffer(TDFXPtr pTDFX, int which) { -#ifdef XF86DRI int fmt; TDFXMakeRoom(pTDFX, 4); @@ -118,14 +123,20 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) { TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt); break; case TDFX_BACK: - fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */ + if (pTDFX->cpp==2) + fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */ + else + fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */ TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->backOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->backOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt); break; case TDFX_DEPTH: - fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */ + if (pTDFX->cpp==2) + fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */ + else + fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */ TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->depthOffset|BIT(31)); TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt); TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->depthOffset|BIT(31)); @@ -133,14 +144,27 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) { break; default: } -#endif } void TDFXSetLFBConfig(TDFXPtr pTDFX) { - TDFXWriteLongMMIO(pTDFX, LFBMEMORYCONFIG, (pTDFX->backOffset>>12) | - SST_RAW_LFB_ADDR_STRIDE_4K | - ((pTDFX->stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); + if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) { + TDFXWriteLongMMIO(pTDFX, LFBMEMORYCONFIG, (pTDFX->backOffset>>12) | + SST_RAW_LFB_ADDR_STRIDE_4K | + ((pTDFX->stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); + } else { + int chip; + int stride, bits; + if (pTDFX->cpp==2) stride=pTDFX->stride; + else stride=4*pTDFX->stride/pTDFX->cpp; + bits=pTDFX->backOffset>>12; + for (chip=0; chip<pTDFX->numChips; chip++) { + TDFXWriteChipLongMMIO(pTDFX, chip, LFBMEMORYCONFIG, (bits&0x1FFF) | + SST_RAW_LFB_ADDR_STRIDE_4K | + ((bits&0x6000)<<10) | + ((stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT); + } + } } Bool @@ -265,8 +289,11 @@ static void TDFXMakeRoomNoProp(TDFXPtr pTDFX, int size) { } } -static void TDFXSendNOPNoProp(TDFXPtr pTDFX) +static void TDFXSendNOPNoProp(ScrnInfoPtr pScrn) { + TDFXPtr pTDFX; + + pTDFX=TDFXPTR(pScrn); TDFXMakeRoomNoProp(pTDFX, 1); TDFXWriteLongMMIO(pTDFX, SST_2D_COMMAND, SST_2D_NOP); } @@ -280,7 +307,7 @@ void TDFXSync(ScrnInfoPtr pScrn) TDFXTRACEACCEL("TDFXSync\n"); pTDFX=TDFXPTR(pScrn); - TDFXSendNOPNoProp(pTDFX); + TDFXSendNOPNoProp(pScrn); i=0; do { stat=TDFXReadLongMMIO(pTDFX, 0); @@ -410,7 +437,7 @@ TDFXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX, int srcY, } if ((srcY>=dstY-32 && srcY<=dstY)|| (srcY>=pTDFX->prevBlitDest.y1-32 && srcY<=pTDFX->prevBlitDest.y1)) { - TDFXSendNOP(pTDFX); + TDFXSendNOP(pScrn); } pTDFX->sync(pScrn); @@ -608,8 +635,8 @@ TDFXNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n, SSTCP_SRCXY|SSTCP_COLORFORE|SSTCP_COMMAND); TDFXWriteLong(pTDFX, SST_2D_CLIP1MIN, ((pbox->y1&0x1FFF)<<16) | (pbox->x1&0x1FFF)); - TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, (((pbox->y2+1)&0x1FFF)<<16) | - ((pbox->x2+1)&0x1FFF)); + TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, ((pbox->y2&0x1FFF)<<16) | + (pbox->x2&0x1FFF)); TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, SST_2D_PIXFMT_1BPP | SST_2D_SOURCE_PACKING_DWORD); TDFXWriteLong(pTDFX, SST_2D_SRCXY, 0); @@ -736,7 +763,7 @@ TDFXSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, pTDFX->DrawState|=DRAW_STATE_CLIP1CHANGED; if (srcy>=pTDFX->prevBlitDest.y1-8 && srcy<=pTDFX->prevBlitDest.y1) { - TDFXSendNOP(pTDFX); + TDFXSendNOP(pScrn); } if (pTDFX->cpp==1) fmt=(1<<16)|pTDFX->stride; diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c index 510cfd097..11ea6f3f0 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c @@ -4,7 +4,6 @@ #include "xf86_OSproc.h" #include "xf86_ansic.h" #include "xf86Priv.h" - #include "xf86PciInfo.h" #include "xf86Pci.h" #define PSZ 8 @@ -12,11 +11,8 @@ #undef PSZ #include "cfb16.h" #include "cfb32.h" - #include "miline.h" - #include "GL/glxtokens.h" - #include "tdfx.h" #include "tdfx_dri.h" #include "tdfx_dripriv.h" @@ -24,7 +20,6 @@ static char TDFXKernelDriverName[] = "tdfx"; static char TDFXClientDriverName[] = "tdfx"; -static Bool TDFXInitVisualConfigs(ScreenPtr pScreen); static Bool TDFXCreateContext(ScreenPtr pScreen, VisualPtr visual, drmContext hwContext, void *pVisualConfigPriv, DRIContextType contextStore); @@ -48,15 +43,12 @@ TDFXInitVisualConfigs(ScreenPtr pScreen) __GLXvisualConfig *pConfigs = 0; TDFXConfigPrivPtr pTDFXConfigs = 0; TDFXConfigPrivPtr *pTDFXConfigPtrs = 0; - int i; + int i, db, stencil, accum, depth; switch (pScrn->bitsPerPixel) { case 8: - case 24: - case 32: - break; case 16: - numConfigs = 2; + numConfigs = 16; if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig), numConfigs))) { @@ -76,64 +68,167 @@ TDFXInitVisualConfigs(ScreenPtr pScreen) for (i=0; i<numConfigs; i++) pTDFXConfigPtrs[i] = &pTDFXConfigs[i]; - pConfigs[0].vid = -1; - pConfigs[0].class = -1; - pConfigs[0].rgba = TRUE; - pConfigs[0].redSize = 5; - pConfigs[0].greenSize = 6; - pConfigs[0].blueSize = 5; - pConfigs[0].redMask = 0x0000F800; - pConfigs[0].greenMask = 0x000007E0; - pConfigs[0].blueMask = 0x0000001F; - pConfigs[0].alphaMask = 0; - pConfigs[0].accumRedSize = 0; - pConfigs[0].accumGreenSize = 0; - pConfigs[0].accumBlueSize = 0; - pConfigs[0].accumAlphaSize = 0; - pConfigs[0].doubleBuffer = TRUE; - pConfigs[0].stereo = FALSE; - pConfigs[0].bufferSize = 16; - pConfigs[0].depthSize = 16; - pConfigs[0].stencilSize = 0; - pConfigs[0].auxBuffers = 0; - pConfigs[0].level = 0; - pConfigs[0].visualRating = 0; - pConfigs[0].transparentPixel = 0; - pConfigs[0].transparentRed = 0; - pConfigs[0].transparentGreen = 0; - pConfigs[0].transparentBlue = 0; - pConfigs[0].transparentAlpha = 0; - pConfigs[0].transparentIndex = 0; - - pConfigs[1].vid = -1; - pConfigs[1].class = -1; - pConfigs[1].rgba = TRUE; - pConfigs[1].redSize = 5; - pConfigs[1].greenSize = 6; - pConfigs[1].blueSize = 5; - pConfigs[1].redMask = 0x0000F800; - pConfigs[1].greenMask = 0x000007E0; - pConfigs[1].blueMask = 0x0000001F; - pConfigs[1].alphaMask = 0; - pConfigs[1].accumRedSize = 0; - pConfigs[1].accumGreenSize = 0; - pConfigs[1].accumBlueSize = 0; - pConfigs[1].accumAlphaSize = 0; - pConfigs[1].doubleBuffer = FALSE; - pConfigs[1].stereo = FALSE; - pConfigs[1].bufferSize = 16; - pConfigs[1].depthSize = 16; - pConfigs[1].stencilSize = 0; - pConfigs[1].auxBuffers = 0; - pConfigs[1].level = 0; - pConfigs[1].visualRating = 0; - pConfigs[1].transparentPixel = 0; - pConfigs[1].transparentRed = 0; - pConfigs[1].transparentGreen = 0; - pConfigs[1].transparentBlue = 0; - pConfigs[1].transparentAlpha = 0; - pConfigs[1].transparentIndex = 0; + i=0; + depth=1; + for (db = 0; db <=1; db++) { + for (depth = 0; depth<=1; depth++) { + for (accum = 0; accum <= 1; accum++) { + for (stencil = 0; stencil <= 1; stencil++) { + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 5; + pConfigs[i].greenSize = 6; + pConfigs[i].blueSize = 5; + pConfigs[i].redMask = 0x0000F800; + pConfigs[i].greenMask = 0x000007E0; + pConfigs[i].blueMask = 0x0000001F; + pConfigs[i].alphaMask = 0; + if (accum) { + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = 0; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + if (db) + pConfigs[i].doubleBuffer = TRUE; + else + pConfigs[i].doubleBuffer = FALSE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 16; + if (depth) { + if (pTDFX->cpp>2) + pConfigs[i].depthSize = 24; + else + pConfigs[i].depthSize = 16; + } else { + pConfigs[i].depthSize = 0; + } + if (stencil) + pConfigs[i].stencilSize = 8; + else + pConfigs[i].stencilSize = 0; + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (stencil || accum) + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + else + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + } + } + } + } + if (i!=numConfigs) { + ErrorF("Incorrect initialization of visuals\n"); + return FALSE; + } else ErrorF("Created %d visuals\n", numConfigs); + break; /* 16bpp */ + + case 24: + case 32: + numConfigs = 8; + pConfigs = (__GLXvisualConfig*) xnfcalloc(sizeof(__GLXvisualConfig), numConfigs); + if (!pConfigs) + return FALSE; + + pTDFXConfigs = (TDFXConfigPrivPtr) xnfcalloc(sizeof(TDFXConfigPrivRec), numConfigs); + if (!pTDFXConfigs) { + xfree(pConfigs); + return FALSE; + } + + pTDFXConfigPtrs = (TDFXConfigPrivPtr *) xnfcalloc(sizeof(TDFXConfigPrivPtr), numConfigs); + if (!pTDFXConfigPtrs) { + xfree(pConfigs); + xfree(pTDFXConfigs); + return FALSE; + } + + for (i = 0; i < numConfigs; i++) + pTDFXConfigPtrs[i] = &pTDFXConfigs[i]; + + i=0; + for (db = 0; db <=1; db++) { + for (depth = 0; depth<=1; depth++) { + /*stencil = depth;*/ /* Z and stencil share the same memory */ + for (accum = 0; accum <= 1; accum++) { + /*for (stencil = 0; stencil <=1; stencil++) {*/ + stencil = depth; + pConfigs[i].vid = -1; + pConfigs[i].class = -1; + pConfigs[i].rgba = TRUE; + pConfigs[i].redSize = 8; + pConfigs[i].greenSize = 8; + pConfigs[i].blueSize = 8; + pConfigs[i].alphaSize = (pScrn->bitsPerPixel==32) ? 8 : 0; + pConfigs[i].redMask = 0x00ff0000; + pConfigs[i].greenMask = 0x0000ff00; + pConfigs[i].blueMask = 0x000000ff; + pConfigs[i].alphaMask = (pScrn->bitsPerPixel==32) ? 0xff000000 : 0; + if (accum) { + pConfigs[i].accumRedSize = 16; + pConfigs[i].accumGreenSize = 16; + pConfigs[i].accumBlueSize = 16; + pConfigs[i].accumAlphaSize = (pScrn->bitsPerPixel==32) ? 16 : 0; + } else { + pConfigs[i].accumRedSize = 0; + pConfigs[i].accumGreenSize = 0; + pConfigs[i].accumBlueSize = 0; + pConfigs[i].accumAlphaSize = 0; + } + if (db) + pConfigs[i].doubleBuffer = TRUE; + else + pConfigs[i].doubleBuffer = FALSE; + pConfigs[i].stereo = FALSE; + pConfigs[i].bufferSize = 16; + if (depth) { + if (pTDFX->cpp > 2) + pConfigs[i].depthSize = 24; + else + pConfigs[i].depthSize = 16; + } else { + pConfigs[i].depthSize = 0; + } + if (stencil) + pConfigs[i].stencilSize = 8; + else + pConfigs[i].stencilSize = 0; + pConfigs[i].auxBuffers = 0; + pConfigs[i].level = 0; + if (accum) + pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT; + else + pConfigs[i].visualRating = GLX_NONE_EXT; + pConfigs[i].transparentPixel = 0; + pConfigs[i].transparentRed = 0; + pConfigs[i].transparentGreen = 0; + pConfigs[i].transparentBlue = 0; + pConfigs[i].transparentAlpha = 0; + pConfigs[i].transparentIndex = 0; + i++; + /*}*/ + } + } + } + if (i!=numConfigs) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "Incorrect initialization of visuals\n"); + return FALSE; + } else ErrorF("Created %d visuals\n", numConfigs); break; } pTDFX->numVisualConfigs = numConfigs; @@ -143,6 +238,26 @@ TDFXInitVisualConfigs(ScreenPtr pScreen) return TRUE; } +static void +TDFXDoWakeupHandler(int screenNum, pointer wakeupData, unsigned long result, + pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[screenNum]; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + TDFXNeedSync(pScrn); +} + +static void +TDFXDoBlockHandler(int screenNum, pointer blockData, pointer pTimeout, + pointer pReadmask) +{ + ScreenPtr pScreen = screenInfo.screens[screenNum]; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + TDFXCheckSync(pScrn); +} + Bool TDFXDRIScreenInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; @@ -150,6 +265,16 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen) DRIInfoPtr pDRIInfo; TDFXDRIPtr pTDFXDRI; + switch (pScrn->bitsPerPixel) { + case 8: + return FALSE; + case 16: + break; + case 24: + case 32: + if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) return FALSE; + } + #if XFree86LOADER /* Check that the GLX, DRI, and DRM modules have been loaded by testing for canonical symbols in each module. */ @@ -158,8 +283,21 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen) if (!LoaderSymbol("drmAvailable")) return FALSE; #endif + /* Check the DRI version */ + { + int major, minor, patch; + DRIQueryVersion(&major, &minor, &patch); + if (major != 3 || minor != 0 || patch < 0) { + xf86DrvMsg(pScreen->myNum, X_ERROR, + "TDFXDRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n", + major, minor, patch); + return FALSE; + } + } + pDRIInfo = DRICreateInfoRec(); - if (!pDRIInfo) return FALSE; + if (!pDRIInfo) + return FALSE; pTDFX->pDRIInfo = pDRIInfo; pDRIInfo->drmDriverName = TDFXKernelDriverName; @@ -169,14 +307,19 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen) ((pciConfigPtr)pTDFX->PciInfo->thisCard)->busnum, ((pciConfigPtr)pTDFX->PciInfo->thisCard)->devnum, ((pciConfigPtr)pTDFX->PciInfo->thisCard)->funcnum); - pDRIInfo->ddxDriverMajorVersion = 0; - pDRIInfo->ddxDriverMinorVersion = 1; - pDRIInfo->ddxDriverPatchVersion = 0; - pDRIInfo->frameBufferPhysicalAddress = pTDFX->LinearAddr; + pDRIInfo->ddxDriverMajorVersion = TDFX_MAJOR_VERSION; + pDRIInfo->ddxDriverMinorVersion = TDFX_MINOR_VERSION; + pDRIInfo->ddxDriverPatchVersion = TDFX_PATCHLEVEL; + pDRIInfo->frameBufferPhysicalAddress = pTDFX->LinearAddr[0]; pDRIInfo->frameBufferSize = pTDFX->FbMapSize; pDRIInfo->frameBufferStride = pTDFX->stride; pDRIInfo->ddxDrawableTableEntry = TDFX_MAX_DRAWABLES; + pDRIInfo->wrap.ValidateTree = 0; + pDRIInfo->wrap.PostValidateTree = 0; + pDRIInfo->wrap.BlockHandler = TDFXDoBlockHandler; + pDRIInfo->wrap.WakeupHandler = TDFXDoWakeupHandler; + if (SAREA_MAX_DRAWABLES < TDFX_MAX_DRAWABLES) pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES; else @@ -194,7 +337,7 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen) * in the SAREA header */ if (sizeof(XF86DRISAREARec)+sizeof(TDFXSAREAPriv)>SAREA_MAX) { - ErrorF("Data does not fit in SAREA\n"); + xf86DrvMsg(pScreen->myNum, X_ERROR, "Data does not fit in SAREA\n"); return FALSE; } pDRIInfo->SAREASize = SAREA_MAX; @@ -224,8 +367,29 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen) return FALSE; } + /* Check the TDFX DRM version */ + { + drmVersionPtr version = drmGetVersion(pTDFX->drmSubFD); + if (version) { + if (version->version_major != 1 || + version->version_minor != 0 || + version->version_patchlevel < 0) { + /* incompatible drm version */ + xf86DrvMsg(pScreen->myNum, X_ERROR, + "TDFXDRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n", + version->version_major, + version->version_minor, + version->version_patchlevel); + TDFXDRICloseScreen(pScreen); + drmFreeVersion(version); + return FALSE; + } + drmFreeVersion(version); + } + } + pTDFXDRI->regsSize=TDFXIOMAPSIZE; - if (drmAddMap(pTDFX->drmSubFD, (drmHandle)pTDFX->MMIOAddr, + if (drmAddMap(pTDFX->drmSubFD, (drmHandle)pTDFX->MMIOAddr[0], pTDFXDRI->regsSize, DRM_REGISTERS, 0, &pTDFXDRI->regs)<0) { TDFXDRICloseScreen(pScreen); return FALSE; @@ -267,8 +431,6 @@ TDFXCreateContext(ScreenPtr pScreen, VisualPtr visual, drmContext hwContext, void *pVisualConfigPriv, DRIContextType contextStore) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - TDFXPtr pTDFX = TDFXPTR(pScrn); TDFXConfigPrivPtr pTDFXConfig = (TDFXConfigPrivPtr)pVisualConfigPriv; TDFXDRIContextPtr ctx; @@ -315,14 +477,21 @@ TDFXDRISwapContext(ScreenPtr pScreen, DRISyncType syncType, DRIContextType oldContextType, void *oldContext, DRIContextType newContextType, void *newContext) { - if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && - (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ - TDFXSwapContextPrivate(pScreen); - } +#if 0 + ScrnInfoPtr pScrn; + + pScrn = xf86Screens[pScreen->myNum]; if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) && (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */ + TDFXCheckSync(pScrn); TDFXLostContext(pScreen); } + if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) && + (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */ + TDFXSwapContextPrivate(pScreen); + TDFXNeedSync(pScrn); + } +#endif } static void diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c index ec2729055..8b0c2dc38 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c @@ -35,10 +35,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* * This server does not support these XFree 4.0 features yet - * DDC1 & DDC2 (requires I2C) + * DDC2 (requires I2C) * shadowFb (if requested or acceleration is off) * Overlay planes - * DGA */ /* @@ -147,20 +146,14 @@ static void TDFXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagermentMode, int flags); #endif -#define VERSION 4000 -#define TDFX_NAME "TDFX" -#define TDFX_DRIVER_NAME "tdfx" -#define TDFX_MAJOR_VERSION 1 -#define TDFX_MINOR_VERSION 0 -#define TDFX_PATCHLEVEL 0 #define PCI_SUBDEVICE_ID_VOODOO3_2000 0x0036 #define PCI_SUBDEVICE_ID_VOODOO3_3000 0x003a DriverRec TDFX = { - VERSION, + TDFX_VERSION, TDFX_DRIVER_NAME, #if 0 - "Accelerated driver for 3dfx Voodoo Banshee and Voodoo3 cards", + "Accelerated driver for 3dfx cards", #endif TDFXIdentify, TDFXProbe, @@ -172,12 +165,14 @@ DriverRec TDFX = { static SymTabRec TDFXChipsets[] = { { PCI_CHIP_BANSHEE, "3dfx Banshee"}, { PCI_CHIP_VOODOO3, "3dfx Voodoo3"}, + { PCI_CHIP_VOODOO5, "3dfx Voodoo5"}, { -1, NULL } }; static PciChipsets TDFXPciChipsets[] = { { PCI_CHIP_BANSHEE, PCI_CHIP_BANSHEE, RES_SHARED_VGA }, { PCI_CHIP_VOODOO3, PCI_CHIP_VOODOO3, RES_SHARED_VGA }, + { PCI_CHIP_VOODOO5, PCI_CHIP_VOODOO5, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } }; @@ -187,13 +182,15 @@ static PciChipsets TDFXPciChipsets[] = { typedef enum { OPTION_NOACCEL, OPTION_SW_CURSOR, - OPTION_USE_PIO + OPTION_USE_PIO, + OPTION_NO_SLI } TDFXOpts; static OptionInfoRec TDFXOptions[] = { { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_USE_PIO, "UsePIO", OPTV_BOOLEAN, {0}, FALSE}, + { OPTION_NO_SLI, "NoSLI", OPTV_BOOLEAN, {0}, FALSE}, { -1, NULL, OPTV_NONE, {0}, FALSE} }; @@ -420,9 +417,7 @@ TDFXProbe(DriverPtr drv, int flags) { TDFXChipsets, TDFXPciChipsets, devSections, numDevSections, drv, &usedChips); - if (devSections) - xfree(devSections); - devSections=NULL; + if (numUsed<=0) return FALSE; if (flags & PROBE_DETECT) @@ -433,7 +428,7 @@ TDFXProbe(DriverPtr drv, int flags) { /* Allocate new ScrnInfoRec and claim the slot */ pScrn = xf86AllocateScreen(drv, 0); - pScrn->driverVersion = VERSION; + pScrn->driverVersion = TDFX_VERSION; pScrn->driverName = TDFX_DRIVER_NAME; pScrn->name = TDFX_NAME; pScrn->Probe = TDFXProbe; @@ -450,6 +445,7 @@ TDFXProbe(DriverPtr drv, int flags) { xf86ConfigActivePciEntity(pScrn, usedChips[i], TDFXPciChipsets, 0, 0, 0, 0, 0); } xfree(usedChips); + if (devSections) xfree(devSections); return foundScreen; } @@ -463,10 +459,11 @@ TDFXCountRam(ScrnInfoPtr pScrn) { pTDFX = TDFXPTR(pScrn); TDFXTRACE("TDFXCountRam start\n"); memSize=0; - if (pTDFX->PIOBase) { + if (pTDFX->PIOBase[0]) { CARD32 partSize, /* size of SGRAM chips in Mbits */ nChips, /* # chips of SDRAM/SGRAM */ + banks, /* Number of banks of chips */ dramInit0_strap, dramInit1_strap, dramInit1, @@ -492,23 +489,28 @@ TDFXCountRam(ScrnInfoPtr pScrn) { /* determine memory size from strapping pins (dramInit0 and dramInit1) */ dramInit0_strap = pTDFX->readLong(pTDFX, DRAMINIT0); - dramInit0_strap &= SST_SGRAM_TYPE | SST_SGRAM_NUM_CHIPSETS; - - if ( memType == MEM_TYPE_SDRAM ) { - memSize = 16; - } else { - nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS) == 0) ? 4 : 8; - - if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_8MBIT ) { - partSize = 8; - } else if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_16MBIT) { - partSize = 16; + if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) { /* Banshee/V3 */ + if (memType == MEM_TYPE_SDRAM) { + memSize = 16; } else { - ErrorF("Invalid sgram type = 0x%x", - (dramInit0_strap & SST_SGRAM_TYPE) << SST_SGRAM_TYPE_SHIFT ); - return 0; + nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS) == 0) ? 4 : 8; + + if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_8MBIT ) { + partSize = 8; + } else if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_16MBIT) { + partSize = 16; + } else { + ErrorF("Invalid sgram type = 0x%x", + (dramInit0_strap & SST_SGRAM_TYPE) << SST_SGRAM_TYPE_SHIFT ); + return 0; + } + memSize = (nChips * partSize) / 8; /* in MBytes */ } - memSize = (nChips * partSize) / 8; /* in MBytes */ + } else { /* V4, V5 */ + nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS)==0) ? 4 : 8; + partSize=1<<((dramInit0_strap&0x38000000)>>28); + banks=((dramInit0_strap&BIT(30))==0) ? 2 : 4; + memSize=nChips*partSize*banks; } TDFXTRACEREG("dramInit0 = %x dramInit1 = %x\n", dramInit0_strap, dramInit1_strap); TDFXTRACEREG("MemConfig %d chips %d size %d total\n", nChips, partSize, memSize); @@ -530,7 +532,7 @@ TDFXCountRam(ScrnInfoPtr pScrn) { extern xf86MonPtr ConfiguredMonitor; -void +static void TDFXProbeDDC(ScrnInfoPtr pScrn, int index) { vbeInfoPtr pVbe; @@ -540,6 +542,83 @@ TDFXProbeDDC(ScrnInfoPtr pScrn, int index) } } +static int TDFXCfgToSize(int cfg) +{ + if (cfg<4) return 0x8000000<<cfg; + return 0x4000000>>(cfg-4); +} + +static int TDFXSizeToCfg(int size) +{ + switch (size) { + case 0x40000000: return 3; + case 0x20000000: return 2; + case 0x10000000: return 1; + case 0x08000000: return 0; + case 0x04000000: return 4; + case 0x02000000: return 5; + case 0x01000000: return 6; + case 0x00800000: return 7; + case 0x00400000: return 8; + default: + return -1; + } +} + +static void +TDFXFindChips(ScrnInfoPtr pScrn, pciVideoPtr match) +{ + TDFXPtr pTDFX; + pciVideoPtr *ppPci; + + pTDFX=TDFXPTR(pScrn); + pTDFX->numChips=0; + pTDFX->ChipType=match->chipType; + for (ppPci = xf86GetPciVideoInfo(); *ppPci != NULL; ppPci++) { + if ((*ppPci)->bus == match->bus && + (*ppPci)->device == match->device) { + pTDFX->PciTag[pTDFX->numChips] = pciTag((*ppPci)->bus, + (*ppPci)->device, + (*ppPci)->func); + pTDFX->PIOBase[pTDFX->numChips] = (*ppPci)->ioBase[2]&0xFFFFFFFC; + pTDFX->numChips++; + } + } +} + +static void +TDFXInitChips(ScrnInfoPtr pScrn) +{ + TDFXPtr pTDFX; + int i, cfgbits, initbits; + int mem0base, mem1base, mem0size, mem0bits, mem1size, mem1bits; + + pTDFX=TDFXPTR(pScrn); + cfgbits=pciReadLong(pTDFX->PciTag[0], CFG_PCI_DECODE); + mem0base=pciReadLong(pTDFX->PciTag[0], CFG_MEM0BASE); + mem1base=pciReadLong(pTDFX->PciTag[0], CFG_MEM1BASE); + mem0size=32*1024*1024; /* Registers are always 32MB */ + mem1size=pScrn->videoRam*1024*2; /* Linear mapping is 2x memory */ + mem0bits=TDFXSizeToCfg(mem0size); + mem1bits=TDFXSizeToCfg(mem1size)<<4; + cfgbits=(cfgbits&~(0xFF))|mem0bits|mem1bits; + for (i=0; i<pTDFX->numChips; i++) { + initbits=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE); + initbits|=BIT(10); + pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits); + pTDFX->MMIOAddr[i]=mem0base+i*mem0size; + pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, 0xFFFFFFFF); + pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, pTDFX->MMIOAddr[i]); + pTDFX->MMIOAddr[i]&=0xFFFFFF00; + pTDFX->LinearAddr[i]=mem1base+i*mem1size; + pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, 0xFFFFFFFF); + pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, pTDFX->LinearAddr[i]); + pTDFX->LinearAddr[i]&=0xFFFFFF00; + pciWriteLong(pTDFX->PciTag[i], CFG_PCI_DECODE, cfgbits); + initbits&=~BIT(10); + pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits); + } +} /* * TDFXPreInit -- @@ -549,8 +628,8 @@ TDFXProbeDDC(ScrnInfoPtr pScrn, int index) * */ static Bool -TDFXPreInit(ScrnInfoPtr pScrn, int flags) { - vgaHWPtr hwp; +TDFXPreInit(ScrnInfoPtr pScrn, int flags) +{ TDFXPtr pTDFX; ClockRangePtr clockRanges; int i; @@ -558,6 +637,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { char *mod=0, *reqSym=0; int flags24; rgb defaultWeight = {0, 0, 0}; + pciVideoPtr match; TDFXTRACE("TDFXPreInit start\n"); if (pScrn->numEntities != 1) return FALSE; @@ -569,6 +649,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { pTDFX = TDFXPTR(pScrn); + pTDFX->initDone=FALSE; pTDFX->pEnt = xf86GetEntityInfo(pScrn->entityList[0]); if (pTDFX->pEnt->location.type != BUS_PCI) return FALSE; @@ -591,9 +672,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { } } - pTDFX->PciInfo = xf86GetPciInfoForEntity(pTDFX->pEnt->index); - pTDFX->PciTag = pciTag(pTDFX->PciInfo->bus, pTDFX->PciInfo->device, - pTDFX->PciInfo->func); + match=pTDFX->PciInfo=xf86GetPciInfoForEntity(pTDFX->pEnt->index); + TDFXFindChips(pScrn, match); if (xf86RegisterResources(pTDFX->pEnt->index, 0, ResNone)) return FALSE; @@ -607,6 +687,14 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { return FALSE; } + /* The vgahw module should be loaded here when needed */ + if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; + + xf86LoaderReqSymLists(vgahwSymbols, NULL); + + /* Allocate a vgaHWRec */ + if (!vgaHWGetHWRec(pScrn)) return FALSE; + /* Set pScrn->monitor */ pScrn->monitor = pScrn->confScreen->monitor; @@ -647,18 +735,9 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { } } - /* The vgahw module should be loaded here when needed */ - if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE; - - xf86LoaderReqSymLists(vgahwSymbols, NULL); - - /* Allocate a vgaHWRec */ - if (!vgaHWGetHWRec(pScrn)) return FALSE; - /* We use a programamble clock */ pScrn->progClock = TRUE; - hwp = VGAHWPTR(pScrn); pTDFX->cpp = pScrn->bitsPerPixel/8; /* Process the options */ @@ -679,7 +758,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { pTDFX->pEnt->device->chipID); } else { from = X_PROBED; - pScrn->chipset = (char *)xf86TokenToString(TDFXChipsets, pTDFX->PciInfo->chipType); + pScrn->chipset = (char *)xf86TokenToString(TDFXChipsets, match->chipType); } if (pTDFX->pEnt->device->chipRev >= 0) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n", @@ -689,11 +768,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset); if (pTDFX->pEnt->device->MemBase != 0) { - pTDFX->LinearAddr = pTDFX->pEnt->device->MemBase; + pTDFX->LinearAddr[0] = pTDFX->pEnt->device->MemBase; from = X_CONFIG; } else { - if (pTDFX->PciInfo->memBase[1] != 0) { - pTDFX->LinearAddr = pTDFX->PciInfo->memBase[1]; + if (match->memBase[1] != 0) { + pTDFX->LinearAddr[0] = match->memBase[1]; from = X_PROBED; } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -706,11 +785,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { (unsigned long)pTDFX->LinearAddr); if (pTDFX->pEnt->device->IOBase != 0) { - pTDFX->MMIOAddr = pTDFX->pEnt->device->IOBase; + pTDFX->MMIOAddr[0] = pTDFX->pEnt->device->IOBase; from = X_CONFIG; } else { - if (pTDFX->PciInfo->memBase[0]) { - pTDFX->MMIOAddr = pTDFX->PciInfo->memBase[0]; + if (match->memBase[0]) { + pTDFX->MMIOAddr[0] = match->memBase[0]; from = X_PROBED; } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, @@ -722,8 +801,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at addr 0x%lX\n", (unsigned long)pTDFX->MMIOAddr); - if (pTDFX->PciInfo->ioBase[2]) { - pTDFX->PIOBase = pTDFX->PciInfo->ioBase[2]&0xFFFFFFFC; + if (match->ioBase[2]) { + pTDFX->PIOBase[0] = match->ioBase[2]&0xFFFFFFFC; } else { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid PIO address in PCI config space\n"); @@ -731,7 +810,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "PIO registers at addr 0x%lX\n", - (unsigned long)pTDFX->PIOBase); + (unsigned long)pTDFX->PIOBase[0]); /* We have to use PIO to probe, because we haven't mappend yet */ TDFXSetPIOAccess(pTDFX); @@ -744,6 +823,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { from = X_CONFIG; } + TDFXInitChips(pScrn); + /* Multiple by two because tiled access requires more address space */ pTDFX->FbMapSize = pScrn->videoRam*1024*2; xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte Mapping %d kByte\n", @@ -778,12 +859,12 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { pTDFX->MaxClock = pTDFX->pEnt->device->dacSpeeds[0]; from = X_CONFIG; } else { - switch (pTDFX->PciInfo->chipType) { + switch (pTDFX->ChipType) { case PCI_CHIP_BANSHEE: pTDFX->MaxClock = 270000; break; case PCI_CHIP_VOODOO3: - switch(pTDFX->PciInfo->subsysCard) { + switch(match->subsysCard) { case PCI_SUBDEVICE_ID_VOODOO3_2000: pTDFX->MaxClock = 300000; break; @@ -795,6 +876,9 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { break; } break; + case PCI_CHIP_VOODOO5: + pTDFX->MaxClock = 350000; + break; } } clockRanges = xnfalloc(sizeof(ClockRange)); @@ -802,7 +886,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { clockRanges->minClock= 12000; /* !!! What's the min clock? !!! */ clockRanges->maxClock=pTDFX->MaxClock; clockRanges->clockIndex = -1; - clockRanges->interlaceAllowed = TRUE; + clockRanges->interlaceAllowed = FALSE; clockRanges->doubleScanAllowed = TRUE; i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, @@ -887,21 +971,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { xf86SetDDCproperties(pScrn,xf86PrintEDID(pMon)); } - - /* We wont be using the VGA access after the probe */ - if (!xf86ReturnOptValBool(TDFXOptions, OPTION_USE_PIO, FALSE)) { - resRange vgaio[] = { {ResShrIoBlock,0x3B0,0x3BB}, - {ResShrIoBlock,0x3C0,0x3DF}, - _END }; - resRange vgamem[] = {{ResShrMemBlock,0xA0000,0xAFFFF}, - {ResShrMemBlock,0xB8000,0xBFFFF}, - {ResShrMemBlock,0xB0000,0xB7FFF}, - _END }; - - pTDFX->usePIO=FALSE; - xf86SetOperatingState(vgaio, pTDFX->pEnt->index, ResUnusedOpr); - xf86SetOperatingState(vgamem, pTDFX->pEnt->index, ResDisableOpr); - } else { + if (xf86ReturnOptValBool(TDFXOptions, OPTION_USE_PIO, FALSE)) { pTDFX->usePIO=TRUE; } @@ -911,7 +981,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) { static Bool TDFXMapMem(ScrnInfoPtr pScrn) { - int mmioFlags; + int mmioFlags, i; TDFXPtr pTDFX; TDFXTRACE("TDFXMapMem start\n"); @@ -919,15 +989,18 @@ TDFXMapMem(ScrnInfoPtr pScrn) mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT; - pTDFX->MMIOBase = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, - pTDFX->PciTag, - pTDFX->MMIOAddr, - TDFXIOMAPSIZE); - if (!pTDFX->MMIOBase) return FALSE; + for (i=0; i<pTDFX->numChips; i++) { + pTDFX->MMIOBase[i] = xf86MapPciMem(pScrn->scrnIndex, mmioFlags, + pTDFX->PciTag[i], + pTDFX->MMIOAddr[i], + TDFXIOMAPSIZE); + + if (!pTDFX->MMIOBase[i]) return FALSE; + } pTDFX->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, - pTDFX->PciTag, - pTDFX->LinearAddr, + pTDFX->PciTag[0], + pTDFX->LinearAddr[0], pTDFX->FbMapSize); if (!pTDFX->FbBase) return FALSE; @@ -938,12 +1011,16 @@ static Bool TDFXUnmapMem(ScrnInfoPtr pScrn) { TDFXPtr pTDFX; + int i; TDFXTRACE("TDFXUnmapMem start\n"); pTDFX = TDFXPTR(pScrn); - xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->MMIOBase, TDFXIOMAPSIZE); - pTDFX->MMIOBase=0; + for (i=0; i<pTDFX->numChips; i++) { + xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->MMIOBase[i], + TDFXIOMAPSIZE); + pTDFX->MMIOBase[i]=0; + } xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->FbBase, pTDFX->FbMapSize); pTDFX->FbBase = 0; @@ -1118,12 +1195,20 @@ TDFXRestore(ScrnInfoPtr pScrn) { #define REFFREQ 14318.18 static int -CalcPLL(int freq, int *f_out) { +CalcPLL(int freq, int *f_out, int isBanshee) { int m, n, k, best_m, best_n, best_k, f_cur, best_error; + int minm, maxm; TDFXTRACE("CalcPLL start\n"); best_error=freq; best_n=best_m=best_k=0; + if (isBanshee) { + minm=24; + maxm=24; + } else { + minm=1; + maxm=64; + } for (n=1; n<256; n++) { f_cur=REFFREQ*(n+2); if (f_cur<freq) { @@ -1136,7 +1221,7 @@ CalcPLL(int freq, int *f_out) { continue; } } - for (m=1; m<64; m++) { + for (m=minm; m<maxm; m++) { for (k=0; k<4; k++) { f_cur=REFFREQ*(n+2)/(m+2)/(1<<k); if (abs(f_cur-freq)<best_error) { @@ -1175,7 +1260,7 @@ SetupVidPLL(ScrnInfoPtr pScrn, DisplayModePtr mode) { tdfxReg->dacmode|=SST_DAC_MODE_2X; tdfxReg->vidcfg|=SST_VIDEO_2X_MODE_EN; } - tdfxReg->vidpll=CalcPLL(freq, &f_out); + tdfxReg->vidpll=CalcPLL(freq, &f_out, 0); TDFXTRACEREG("Vid PLL freq=%d f_out=%d reg=%x\n", freq, f_out, tdfxReg->vidpll); return TRUE; @@ -1207,7 +1292,10 @@ SetupGfxPLL(int freq) { TDFXTRACE("SetupGfxPLL start\n"); pTDFX=TDFXPTR(); tdfxReg=(vgaTDFXPtr)vgaNewVideoState; - tdfxReg->gfxpll=CalcPLL(freq, &f_out); + if (pTDFX->chipType==PCI_CHIP_BANSHEE) + tdfxReg->gfxpll=CalcPLL(freq, &f_out, 1); + else + tdfxReg->gfxpll=CalcPLL(freq, &f_out, 0); pTDFX->writeLong(pTDFX, PLLCTRL2, tdfxReg->gfxpll); TDFXTRACEREG("Gfx PLL freq=%d f_out=%d reg=%x\n", freq, f_out, tdfxReg->gfxpll); @@ -1218,14 +1306,13 @@ SetupGfxPLL(int freq) { static Bool TDFXInitVGA(ScrnInfoPtr pScrn) { - static Bool initDone=FALSE; TDFXPtr pTDFX; TDFXRegPtr tdfxReg; TDFXTRACE("TDFXInitVGA start\n"); - if (initDone) return TRUE; - initDone=TRUE; pTDFX=TDFXPTR(pScrn); + if (pTDFX->initDone) return TRUE; + pTDFX->initDone=TRUE; tdfxReg = &pTDFX->ModeReg; tdfxReg->vgainit0 = 0; tdfxReg->vgainit0 |= SST_VGA0_EXTENSIONS; @@ -1240,8 +1327,9 @@ TDFXInitVGA(ScrnInfoPtr pScrn) tdfxReg->vidcfg = SST_VIDEO_PROCESSOR_EN | SST_CURSOR_X11 | SST_DESKTOP_EN | (pTDFX->cpp-1)<<SST_DESKTOP_PIXEL_FORMAT_SHIFT; - if (pTDFX->cpp!=1) tdfxReg->vidcfg |= SST_DESKTOP_CLUT_BYPASS; + /* tdfxReg->vidcfg |= SST_DESKTOP_CLUT_BYPASS; */ + tdfxReg->stride = pTDFX->stride; tdfxReg->clip0min = tdfxReg->clip1min = 0; @@ -1377,8 +1465,9 @@ TDFXModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) #endif DoRestore(pScrn, &hwp->ModeReg, &pTDFX->ModeReg, FALSE); #ifdef XF86DRI - if (pTDFX->directRenderingEnabled) + if (pTDFX->directRenderingEnabled) { DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); + } #endif return TRUE; @@ -1388,30 +1477,37 @@ static void TDFXLoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, short visualClass) { TDFXPtr pTDFX; - vgaHWPtr hwp; - int i, index; - unsigned char r, g, b; + int i, j, index, v, repeat, max; TDFXTRACE("TDFXLoadPalette16 start\n"); pTDFX = TDFXPTR(pScrn); - hwp = VGAHWPTR(pScrn); for (i=0; i<numColors; i++) { - index=indices[i/2]; - r=colors[index].red; - b=colors[index].blue; - index=indices[i]; - g=colors[index].green; - hwp->writeDacWriteAddr(hwp, index<<2); - hwp->writeDacData(hwp, r); - hwp->writeDacData(hwp, g); - hwp->writeDacData(hwp, b); - i++; index=indices[i]; - g=colors[index].green; - hwp->writeDacWriteAddr(hwp, index<<2); - hwp->writeDacData(hwp, r); - hwp->writeDacData(hwp, g); - hwp->writeDacData(hwp, b); + v=(colors[index/2].red<<16)|(colors[index].green<<8)|colors[index/2].blue; + if (i<numColors-1) max=indices[i+1]<<2; + else max=256; + for (j=index<<2; j<max; j++) { + repeat=100; + do { + pTDFX->writeLong(pTDFX, DACADDR, j); + } while (--repeat && pTDFX->readLong(pTDFX, DACADDR)!=j); + if (!repeat) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac index, " + "bypassing CLUT\n"); + pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS; + return; + } + repeat=100; + do { + pTDFX->writeLong(pTDFX, DACDATA, v); + } while (--repeat && pTDFX->readLong(pTDFX, DACDATA)!=v); + if (!repeat) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac value, " + "bypassing CLUT\n"); + pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS; + return; + } + } } } @@ -1419,23 +1515,33 @@ static void TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, short visualClass) { TDFXPtr pTDFX; - vgaHWPtr hwp; - int i, index; - unsigned char r, g, b; + int i, index, v, repeat; TDFXTRACE("TDFXLoadPalette24 start\n"); pTDFX = TDFXPTR(pScrn); - hwp = VGAHWPTR(pScrn); for (i=0; i<numColors; i++) { index=indices[i]; - r=colors[index].red; - b=colors[index].blue; - index=indices[i]; - g=colors[index].green; - hwp->writeDacWriteAddr(hwp, index); - hwp->writeDacData(hwp, r); - hwp->writeDacData(hwp, g); - hwp->writeDacData(hwp, b); + v=(colors[index].red<<16)|(colors[index].green<<8)|colors[index].blue; + repeat=100; + do { + pTDFX->writeLong(pTDFX, DACADDR, index); + } while (--repeat && pTDFX->readLong(pTDFX, DACADDR)!=index); + if (!repeat) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac index, " + "bypassing CLUT\n"); + pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS; + return; + } + repeat=100; + do { + pTDFX->writeLong(pTDFX, DACDATA, v); + } while (--repeat && pTDFX->readLong(pTDFX, DACDATA)!=v); + if (!repeat) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac value, " + "bypassing CLUT\n"); + pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS; + return; + } } } @@ -1443,20 +1549,17 @@ TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors, #define TILE_HEIGHT 32 static int -calcBufferStride(int xres, Bool tiled) +calcBufferStride(int xres, Bool tiled, int cpp) { int strideInTiles; if (tiled == TRUE) { /* Calculate tile width stuff */ - strideInTiles = (xres << 1) >> 7; - if ((xres << 1) & (TILE_WIDTH - 1)) - strideInTiles++; + strideInTiles = (xres+TILE_WIDTH-1)/TILE_WIDTH; - return (strideInTiles * TILE_WIDTH); - + return strideInTiles*cpp*TILE_WIDTH; } else { - return (xres << 1); + return xres*cpp; } } /* calcBufferStride */ @@ -1477,26 +1580,26 @@ calcBufferHeightInTiles(int yres) } /* calcBufferHeightInTiles */ static int -calcBufferSizeInTiles(int xres, int yres) { +calcBufferSizeInTiles(int xres, int yres, int cpp) { int bufSizeInTiles; /* Size of buffer in tiles */ bufSizeInTiles = - calcBufferHeightInTiles(yres) * (calcBufferStride(xres, TRUE) >> 7); + calcBufferHeightInTiles(yres) * (calcBufferStride(xres, TRUE, cpp) >> 7); return bufSizeInTiles; } /* calcBufferSizeInTiles */ static int -calcBufferSize(int xres, int yres, Bool tiled) +calcBufferSize(int xres, int yres, Bool tiled, int cpp) { int stride, height, bufSize; if (tiled) { - stride = calcBufferStride(xres, tiled); + stride = calcBufferStride(xres, tiled, cpp); height = TILE_HEIGHT * calcBufferHeightInTiles(yres); } else { - stride = xres << 1; + stride = xres*cpp; height = yres; } @@ -1522,7 +1625,15 @@ static void allocateMemory(ScrnInfoPtr pScrn) { /* Remove one scanline for page alignment */ memRemaining-=4095; /* Remove the back and Z buffers */ - screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE); + if (pTDFX->cpp!=3) { + screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, + TRUE, pTDFX->cpp); + } + else { + /* cpp==3 needs to bump up to 4 */ + screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, + TRUE, 4); + } memRemaining-=screenSizeInTiles*2; /* Give all the rest to textures, rounded down to a page */ @@ -1580,18 +1691,22 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { if (!TDFXMapMem(pScrn)) return FALSE; pScrn->memPhysBase = (int)pTDFX->LinearAddr; - if (!pTDFX->usePIO) { - TDFXSetMMIOAccess(pTDFX); - hwp->IOBase = ((hwp->readMiscOut(hwp) & 0x01) ? - VGA_IOBASE_COLOR : VGA_IOBASE_MONO) + (unsigned long)pTDFX->MMIOBase - - 0x300; - } else { - vgaHWGetIOBase(hwp); - } + if (!pTDFX->usePIO) TDFXSetMMIOAccess(pTDFX); + vgaHWGetIOBase(hwp); if (!vgaHWMapMem(pScrn)) return FALSE; allocateMemory(pScrn); + if (pTDFX->numChips>1) { + if (xf86ReturnOptValBool(TDFXOptions, OPTION_NO_SLI, FALSE)) { + TDFXSetupSLI(pScrn, FALSE, 0); + } else { + TDFXSetupSLI(pScrn, TRUE, 0); + } + } + + TDFXSetLFBConfig(pTDFX); + #ifdef PROP_3DFX if (!TDFXInitPrivate(pScreen)) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize private\n"); @@ -1739,7 +1854,6 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { } if (pTDFX->directRenderingEnabled) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n"); - TDFXSetLFBConfig(pTDFX); } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n"); } @@ -1806,6 +1920,7 @@ TDFXEnterVT(int scrnIndex, int flags) { if (pTDFX->directRenderingEnabled) { pScreen = screenInfo.screens[scrnIndex]; DRIUnlock(pScreen); + TDFXLostContext(pScreen); } #endif if (!TDFXModeInit(pScrn, pScrn->currentMode)) return FALSE; @@ -1832,6 +1947,7 @@ TDFXLeaveVT(int scrnIndex, int flags) { pTDFX = TDFXPTR(pScrn); if (pTDFX->directRenderingEnabled) { DRILock(pScreen, 0); + TDFXSwapContextPrivate(pScreen); } #endif } @@ -1978,3 +2094,4 @@ TDFXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode, pTDFX->writeLong(pTDFX, DACMODE, dacmode); } #endif + diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c index 62b883a16..73a8b4604 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c @@ -39,27 +39,35 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "tdfx.h" -#define minb(p) MMIO_IN8(pTDFX->MMIOBase, (p)) -#define moutb(p,v) MMIO_OUT8(pTDFX->MMIOBase, (p),(v)) -#define minl(p) MMIO_IN32(pTDFX->MMIOBase, (p)) -#define moutl(p,v) MMIO_OUT32(pTDFX->MMIOBase, (p),(v)) +#define minb(b, p) MMIO_IN8((b), (p)) +#define moutb(b, p,v) MMIO_OUT8((b), (p),(v)) +#define minl(b, p) MMIO_IN32((b), (p)) +#define moutl(b, p,v) MMIO_OUT32((b), (p),(v)) static void TDFXWriteControlPIO(TDFXPtr pTDFX, int addr, char index, char val) { - outb(pTDFX->PIOBase+addr, index); - outb(pTDFX->PIOBase+addr+1, val); + outb(pTDFX->PIOBase[0]+addr, index); + outb(pTDFX->PIOBase[0]+addr+1, val); } static char TDFXReadControlPIO(TDFXPtr pTDFX, int addr, char index) { - outb(pTDFX->PIOBase+addr, index); - return inb(pTDFX->PIOBase+addr+1); + outb(pTDFX->PIOBase[0]+addr, index); + return inb(pTDFX->PIOBase[0]+addr+1); +} + +void TDFXWriteChipLongPIO(TDFXPtr pTDFX, int chip, int addr, int val) { + outl(pTDFX->PIOBase[chip]+addr, val); +} + +int TDFXReadChipLongPIO(TDFXPtr pTDFX, int chip, int addr) { + return inl(pTDFX->PIOBase[chip]+addr); } static void TDFXWriteLongPIO(TDFXPtr pTDFX, int addr, int val) { - outl(pTDFX->PIOBase+addr, val); + TDFXWriteChipLongPIO(pTDFX, 0, addr, val); } static int TDFXReadLongPIO(TDFXPtr pTDFX, int addr) { - return inl(pTDFX->PIOBase+addr); + return TDFXReadChipLongPIO(pTDFX, 0, addr); } void TDFXSetPIOAccess(TDFXPtr pTDFX) { @@ -69,24 +77,34 @@ void TDFXSetPIOAccess(TDFXPtr pTDFX) { pTDFX->readControl=TDFXReadControlPIO; pTDFX->writeLong=TDFXWriteLongPIO; pTDFX->readLong=TDFXReadLongPIO; + pTDFX->readChipLong=TDFXReadChipLongPIO; + pTDFX->writeChipLong=TDFXWriteChipLongPIO; } static void TDFXWriteControlMMIO(TDFXPtr pTDFX, int addr, char index, char val) { - moutb(addr, index); - moutb(addr+1, val); + moutb(pTDFX->MMIOBase[0], addr, index); + moutb(pTDFX->MMIOBase[0], addr+1, val); } static char TDFXReadControlMMIO(TDFXPtr pTDFX, int addr, char index) { - moutb(addr, index); - return minb(addr+1); + moutb(pTDFX->MMIOBase[0], addr, index); + return minb(pTDFX->MMIOBase[0], addr+1); +} + +void TDFXWriteChipLongMMIO(TDFXPtr pTDFX, int chip, int addr, int val) { + moutl(pTDFX->MMIOBase[chip], addr, val); +} + +static int TDFXReadChipLongMMIO(TDFXPtr pTDFX, int chip, int addr) { + return minl(pTDFX->MMIOBase[chip], addr); } void TDFXWriteLongMMIO(TDFXPtr pTDFX, int addr, int val) { - moutl(addr, val); + TDFXWriteChipLongMMIO(pTDFX, 0, addr, val); } int TDFXReadLongMMIO(TDFXPtr pTDFX, int addr) { - return minl(addr); + return TDFXReadChipLongMMIO(pTDFX, 0, addr); } void TDFXSetMMIOAccess(TDFXPtr pTDFX) { @@ -96,5 +114,7 @@ void TDFXSetMMIOAccess(TDFXPtr pTDFX) { pTDFX->readControl=TDFXReadControlMMIO; pTDFX->writeLong=TDFXWriteLongMMIO; pTDFX->readLong=TDFXReadLongMMIO; + pTDFX->writeChipLong=TDFXWriteChipLongMMIO; + pTDFX->readChipLong=TDFXReadChipLongMMIO; } diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c index e8a75056f..0d09b79dd 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c @@ -23,28 +23,41 @@ C - D-1 : Z buffer */ -void TDFXSendNOPPrivate2D(TDFXPtr pTDFX) +void TDFXSendNOPPrivate3D(ScrnInfoPtr pScrn) { + TDFXPtr pTDFX; + + if (!pTDFX->syncDone) { + TDFXFirstSync(pScrn); + return; + } + pTDFX=TDFXPTR(pScrn); TDFXAllocateSlots(pTDFX, 2); - SET_3DPK4_HEADER(1, 0x48); + SET_3DPK4_HEADER(1, 0x48<<3); WRITE_FIFO(pTDFX, 0, 0); } -void TDFXSendNOPPrivate3D(TDFXPtr pTDFX) +void TDFXSendNOPPrivate2D(ScrnInfoPtr pScrn) { + TDFXPtr pTDFX; + + pTDFX=TDFXPTR(pScrn); TDFXAllocateSlots(pTDFX, 2); SET_PKT2_HEADER(SSTCP_COMMAND); WRITE_FIFO(pTDFX, SST_2D_COMMAND, SST_2D_NOP|SST_2D_GO); } -void TDFXSendNOPPrivate(TDFXPtr pTDFX) +void TDFXSendNOPPrivate(ScrnInfoPtr pScrn) { - TDFXSendNOPPrivate2D(pTDFX); - TDFXSendNOPPrivate3D(pTDFX); + TDFXSendNOPPrivate2D(pScrn); + TDFXSendNOPPrivate3D(pScrn); } -void InstallFifo(TDFXPtr pTDFX) +void InstallFifo(ScrnInfoPtr pScrn) { + TDFXPtr pTDFX; + + pTDFX=TDFXPTR(pScrn); /* Install the fifo */ TDFXWriteLongMMIO(pTDFX, SST_FIFO_BASEADDR0, pTDFX->fifoOffset>>12); TDFXWriteLongMMIO(pTDFX, SST_FIFO_BUMP0, 0); @@ -54,7 +67,7 @@ void InstallFifo(TDFXPtr pTDFX) TDFXWriteLongMMIO(pTDFX, SST_FIFO_AMAX0, pTDFX->fifoOffset-4); TDFXWriteLongMMIO(pTDFX, SST_FIFO_DEPTH0, 0); TDFXWriteLongMMIO(pTDFX, SST_FIFO_HOLECNT0, 0); - if (pTDFX->PciInfo->chipType == PCI_CHIP_BANSHEE) + if (pTDFX->ChipType == PCI_CHIP_BANSHEE) TDFXWriteLongMMIO(pTDFX, SST_FIFO_FIFOTHRESH, (0x9<<5) | 0x2); else TDFXWriteLongMMIO(pTDFX, SST_FIFO_FIFOTHRESH, (0xf<<5) | 0x8); @@ -65,14 +78,16 @@ void InstallFifo(TDFXPtr pTDFX) pTDFX->fifoPtr = pTDFX->fifoBase; pTDFX->fifoSlots = (pTDFX->fifoSize>>2) - 1; pTDFX->fifoEnd = pTDFX->fifoBase+pTDFX->fifoSlots; - TDFXSendNOPPrivate(pTDFX); + TDFXSendNOPPrivate(pScrn); } -void TDFXResetFifo(TDFXPtr pTDFX) +void TDFXResetFifo(ScrnInfoPtr pScrn) { + TDFXPtr pTDFX; int oldValue; CARD32 start_sec, end_sec, dummy; + pTDFX=TDFXPTR(pScrn); ErrorF("Resetting FIFO\n"); /* Shut down the fifo */ TDFXWriteLongMMIO(pTDFX, SST_FIFO_BASESIZE0, 0); @@ -91,7 +106,7 @@ void TDFXResetFifo(TDFXPtr pTDFX) xf86getsecs(&end_sec, &dummy); } while (end_sec-start_sec<2); TDFXWriteLongMMIO(pTDFX, MISCINIT1, oldValue); - InstallFifo(pTDFX); + InstallFifo(pScrn); } /* @@ -102,7 +117,7 @@ void TDFXResetFifo(TDFXPtr pTDFX) !!! We should use expedential backoff in our reads !!! */ -void TDFXSyncFifo(ScrnInfoPtr pScrn) +static void TDFXSyncFifo(ScrnInfoPtr pScrn) { TDFXPtr pTDFX; int i, cnt; @@ -111,7 +126,7 @@ void TDFXSyncFifo(ScrnInfoPtr pScrn) TDFXTRACEACCEL("TDFXSyncFifo start\n"); pTDFX=TDFXPTR(pScrn); - TDFXSendNOPPrivate(pTDFX); + TDFXSendNOPPrivate(pScrn); i=0; cnt=0; start_sec=0; @@ -125,7 +140,7 @@ void TDFXSyncFifo(ScrnInfoPtr pScrn) } else { xf86getsecs(&end_sec, &dummy); if (end_sec-start_sec>3) { - TDFXResetFifo(pTDFX); + TDFXResetFifo(pScrn); start_sec=0; } } @@ -153,7 +168,7 @@ Bool TDFXInitPrivate(ScreenPtr pScreen) pTDFX->fifoMirrorPtr = pTDFX->fifoMirrorBase; #endif pTDFX->sync=TDFXSyncFifo; - InstallFifo(pTDFX); + InstallFifo(pScrn); return TRUE; } @@ -190,7 +205,6 @@ void TDFXSwapContextPrivate(ScreenPtr pScreen) ScrnInfoPtr pScrn; TDFXPtr pTDFX; int dummy, readPos; - int offset; TDFXSAREAPriv *sPriv; pScrn = xf86Screens[pScreen->myNum]; @@ -214,7 +228,7 @@ void TDFXSwapContextPrivate(ScreenPtr pScreen) (sPriv->fifoRead<pTDFX->fifoOffset) || (sPriv->fifoRead>(int)pTDFX->fifoOffset+pTDFX->fifoSize)) { ErrorF("Invalid offsets passed between client and X server\n"); - ResetFifo(pTDFX); + ResetFifo(pScrn); } else { pTDFX->fifoPtr = (unsigned int *)(pTDFX->FbBase+sPriv->fifoPtr); pTDFX->fifoRead = (unsigned int *)(pTDFX->FbBase+sPriv->fifoRead); @@ -226,7 +240,8 @@ void TDFXSwapContextPrivate(ScreenPtr pScreen) pTDFX->fifoSlots = pTDFX->fifoEnd-pTDFX->fifoPtr-8; } -void TDFXLostContext(ScreenPtr pScreen) { +void TDFXLostContext(ScreenPtr pScreen) +{ ScrnInfoPtr pScrn; TDFXPtr pTDFX; TDFXSAREAPriv *sPriv; @@ -312,7 +327,8 @@ TDFXMakeSpace(TDFXPtr pTDFX, uint32 slots) } void -TDFXAllocateSlots(TDFXPtr pTDFX, int slots) { +TDFXAllocateSlots(TDFXPtr pTDFX, int slots) +{ #ifdef TDFX_DEBUG_FIFO if (pTDFX->fifoEnd-pTDFX->fifoPtr<pTDFX->fifoSlots) ErrorF("FIFO overrun\n"); diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c new file mode 100644 index 000000000..fd442c49d --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c @@ -0,0 +1,768 @@ + +#include "xf86.h" +#include "xf86_ansic.h" +#include "xf86_OSproc.h" +#include "xf86Pci.h" +#include "tdfx.h" + +#define AACLKOUTDEL 0x2 +#define CFGSWAPALGORITHM 0x1 + +/* #define RD_ABORT_ERROR */ +#define H3VDD + +static Bool TDFXDisableSLI(TDFXPtr pTDFX) +{ + int i; + int v; + + for (i=0; i<pTDFX->numChips; i++) { + v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE); + pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, + v&~(CFG_SNOOP_MEMBASE0 | CFG_SNOOP_EN | CFG_SNOOP_MEMBASE0_EN | + CFG_SNOOP_MEMBASE1_EN | CFG_SNOOP_SLAVE | + CFG_SNOOP_FBIINIT_WR_EN | CFG_SWAP_ALGORITHM | + CFG_SWAP_QUICK)); + v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL); + pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL, + v&~(CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN | + CFG_SLI_RD_EN)); +#ifdef H3VDD + pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL, 0); + pTDFX->writeChipLong(pTDFX, i, SST_3D_AACTRL, 0); +#endif + v=pciReadLong(pTDFX->PciTag[i], CFG_AA_LFB_CTRL); + pciWriteLong(pTDFX->PciTag[i], CFG_AA_LFB_CTRL, + v&~(CFG_AA_LFB_CPU_WR_EN | CFG_AA_LFB_DPTCH_WR_EN | + CFG_AA_LFB_RD_EN)); + v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC); + pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC, + (v&~CFG_VGA_VSYNC_OFFSET) | + (0 << CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT) | + (0 << CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT) | + (0 << CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, 0); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, 0); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, 0); + + if (pTDFX->numChips>1) { + v=pTDFX->readChipLong(pTDFX, i, PCIINIT0); + pTDFX->writeChipLong(pTDFX, i, PCIINIT0, + (v&~(SST_PCI_DISABLE_IO|SST_PCI_DISABLE_MEM| + SST_PCI_RETRY_INTERVAL)) | + (0<<SST_PCI_RETRY_INTERVAL_SHIFT) | + SST_PCI_FORCE_FB_HIGH); + } else { + v=pTDFX->readChipLong(pTDFX, i, PCIINIT0); + pTDFX->writeChipLong(pTDFX, i, PCIINIT0, + (v&~(SST_PCI_DISABLE_IO|SST_PCI_DISABLE_MEM| + SST_PCI_RETRY_INTERVAL)) | + (0<<SST_PCI_RETRY_INTERVAL_SHIFT)); + } + +#if 0 + if (i>0) { + pTDFX->writeChipLong(pTDFX, i, DACMODE, + SST_DAC_DPMS_ON_VSYNC | SST_DAC_DPMS_ON_HSYNC); + v=pTDFX->readChipLong(pTDFX, i, VIDPROCCFG); + pTDFX->writeChipLong(pTDFX, i, VIDPROCCFG, v&~SST_VIDEO_PROCESSOR_EN); + } +#endif + } + return TRUE; +} + +Bool TDFXSetupSLI(ScrnInfoPtr pScrn, Bool sliEnable, int aaSamples) +{ + TDFXPtr pTDFX; + int i, sliLines, sliLinesLog2, nChipsLog2, v; + int sli_renderMask, sli_compareMask, sli_scanMask; + int sliAnalog, dwFormat; + + pTDFX=TDFXPTR(pScrn); + if (pScrn->depth == 24 || pScrn->depth==32) { + if ((aaSamples == 4) && (pTDFX->numChips>1)) { + pTDFX->pixelFormat=GR_PIXFMT_AA_4_ARGB_8888; + } else if (aaSamples >= 2) { + pTDFX->pixelFormat=GR_PIXFMT_AA_2_ARGB_8888; + } else { + pTDFX->pixelFormat=GR_PIXFMT_ARGB_8888; + } + } else if (pScrn->depth == 16) { + if ((aaSamples == 4) && (pTDFX->numChips>1)) { + pTDFX->pixelFormat=GR_PIXFMT_AA_4_RGB_565; + } else if (aaSamples >= 2) { + pTDFX->pixelFormat=GR_PIXFMT_AA_2_RGB_565; + } else { + pTDFX->pixelFormat=GR_PIXFMT_RGB_565; + } + } else if (pScrn->depth == 8) { + pTDFX->pixelFormat=GR_PIXFMT_I_8; + } + if (!sliEnable && !aaSamples) { /* Turn off */ + return TDFXDisableSLI(pTDFX); + } + + if (pScrn->virtualY>768) sliLinesLog2=5; + else sliLinesLog2=4; + sliLines=1<<sliLinesLog2; + if (pScrn->virtualY*pScrn->virtualX>1600*1024) sliAnalog=1; + else sliAnalog=0; + /* XXX We need to avoid SLI in double scan modes somehow */ + + switch (pTDFX->numChips) { + case 1: + nChipsLog2=0; + break; + case 2: + nChipsLog2=1; + break; + case 4: + nChipsLog2=2; + break; + default: + return FALSE; + /* XXX Huh? Unsupported configuration */ + } + + for (i=0; i<pTDFX->numChips; i++) { + /* Do we want to set these differently for a VIA board? */ + v=pTDFX->readChipLong(pTDFX, i, PCIINIT0); + v=(v&~(SST_PCI_RETRY_INTERVAL|SST_PCI_FORCE_FB_HIGH)) | + SST_PCI_READ_WS | SST_PCI_WRITE_WS | + SST_PCI_DISABLE_IO | SST_PCI_DISABLE_MEM | + (5<<SST_PCI_RETRY_INTERVAL_SHIFT); + pTDFX->writeChipLong(pTDFX, i, PCIINIT0, + (v&~(SST_PCI_RETRY_INTERVAL|SST_PCI_FORCE_FB_HIGH)) | + SST_PCI_READ_WS | SST_PCI_WRITE_WS | + SST_PCI_DISABLE_IO | SST_PCI_DISABLE_MEM | + (5<<SST_PCI_RETRY_INTERVAL_SHIFT)); + v=pTDFX->readChipLong(pTDFX, i, TMUGBEINIT); + pTDFX->writeChipLong(pTDFX, i, TMUGBEINIT, + (v&~(SST_AA_CLK_DELAY | SST_AA_CLK_INVERT)) | + (AACLKOUTDEL<<SST_AA_CLK_DELAY_SHIFT) | + SST_AA_CLK_INVERT); + + if (pTDFX->numChips>1) { + v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE); + pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, v | + (CFGSWAPALGORITHM << CFG_SWAPBUFFER_ALGORITHM_SHIFT) | + CFG_SWAP_ALGORITHM | ((!i)? CFG_SWAP_MASTER : 0)); + if (!i) { + v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE); + pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, + v | CFG_SNOOP_EN); + v=pciReadLong(pTDFX->PciTag[i], CFG_PCI_DECODE); + } else { + v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE); + v=(v & ~CFG_SNOOP_MEMBASE0) | CFG_SNOOP_EN | + CFG_SNOOP_MEMBASE0_EN | CFG_SNOOP_MEMBASE1_EN | + CFG_SNOOP_SLAVE | CFG_SNOOP_FBIINIT_WR_EN | + (((pTDFX->MMIOAddr[0]>>22)&0x3ff)<<CFG_SNOOP_MEMBASE0_SHIFT) | + ((pTDFX->numChips>2)? CFG_SWAP_QUICK : 0); + pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, v); + v=pciReadLong(pTDFX->PciTag[i], CFG_PCI_DECODE); + v=(v & ~CFG_SNOOP_MEMBASE1) | + ((pTDFX->LinearAddr[0]>>22)&0x3ff)<<CFG_SNOOP_MEMBASE1_SHIFT; + pciWriteLong(pTDFX->PciTag[i], CFG_PCI_DECODE, v); + } + } + + if (sliEnable && aaSamples<4) { + /* SLI is on and we're using less than 4 AA samples */ + sli_renderMask = (pTDFX->numChips-1) << sliLinesLog2; + sli_compareMask = i << sliLinesLog2; + sli_scanMask = sliLines - 1; + v = (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) | + (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) | + (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) | + (nChipsLog2 << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT) | + CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN; +#ifndef RD_ABORT_ERROR + v|=CFG_SLI_RD_EN; +#endif + pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL, v); + +#ifdef H3VDD + pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL, + (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) | + (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) | + (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) | + (nChipsLog2 << SLICTL_3D_NUMCHIPS_LOG2_SHIFT) | + SLICTL_3D_EN); +#endif + } else if (!sliEnable && aaSamples) { + /* SLI is off and AA is on */ + sli_renderMask = 0; + sli_compareMask = 0; + sli_scanMask = 0; + pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL, + (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) | + (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) | + (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) | + (0x0 << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT)); +#ifdef H3VDD + pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL, + (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) | + (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) | + (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) | + (0 << SLICTL_3D_NUMCHIPS_LOG2_SHIFT)); +#endif + } else { + /* SLI is on && aaSamples=4 */ + sli_renderMask = ((pTDFX->numChips>>1)-1) << sliLinesLog2; + sli_compareMask = (i>>1) << sliLinesLog2; + sli_scanMask = sliLines - 1; + v = (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) | + (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) | + (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) | + ((nChipsLog2-1) << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT) | + CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN; +#ifndef RD_ABORT_ERROR + v|=CFG_SLI_RD_EN; +#endif + pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL, v); +#ifdef H3VDD + pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL, + (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) | + (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) | + (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) | + ((nChipsLog2-1) << SLICTL_3D_NUMCHIPS_LOG2_SHIFT) | + SLICTL_3D_EN); +#endif + } + + TDFXSetLFBConfig(pTDFX); + if (pTDFX->cpp==2) dwFormat = CFG_AA_LFB_RD_FORMAT_16BPP; + else dwFormat = CFG_AA_LFB_RD_FORMAT_32BPP; + if (pTDFX->numChips==2 && !sliEnable && aaSamples==2) + dwFormat|=CFG_AA_LFB_RD_DIVIDE_BY_4; + /* Thess are wrong, because we don't know where the secondary buffers + are located */ + pTDFX->writeChipLong(pTDFX, i, CFG_AA_LFB_CTRL, + (pScrn->videoRam<<10 /* 2nd buf */ << CFG_AA_BASEADDR_SHIFT) | + CFG_AA_LFB_CPU_WR_EN | CFG_AA_LFB_DPTCH_WR_EN | + CFG_AA_LFB_RD_EN | dwFormat | + ((aaSamples==4)?CFG_AA_LFB_RD_DIVIDE_BY_4:0)); + pTDFX->writeChipLong(pTDFX, i, CFG_AA_ZBUFF_APERTURE, + ((pTDFX->depthOffset>>12)<<CFG_AA_DEPTH_BUFFER_BEG_SHIFT) | + ((pScrn->videoRam>>2)<<CFG_AA_DEPTH_BUFFER_END_SHIFT)); + + if (pTDFX->numChips>1 && i && (aaSamples || sliEnable)) { + int vsyncOffsetPixels, vsyncOffsetChars, vsyncOffsetHXtra; + + if (aaSamples || (pTDFX->numChips==4 && sliEnable && aaSamples==4 && + sliAnalog && i==3)) { + vsyncOffsetPixels=7; + vsyncOffsetChars=4; + vsyncOffsetHXtra=0; + } else { + vsyncOffsetPixels=7; + vsyncOffsetChars=5; + vsyncOffsetHXtra=0; + } + v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC); + pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC, + (v&~CFG_VGA_VSYNC_OFFSET) | + (vsyncOffsetPixels << CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT) | + (vsyncOffsetChars << CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT) | + (vsyncOffsetHXtra << + CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT)); + } + if (pTDFX->numChips==1 && aaSamples) { + /* 1 chip 2 AA */ + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + CFG_VIDEO_OTHERMUX_SEL_PIPE<<CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT | + CFG_DIVIDE_VIDEO_BY_2); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + 0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT | + 0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT | + 0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT | + 0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + 0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT | + 0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT); + } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==4 && + !sliAnalog) { + /* 2 chips 4 digital AA */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_4); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + (CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==4 && sliAnalog) { + /* 2 chips 4 analog AA */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + (CFG_ENHANCED_VIDEO_EN | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_4)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_DAC_HSYNC_TRISTATE | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_4); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==2 && sliEnable && !aaSamples && !sliAnalog) { + /* 2 chips 2 digital SLI */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + (CFG_ENHANCED_VIDEO_EN | + (CFG_VIDEO_OTHERMUX_SEL_AAFIFO << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + ((0x0<<sliLinesLog2) << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + ((i<<sliLinesLog2) << + CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips>=2 && sliEnable && !aaSamples && sliAnalog) { + /* 2 or 4 chips 2/4 analog SLI */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_CRT_SHIFT) | + ((i<<sliLinesLog2) << + CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==2 && sliEnable && aaSamples==2 && !sliAnalog) { + /* 2 chips 2 AA 2 digital SLI */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_AAFIFO << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_2); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + ((0x1<<sliLinesLog2) << + CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + ((i<<sliLinesLog2) << + CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==2 && !sliAnalog) { + /* 2 chips 2 digital AA */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_2); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==2 && sliAnalog) { + /* 2 chips 2 analog AA */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_2); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_DAC_HSYNC_TRISTATE | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_2); + } + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else if (pTDFX->numChips>=2 && sliEnable && aaSamples==2 && sliAnalog) { + /* 2 or 4 chips 2 AA 2 or 4 analog SLI */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_2); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_2); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_CRT_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==4 && sliEnable && !aaSamples && !sliAnalog) { + /* 4 chips 4 digital SLI */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + (CFG_VIDEO_OTHERMUX_SEL_AAFIFO << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_SLI_AAFIFO_COMPARE_INV | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + ((0x0<<sliLinesLog2) << + CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==4 && sliEnable && aaSamples==2 && !sliAnalog) { + /* 4 chips 2 AA 4 digital SLI */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_AAFIFO << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_SLI_AAFIFO_COMPARE_INV | + CFG_DIVIDE_VIDEO_BY_2); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (((pTDFX->numChips-1)<<sliLinesLog2) << + CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && !sliAnalog) { + /* 4 chips 4 AA 2 digital SLI */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_4); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) | + ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else if (i==1 || i==3) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_DAC_HSYNC_TRISTATE | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_1); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + ((0x0<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) | + ((0xff<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO << + CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_4); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } else if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && sliAnalog) { + /* 4 chips 4 AA 2 analog SLI */ + if (!i) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_4); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) | + ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else if (i==1 || i==3) { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_DAC_HSYNC_TRISTATE | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_4); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) | + ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } else { + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + CFG_ENHANCED_VIDEO_EN | + CFG_ENHANCED_VIDEO_SLV | + CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY | + (CFG_VIDEO_OTHERMUX_SEL_PIPE << + CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) | + CFG_DIVIDE_VIDEO_BY_4); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) | + ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT)); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, + (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) | + (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)); + } + } + if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && i==3) { + v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC); + pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC, + v | CFG_AA_LFB_RD_SLV_WAIT); + } + if (i) { + v=pciReadLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0); + pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, + v|CFG_VIDPLL_SEL); + v=pTDFX->readChipLong(pTDFX, i, MISCINIT1); + pTDFX->writeChipLong(pTDFX, i, MISCINIT1, v|SST_POWERDOWN_DAC); + } + } + return TRUE; +} diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h index bb82da4cd..c6224d78f 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h +++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h @@ -176,7 +176,184 @@ #define SST_3D_NOP 0 /* 3D Registers */ -#define SST_3D_OFFSET 0x200000 -#define SST_3D_COMMAND SST_3D_OFFSET+0x120 +#define SST_3D_OFFSET 0x200000 +#define SST_3D_COMMAND SST_3D_OFFSET+0x120 +#define SST_3D_SLICTRL SST_3D_OFFSET+0x20C +#define SST_3D_AACTRL SST_3D_OFFSET+0x210 +#define SST_3D_CHIPMASK SST_3D_OFFSET+0x214 + +/* NAPALM REGISTERS */ +#define CFG_MEM0BASE 16 +#define CFG_MEM1BASE 20 +#define CFG_INIT_ENABLE 64 +#define CFG_PCI_DECODE 72 +#define CFG_VIDEO_CTRL0 128 +#define CFG_VIDEO_CTRL1 132 +#define CFG_VIDEO_CTRL2 136 +#define CFG_SLI_LFB_CTRL 140 +#define CFG_AA_ZBUFF_APERTURE 144 +#define CFG_AA_LFB_CTRL 148 +#define CFG_SLI_AA_MISC 172 + +/* Pixel Formats */ +#define GR_PIXFMT_I_8 0x0001 +#define GR_PIXFMT_AI_88 0x0002 +#define GR_PIXFMT_RGB_565 0x0003 +#define GR_PIXFMT_ARGB_1555 0x0004 +#define GR_PIXFMT_ARGB_8888 0x0005 +#define GR_PIXFMT_AA_2_RGB_565 0x0006 +#define GR_PIXFMT_AA_2_ARGB_1555 0x0007 +#define GR_PIXFMT_AA_2_ARGB_8888 0x0008 +#define GR_PIXFMT_AA_4_RGB_565 0x0009 +#define GR_PIXFMT_AA_4_ARGB_1555 0x000a +#define GR_PIXFMT_AA_4_ARGB_8888 0x000b + +/* pciInit0 */ +#define SST_PCI_STALL_ENABLE BIT(0) +#define SST_PCI_LOWTHRESH_SHIFT 2 +#define SST_PCI_LOWTHRESH (0xF << SST_PCI_LOWTHRESH_SHIFT) +#define SST_PCI_HARDCODE_BASE BIT(7) +#define SST_PCI_READ_WS BIT(8) +#define SST_PCI_WRITE_WS BIT(9) +#define SST_PCI_DISABLE_IO BIT(11) +#define SST_PCI_DISABLE_MEM BIT(12) +#define SST_PCI_RETRY_INTERVAL_SHIFT 13 +#define SST_PCI_RETRY_INTERVAL (0x1F << SST_PCI_RETRY_INTERVAL_SHIFT) +#define SST_PCI_INTERRUPT_ENABLE BIT(18) +#define SST_PCI_TIMEOUT_ENABLE BIT(19) +#define SST_PCI_FORCE_FB_HIGH BIT(26) + +#define SST_AA_CLK_INVERT BIT(20) +#define SST_AA_CLK_DELAY_SHIFT 21 +#define SST_AA_CLK_DELAY (0xF<<SST_AA_CLK_DELAY_SHIFT) + +#define CFG_SWAP_ALGORITHM_VSYNC (0x00) +#define CFG_SWAP_ALGORITHM_SYNCIN (0x01) +#define CFG_SWAPBUFFER_ALGORITHM_SHIFT (25) + +/* CFG_INIT_ENABLE */ +#define CFG_UPDATE_MEMBASE_LSBS BIT(10) +#define CFG_SNOOP_EN BIT(11) +#define CFG_SNOOP_MEMBASE0_EN BIT(12) +#define CFG_SNOOP_MEMBASE1_EN BIT(13) +#define CFG_SNOOP_SLAVE BIT(14) +#define CFG_SNOOP_MEMBASE0_SHIFT 15 +#define CFG_SNOOP_MEMBASE0 (0x3FF<<CFG_SNOOP_MEMBASE0_SHIFT) +#define CFG_SWAP_ALGORITHM BIT(25) +#define CFG_SWAP_MASTER BIT(26) +#define CFG_SWAP_QUICK BIT(27) +#define CFG_MULTI_FUNCTION_DEV BIT(28) +#define CFG_LFB_RD_CACHE_DISABLE BIT(29) +#define CFG_SNOOP_FBIINIT_WR_EN BIT(30) +#define CFG_SNOOP_MEMBASE0_DECODE_SHIFT 10 +#define CFG_SNOOP_MEMBASE0_DECODE (0xF<<CFG_SNOOP_MEMBASE0_DECODE_SHIFT) +#define CFG_SNOOP_MEMBASE1_DECODE_SHIFT 14 +#define CFG_SNOOP_MEMBASE1_DECODE (0xF<<CFG_SNOOP_MEMBASE1_DECODE_SHIFT) +#define CFG_SNOOP_MEMBASE1_SHIFT 18 +#define CFG_SNOOP_MEMBASE1 (0x3FF<<CFG_SNOOP_MEMBASE1_SHIFT) + +/* CFG_VIDEO_CTRL0 */ +#define CFG_ENHANCED_VIDEO_EN BIT(0) +#define CFG_ENHANCED_VIDEO_SLV BIT(1) +#define CFG_VIDEO_TV_OUTPUT_EN BIT(2) +#define CFG_VIDEO_LOCALMUX_SEL BIT(3) +#define CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY BIT(3) +#define CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT 4 +#define CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT 6 +#define CFG_VIDEO_OTHERMUX_SEL_TRUE (0x3<<CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) +#define CFG_VIDEO_OTHERMUX_SEL_FALSE (0x3<<CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) +#define CFG_VIDEO_OTHERMUX_SEL_PIPE 0 +#define CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO 1 +#define CFG_VIDEO_OTHERMUX_SEL_AAFIFO 2 +#define CFG_SLI_FETCH_COMPARE_INV BIT(8) +#define CFG_SLI_CRT_COMPARE_INV BIT(9) +#define CFG_SLI_AAFIFO_COMPARE_INV BIT(10) +#define CFG_VIDPLL_SEL BIT(11) +#define CFG_DIVIDE_VIDEO_SHIFT 12 +#define CFG_DIVIDE_VIDEO (0x7<<CFG_DIVIDE_VIDEO_SHIFT) +#define CFG_DIVIDE_VIDEO_BY_1 (0x0<<CFG_DIVIDE_VIDEO_SHIFT) +#define CFG_DIVIDE_VIDEO_BY_2 (0x1<<CFG_DIVIDE_VIDEO_SHIFT) +#define CFG_DIVIDE_VIDEO_BY_4 (0x2<<CFG_DIVIDE_VIDEO_SHIFT) +#define CFG_DIVIDE_VIDEO_BY_8 (0x3<<CFG_DIVIDE_VIDEO_SHIFT) +#define CFG_DIVIDE_VIDEO_BY_16 (0x4<<CFG_DIVIDE_VIDEO_SHIFT) +#define CFG_DIVIDE_VIDEO_BY_32 (0x5<<CFG_DIVIDE_VIDEO_SHIFT) +#define CFG_ALWAYS_DRIVE_AA_BUS BIT(15) +#define CFG_VSYNC_IN_DEL_SHIFT 16 +#define CFG_VSYNC_IN_DEL (0xF<<CFG_VSYNC_IN_DEL_SHIFT) +#define CFG_DAC_VSYNC_TRISTATE BIT(24) +#define CFG_DAC_HSYNC_TRISTATE BIT(25) + +/* CFG_VIDEO_CTRL1 */ +#define CFG_SLI_RENDERMASK_FETCH_SHIFT 0 +#define CFG_SLI_RENDERMASK_FETCH (0xFF<<CFG_SLI_RENDERMASK_FETCH_SHIFT) +#define CFG_SLI_COMPAREMASK_FETCH_SHIFT 8 +#define CFG_SLI_COMPAREMASK_FETCH (0xFF<<CFG_SLI_COMPAREMASK_FETCH_SHIFT) +#define CFG_SLI_RENDERMASK_CRT_SHIFT 16 +#define CFG_SLI_RENDERMASK_CRT (0xFF<<CFG_SLI_RENDERMASK_CRT_SHIFT) +#define CFG_SLI_COMPAREMASK_CRT_SHIFT 24 +#define CFG_SLI_COMPAREMASK_CRT (0xFF<<CFG_SLI_COMPAREMASK_CRT_SHIFT) + +/* CFG_VIDEO_CTRL2 */ +#define CFG_SLI_RENDERMASK_AAFIFO_SHIFT 0 +#define CFG_SLI_RENDERMASK_AAFIFO (0xFF<<CFG_SLI_RENDERMASK_AAFIFO_SHIFT) +#define CFG_SLI_COMPAREMASK_AAFIFO_SHIFT 8 +#define CFG_SLI_COMPAREMASK_AAFIFO (0xFF<<CFG_SLI_COMPAREMASK_AAFIFO_SHIFT) + +/* CFG_SLI_LFB_CTRL */ +#define CFG_SLI_LFB_RENDERMASK_SHIFT 0 +#define CFG_SLI_LFB_RENDERMASK (0xFF<<CFG_SLI_LFB_RENDERMASK_SHIFT) +#define CFG_SLI_LFB_COMPAREMASK_SHIFT 8 +#define CFG_SLI_LFB_COMPAREMASK (0xFF<<CFG_SLI_LFB_COMPAREMASK_SHIFT) +#define CFG_SLI_LFB_SCANMASK_SHIFT 16 +#define CFG_SLI_LFB_SCANMASK (0xFF<<CFG_SLI_LFB_SCANMASK_SHIFT) +#define CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT 24 +#define CFG_SLI_LFB_NUMCHIPS_LOG2 (0x3<<CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT) +#define CFG_SLI_LFB_CPU_WR_EN BIT(26) +#define CFG_SLI_LFB_DPTCH_WR_EN BIT(27) +#define CFG_SLI_RD_EN BIT(28) + +/* CFG_AA_ZBUFF_APERTURE */ +#define CFG_AA_DEPTH_BUFFER_BEG_SHIFT 0 +#define CFG_AA_DEPTH_BUFFER_BEG (0x7FFF<<CFG_AA_DEPTH_BUFFER_BEG_SHIFT) +#define CFG_AA_DEPTH_BUFFER_END_SHIFT 16 +#define CFG_AA_DEPTH_BUFFER_END (0xFFFF<<CFG_AA_DEPTH_BUFFER_END_SHIFT) + +/* CFG_AA_LFB_CTRL */ +#define CFG_AA_BASEADDR_SHIFT 0 +#define CFG_AA_BASEADDR (0x3FFFFFF<<CFG_AA_BASEADDR_SHIFT) +#define CFG_AA_LFB_CPU_WR_EN BIT(26) +#define CFG_AA_LFB_DPTCH_WR_EN BIT(27) +#define CFG_AA_LFB_RD_EN BIT(28) +#define CFG_AA_LFB_RD_FORMAT_SHIFT 29 +#define CFG_AA_LFB_RD_FORMAT (0x3<<CFG_AA_LFB_RD_FORMAT_SHIFT) +#define CFG_AA_LFB_RD_FORMAT_16BPP (0x0<<CFG_AA_LFB_RD_FORMAT_SHIFT) +#define CFG_AA_LFB_RD_FORMAT_15BPP (0x1<<CFG_AA_LFB_RD_FORMAT_SHIFT) +#define CFG_AA_LFB_RD_FORMAT_32BPP (0x2<<CFG_AA_LFB_RD_FORMAT_SHIFT) +#define CFG_AA_LFB_RD_DIVIDE_BY_4 BIT(31) + +/* CFG_SLI_AA_MISC */ +#define CFG_VGA_VSYNC_OFFSET_SHIFT 0 +#define CFG_VGA_VSYNC_OFFSET (0x1ff<<CFG_VGA_VSYNC_OFFSET_SHIFT) +#define CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT 0 +#define CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT 3 +#define CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT 6 +#define CFG_HOTPLUG_SHIFT 9 +#define CFG_HOTPLUG_TRISTATE (0x0<<CFG_HOTPLUG_SHIFT) +#define CFG_HOTPLUG_DRIVE0 (0x2<<CFG_HOTPLUG_SHIFT) +#define CFG_HOTPLUG_DRIVE1 (0x3<<CFG_HOTPLUG_SHIFT) +#define CFG_AA_LFB_RD_SLV_WAIT BIT(12) + +/* SLICTL_3D_CTRL */ +#define SLICTL_3D_RENDERMASK_SHIFT 0 +#define SLICTL_3D_RENDERMASK (0xFF<<SLICTL_3D_RENDERMASK_SHIFT) +#define SLICTL_3D_COMPAREMASK_SHIFT 8 +#define SLICTL_3D_COMPAREMASK (0xFF<<SLICTL_3D_COMPAREMASK_SHIFT) +#define SLICTL_3D_SCANMASK_SHIFT 16 +#define SLICTL_3D_SCANMASK (0xFF<<SLICTL_3D_SCANMASK_SHIFT) +#define SLICTL_3D_NUMCHIPS_LOG2_SHIFT 24 +#define SLICTL_3D_NUMCHIPS_LOG2 (0x3<<SLICTL_3D_NUMCHIPS_LOG2_SHIFT) +#define SLICTL_3D_EN BIT(26) + +#define SST_POWERDOWN_DAC BIT(8) #endif diff --git a/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c b/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c index d91457078..9844d6d90 100644 --- a/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c +++ b/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c @@ -54,6 +54,12 @@ #include "xf86Priv.h" #include "vbe.h" +#ifdef __FreeBSD__ +/* XXX used in drmOpen(). This should change to use a less os-specific + * method. */ +int sysctlbyname(const char*, void *, size_t *, void *, size_t); +#endif + extern xf86MonPtr ConfiguredMonitor; /* XXX Should get all of these from elsewhere */ @@ -231,6 +237,7 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(xf86GetSerialModemState) SYMFUNC(xf86SerialModemSetBits) SYMFUNC(xf86SerialModemClearBits) + SYMFUNC(xf86LoadKernelModule) SYMFUNC(xf86OSMouseInit) #ifdef XINPUT @@ -778,6 +785,8 @@ LOOKUP xfree86LookupTab[] = { SYMFUNC(xf86fstat) SYMFUNC(xf86access) SYMFUNC(xf86geteuid) + SYMFUNC(xf86getegid) + SYMFUNC(xf86getpid) SYMFUNC(xf86mknod) SYMFUNC(xf86chmod) SYMFUNC(xf86chown) @@ -891,6 +900,10 @@ LOOKUP xfree86LookupTab[] = { #endif #endif +#ifdef __FreeBSD__ + SYMFUNC(sysctlbyname) +#endif + /* * and now some variables */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux index 8a41f880b..ecc196bdd 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux @@ -1,8 +1,8 @@ # Makefile -- For the Direct Rendering Manager module (drm) # Created: Mon Jan 4 09:26:53 1999 by faith@precisioninsight.com -# Revised: Sun Feb 13 23:15:59 2000 by kevin@precisioninsight.com # # Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. +# Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. # All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a @@ -24,19 +24,35 @@ # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. # -# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux,v 1.6 2000/02/23 04:47:25 martin Exp $ -# +# +# ***** NOTE NOTE NOTE NOTE NOTE ***** +# To override the automatic Linux source tree determination, pass the +# pathname for the kernel that you want to compile on the command line, +# like this: +# make TREE=/usr/my-kernel-tree/include +# +# +# ***** NOTE NOTE NOTE NOTE NOTE ***** +# Because some distributions patch 2.2.x kernels to make kill_fasync have +# three parameters, this script tries to determine, via the examination of +# header files, if your kernel has been patched. If this detection is +# incorrect, you can override the value on the command line, like this: +# make PARAMS=2 +# or +# make PARAMS=3 .SUFFIXES: # *** Setup -MODS= gamma.o tdfx.o +# **** End of SMP/MODVERSIONS detection + +MODS= gamma.o tdfx.o r128.o LIBS= libdrm.a PROGS= drmstat DRMOBJS= init.o memory.o proc.o auth.o context.o drawable.o bufs.o \ - lists.o lock.o ioctl.o fops.o vm.o dma.o + lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o DRMHEADERS= drm.h drmP.h GAMMAOBJS= gamma_drv.o gamma_dma.o @@ -45,9 +61,14 @@ GAMMAHEADERS= gamma_drv.h $(DRMHEADERS) TDFXOBJS= tdfx_drv.o tdfx_context.o TDFXHEADERS= tdfx_drv.h $(DRMHEADERS) +R128OBJS= r128_drv.o r128_dma.o r128_bufs.o r128_context.o +R128HEADERS= r128_drv.h r128_drm.h $(DRMHEADERS) + PROGOBJS= drmstat.po xf86drm.po xf86drmHash.po xf86drmRandom.po sigio.po PROGHEADERS= xf86drm.h $(DRMHEADERS) +INC= /usr/include + CFLAGS= -O2 $(WARNINGS) WARNINGS= -Wall -Wwrite-strings -Wpointer-arith -Wcast-align \ -Wstrict-prototypes -Wshadow -Wnested-externs \ @@ -90,11 +111,6 @@ endif endif endif -# To override this determination, pass the path on the make command line: -# make TREE=/usr/my-kernel-tree/include -# or hardcode a value for TREE here: -# TREE:=/usr/include - ifeq ($(TREE),0) all:; @echo Error: Could not locate kernel tree in $A $B $C else @@ -102,7 +118,30 @@ SMP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ | grep -s 'SMP = ' | cut -d' ' -f3) MODVERSIONS := $(shell gcc -E -I $(TREE) picker.c 2>/dev/null \ | grep -s 'MODVERSIONS = ' | cut -d' ' -f3) -all::;@echo KERNEL HEADERS IN $(TREE): SMP=${SMP} MODVERSIONS=${MODVERSIONS} +AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ + | grep -s 'AGP = ' | cut -d' ' -f3) +PARAMS := $(shell if fgrep kill_fasync $(TREE)/linux/fs.h \ + | fgrep -q band; then echo 3; else echo 2; fi) +ifeq ($(AGP),0) +AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \ + | grep -s 'AGP_MODULE = ' | cut -d' ' -f3) +endif + +ifeq ($(AGP),1) +MODCFLAGS += -DDRM_AGP +DRMOBJS += agpsupport.o +MODS += mga.o i810.o + +MGAOBJS= mga_drv.o mga_dma.o mga_bufs.o mga_state.o mga_context.o +MGAHEADERS= mga_drv.h $(DRMHEADERS) + +I810OBJS= i810_drv.o i810_dma.o i810_bufs.o i810_context.o +I810HEADERS= i810_drv.h $(DRMHEADERS) +endif + +all::;@echo === KERNEL HEADERS IN $(TREE) +all::;@echo === SMP=${SMP} MODVERSIONS=${MODVERSIONS} AGP=${AGP} +all::;@echo === kill_fasync has $(PARAMS) parameters all:: $(LIBS) $(MODS) $(PROGS) endif @@ -115,6 +154,9 @@ endif ifeq ($(MODVERSIONS),1) MODCFLAGS += -DMODVERSIONS -include $(TREE)/linux/modversions.h endif +ifeq ($(PARAMS),3) +MODCFLAGS += -DKILLFASYNCHASTHREEPARAMETERS +endif # **** End of configuration @@ -128,6 +170,17 @@ gamma.o: $(GAMMAOBJS) $(LIBS) tdfx.o: $(TDFXOBJS) $(LIBS) $(LD) -r $^ -o $@ +r128.o: $(R128OBJS) $(LIBS) + $(LD) -r $^ -o $@ + +ifeq ($(AGP),1) +mga.o: $(MGAOBJS) $(LIBS) + $(LD) -r $^ -o $@ + +i810.o: $(I810OBJS) $(LIBS) + $(LD) -r $^ -o $@ +endif + drmstat: $(PROGOBJS) $(CC) $(PRGCFLAGS) $^ $(PRGLIBS) -o $@ @@ -140,7 +193,7 @@ ChangeLog: # .o files are used for modules %.o: %.c - $(CC) $(MODCFLAGS) -c $< -o $@ + $(CC) $(MODCFLAGS) -I$(TREE) -c $< -o $@ %.po: %.c $(CC) $(PRGCFLAGS) -DDRM_USE_MALLOC -c $< -o $@ @@ -149,8 +202,12 @@ ChangeLog: $(DRMOBJS): $(DRMHEADERS) $(GAMMAOBJS): $(GAMMAHEADERS) $(TDFXOBJS): $(TDFXHEADERS) +$(R128OBJS): $(R128HEADERS) +ifeq ($(AGP),1) +$(MGAOBJS): $(MGAHEADERS) +$(I810OBJS): $(I810HEADERS) +endif $(PROGOBJS): $(PROGHEADERS) clean: - rm -f *.o *.po *~ core $(PROGS) - + rm -f *.o *.a *.po *~ core $(PROGS) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c index fb58154d6..c89c3e258 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c @@ -2,6 +2,7 @@ * Created: Mon Dec 13 09:56:45 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,9 +24,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Author: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c,v 1.1 2000/02/11 17:26:02 dawes Exp $ + * Author: Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -159,6 +158,8 @@ int drm_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd, -EFAULT); if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS))) return -ENOMEM; + + memset(entry, 0, sizeof(*entry)); pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE; type = (u32) request.type; @@ -237,6 +238,8 @@ int drm_agp_bind(struct inode *inode, struct file *filp, unsigned int cmd, page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE; if ((retcode = drm_bind_agp(entry->memory, page))) return retcode; entry->bound = dev->agp->base + (page << PAGE_SHIFT); + DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n", + dev->agp->base, entry->bound); return 0; } @@ -254,8 +257,10 @@ int drm_agp_free(struct inode *inode, struct file *filp, unsigned int cmd, if (!(entry = drm_agp_lookup_entry(dev, request.handle))) return -EINVAL; if (entry->bound) drm_unbind_agp(entry->memory); - entry->prev->next = entry->next; - entry->next->prev = entry->prev; + + if (entry->prev) entry->prev->next = entry->next; + else dev->agp->memory = entry->next; + if (entry->next) entry->next->prev = entry->prev; drm_free_agp(entry->memory, entry->pages); drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); return 0; @@ -269,15 +274,12 @@ drm_agp_head_t *drm_agp_init(void) for (fill = &drm_agp_fill[0]; fill->name; fill++) { char *n = (char *)fill->name; -#if 0 - *fill->f = (drm_agp_func_u)get_module_symbol(NULL, n); -#endif *fill->f = (drm_agp_func_u)get_module_symbol(NULL, n); - printk("%s resolves to 0x%08lx\n", n, (*fill->f).address); + DRM_DEBUG("%s resolves to 0x%08lx\n", n, (*fill->f).address); if (!(*fill->f).address) agp_available = 0; } - printk("agp_available = %d\n", agp_available); + DRM_DEBUG("agp_available = %d\n", agp_available); if (agp_available) { if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS))) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c index 0e3b1c565..b133bc506 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c @@ -1,8 +1,8 @@ /* auth.c -- IOCTLs for authentication -*- linux-c -*- * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com - * Revised: Fri Aug 20 11:31:48 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c,v 1.2 2000/02/23 04:47:25 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -44,7 +45,6 @@ static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic) down(&dev->struct_sem); for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { - if (pt->priv->authenticated) continue; if (pt->magic == magic) { retval = pt->priv; break; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c index 85244c7dc..011e42410 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c @@ -1,8 +1,8 @@ /* bufs.c -- IOCTLs to manage buffers -*- linux-c -*- * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com - * Revised: Mon Feb 14 00:14:11 2000 by kevin@precisioninsight.com * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,11 +24,13 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c,v 1.5 2000/02/23 04:47:25 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ #define __NO_VERSION__ +#include <linux/config.h> #include "drmP.h" #include "linux/un.h" @@ -102,6 +104,11 @@ int drm_addmap(struct inode *inode, struct file *filp, unsigned int cmd, dev->lock.hw_lock = map->handle; /* Pointer to lock */ } break; +#ifdef DRM_AGP + case _DRM_AGP: + map->offset = map->offset + dev->agp->base; + break; +#endif default: drm_free(map, sizeof(*map), DRM_MEM_MAPS); return -EINVAL; @@ -172,7 +179,7 @@ int drm_addbufs(struct inode *inode, struct file *filp, unsigned int cmd, if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; if (dev->queue_count) return -EBUSY; /* Not while in use */ - alignment = (request.flags & DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; + alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c index fdf8fd9f1..ca491094e 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c @@ -1,8 +1,8 @@ /* context.c -- IOCTLs for contexts and DMA queues -*- linux-c -*- * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com - * Revised: Fri Aug 20 11:32:09 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c,v 1.2 2000/02/23 04:47:26 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c index f67209d44..615505979 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c @@ -1,7 +1,8 @@ /* ctxbitmap.c -- Context bitmap management -*- linux-c -*- * Created: Thu Jan 6 03:56:42 2000 by jhartmann@precisioninsight.com * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,9 +24,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Author: Jeff Hartmann <jhartmann@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c,v 1.1 2000/02/11 17:26:02 dawes Exp $ + * Author: Jeff Hartmann <jhartmann@valinux.com> * */ @@ -53,7 +52,7 @@ int drm_ctxbitmap_next(drm_device_t *dev) bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP); if (bit < DRM_MAX_CTXBITMAP) { set_bit(bit, dev->ctx_bitmap); - printk("drm_ctxbitmap_next bit : %d\n", bit); + DRM_DEBUG("drm_ctxbitmap_next bit : %d\n", bit); return bit; } return -1; @@ -64,15 +63,15 @@ int drm_ctxbitmap_init(drm_device_t *dev) int i; int temp; - dev->ctx_bitmap = (unsigned long *) drm_alloc(PAGE_SIZE * 4, + dev->ctx_bitmap = (unsigned long *) drm_alloc(PAGE_SIZE, DRM_MEM_CTXBITMAP); if(dev->ctx_bitmap == NULL) { return -ENOMEM; } - memset((void *) dev->ctx_bitmap, 0, PAGE_SIZE * 4); + memset((void *) dev->ctx_bitmap, 0, PAGE_SIZE); for(i = 0; i < DRM_RESERVED_CONTEXTS; i++) { temp = drm_ctxbitmap_next(dev); - printk("drm_ctxbitmap_init : %d\n", temp); + DRM_DEBUG("drm_ctxbitmap_init : %d\n", temp); } return 0; @@ -80,7 +79,7 @@ int drm_ctxbitmap_init(drm_device_t *dev) void drm_ctxbitmap_cleanup(drm_device_t *dev) { - drm_free((void *)dev->ctx_bitmap, PAGE_SIZE * 4, + drm_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c index 8291e52e4..ac2d1bc5a 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c @@ -1,8 +1,8 @@ /* dma.c -- DMA IOCTL and function support -*- linux-c -*- * Created: Fri Mar 19 14:30:16 1999 by faith@precisioninsight.com - * Revised: Sun Feb 13 23:19:45 2000 by kevin@precisioninsight.com * - * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c,v 1.5 2000/02/23 04:47:26 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinuxa.com> * */ @@ -63,15 +64,24 @@ void drm_dma_takedown(drm_device_t *dev) dma->bufs[i].page_order, DRM_MEM_DMA); } - drm_free(dma->bufs[i].buflist, - dma->buf_count - * sizeof(*dma->bufs[0].buflist), - DRM_MEM_BUFS); drm_free(dma->bufs[i].seglist, - dma->buf_count + dma->bufs[i].seg_count * sizeof(*dma->bufs[0].seglist), DRM_MEM_SEGS); - drm_freelist_destroy(&dma->bufs[i].freelist); + } + if(dma->bufs[i].buf_count) { + for(j = 0; j < dma->bufs[i].buf_count; j++) { + if(dma->bufs[i].buflist[j].dev_private) { + drm_free(dma->bufs[i].buflist[j].dev_private, + dma->bufs[i].buflist[j].dev_priv_size, + DRM_MEM_BUFS); + } + } + drm_free(dma->bufs[i].buflist, + dma->bufs[i].buf_count * + sizeof(*dma->bufs[0].buflist), + DRM_MEM_BUFS); + drm_freelist_destroy(&dma->bufs[i].freelist); } } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c index c7acecb97..03839f5be 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c @@ -1,8 +1,8 @@ /* drawable.c -- IOCTLs for drawables -*- linux-c -*- * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com - * Revised: Fri Aug 20 09:27:03 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c,v 1.2 2000/02/23 04:47:26 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h index b2e2a0ac6..56ef48d2c 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h @@ -1,7 +1,8 @@ /* drm.h -- Header for Direct Rendering Manager -*- linux-c -*- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com * - * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -10,11 +11,11 @@ * 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL @@ -22,8 +23,9 @@ * 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. - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h,v 1.5 2000/02/23 04:47:26 martin Exp $ + * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * * Acknowledgements: * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg. @@ -60,7 +62,7 @@ typedef unsigned int drm_context_t; typedef unsigned int drm_drawable_t; typedef unsigned int drm_magic_t; -/* Warning: If you change this structure, make sure you change +/* Warning: If you change this structure, make sure you change * XF86DRIClipRectRec in the server as well */ typedef struct drm_clip_rect { @@ -356,7 +358,7 @@ typedef struct drm_agp_info { #define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t) #define DRM_IOCTL_R128_RESET DRM_IO( 0x41) #define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42) -#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43) +#define DRM_IOCTL_R128_IDLE DRM_IO( 0x43) #define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t) #define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h index 312fba36f..350d1ef9b 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h @@ -1,8 +1,8 @@ /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com - * Revised: Sun Feb 13 23:34:30 2000 by kevin@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h,v 1.6 2000/02/23 04:47:27 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -48,8 +49,12 @@ #ifdef CONFIG_MTRR #include <asm/mtrr.h> #endif +#ifdef DRM_AGP +#include <linux/types.h> +#include <linux/agp_backend.h> +#endif #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0) -#include <asm/spinlock.h> +#include <linux/tqueue.h> #include <linux/poll.h> #endif #include "drm.h" @@ -69,21 +74,27 @@ #define DRM_FLAG_DEBUG 0x01 #define DRM_FLAG_NOCTX 0x02 -#define DRM_MEM_DMA 0 -#define DRM_MEM_SAREA 1 -#define DRM_MEM_DRIVER 2 -#define DRM_MEM_MAGIC 3 -#define DRM_MEM_IOCTLS 4 -#define DRM_MEM_MAPS 5 -#define DRM_MEM_VMAS 6 -#define DRM_MEM_BUFS 7 -#define DRM_MEM_SEGS 8 -#define DRM_MEM_PAGES 9 -#define DRM_MEM_FILES 10 -#define DRM_MEM_QUEUES 11 -#define DRM_MEM_CMDS 12 -#define DRM_MEM_MAPPINGS 13 -#define DRM_MEM_BUFLISTS 14 +#define DRM_MEM_DMA 0 +#define DRM_MEM_SAREA 1 +#define DRM_MEM_DRIVER 2 +#define DRM_MEM_MAGIC 3 +#define DRM_MEM_IOCTLS 4 +#define DRM_MEM_MAPS 5 +#define DRM_MEM_VMAS 6 +#define DRM_MEM_BUFS 7 +#define DRM_MEM_SEGS 8 +#define DRM_MEM_PAGES 9 +#define DRM_MEM_FILES 10 +#define DRM_MEM_QUEUES 11 +#define DRM_MEM_CMDS 12 +#define DRM_MEM_MAPPINGS 13 +#define DRM_MEM_BUFLISTS 14 +#define DRM_MEM_AGPLISTS 15 +#define DRM_MEM_TOTALAGP 16 +#define DRM_MEM_BOUNDAGP 17 +#define DRM_MEM_CTXBITMAP 18 + +#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) /* Backward compatibility section */ /* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */ @@ -218,8 +229,8 @@ typedef struct drm_magic_entry { } drm_magic_entry_t; typedef struct drm_magic_head { - struct drm_magic_entry *head; - struct drm_magic_entry *tail; + struct drm_magic_entry *head; + struct drm_magic_entry *tail; } drm_magic_head_t; typedef struct drm_vma_entry { @@ -235,6 +246,7 @@ typedef struct drm_buf { int used; /* Amount of buffer in use (for DMA) */ unsigned long offset; /* Byte offset (used internally) */ void *address; /* Address of buffer */ + unsigned long bus_address; /* Bus address of buffer */ struct drm_buf *next; /* Kernel-only: used for free list */ __volatile__ int waiting; /* On kernel DMA queue */ __volatile__ int pending; /* On hardware DMA queue */ @@ -250,12 +262,16 @@ typedef struct drm_buf { DRM_LIST_PRIO = 4, DRM_LIST_RECLAIM = 5 } list; /* Which list we're on */ + #if DRM_DMA_HISTOGRAM cycles_t time_queued; /* Queued to kernel DMA queue */ cycles_t time_dispatched; /* Dispatched to hardware */ cycles_t time_completed; /* Completed by hardware */ cycles_t time_freed; /* Back on freelist */ #endif + + int dev_priv_size; /* Size of buffer private stoarge */ + void *dev_private; /* Per-buffer private storage */ } drm_buf_t; #if DRM_DMA_HISTOGRAM @@ -376,6 +392,9 @@ typedef struct drm_device_dma { int page_count; unsigned long *pagelist; unsigned long byte_count; + enum { + _DRM_DMA_USE_AGP = 0x01 + } flags; /* DMA support */ drm_buf_t *this_buffer; /* Buffer being sent */ @@ -384,6 +403,41 @@ typedef struct drm_device_dma { wait_queue_head_t waiting; /* Processes waiting on free bufs */ } drm_device_dma_t; +#ifdef DRM_AGP +typedef struct drm_agp_mem { + unsigned long handle; + agp_memory *memory; + unsigned long bound; /* address */ + int pages; + struct drm_agp_mem *prev; + struct drm_agp_mem *next; +} drm_agp_mem_t; + +typedef struct drm_agp_head { + agp_kern_info agp_info; + const char *chipset; + drm_agp_mem_t *memory; + unsigned long mode; + int enabled; + int acquired; + unsigned long base; + int agp_mtrr; +} drm_agp_head_t; + +typedef struct { + void (*free_memory)(agp_memory *); + agp_memory *(*allocate_memory)(size_t, u32); + int (*bind_memory)(agp_memory *, off_t); + int (*unbind_memory)(agp_memory *); + void (*enable)(u32); + int (*acquire)(void); + void (*release)(void); + void (*copy_info)(agp_kern_info *); +} drm_agp_func_t; + +extern drm_agp_func_t drm_agp; +#endif + typedef struct drm_device { const char *name; /* Simple driver name */ char *unique; /* Unique identifier: e.g., busid */ @@ -462,6 +516,12 @@ typedef struct drm_device { struct fasync_struct *buf_async;/* Processes waiting for SIGIO */ wait_queue_head_t buf_readers; /* Processes waiting to read */ wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */ + +#ifdef DRM_AGP + drm_agp_head_t *agp; +#endif + unsigned long *ctx_bitmap; + void *dev_private; } drm_device_t; @@ -470,6 +530,7 @@ typedef struct drm_device { /* Misc. support (init.c) */ extern int drm_flags; extern void drm_parse_options(char *s); +extern int drm_cpu_valid(void); /* Device support (fops.c) */ @@ -533,6 +594,14 @@ extern void drm_free_pages(unsigned long address, int order, extern void *drm_ioremap(unsigned long offset, unsigned long size); extern void drm_ioremapfree(void *pt, unsigned long size); +#ifdef DRM_AGP +extern agp_memory *drm_alloc_agp(int pages, u32 type); +extern int drm_free_agp(agp_memory *handle, int pages); +extern int drm_bind_agp(agp_memory *handle, unsigned int start); +extern int drm_unbind_agp(agp_memory *handle); +#endif + + /* Buffer management support (bufs.c) */ extern int drm_order(unsigned long size); extern int drm_addmap(struct inode *inode, struct file *filp, @@ -642,5 +711,32 @@ extern int drm_flush_unblock(drm_device_t *dev, int context, drm_lock_flags_t flags); extern int drm_flush_block_and_flush(drm_device_t *dev, int context, drm_lock_flags_t flags); + + /* Context Bitmap support (ctxbitmap.c) */ +extern int drm_ctxbitmap_init(drm_device_t *dev); +extern void drm_ctxbitmap_cleanup(drm_device_t *dev); +extern int drm_ctxbitmap_next(drm_device_t *dev); +extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle); + +#ifdef DRM_AGP + /* AGP/GART support (agpsupport.c) */ +extern drm_agp_head_t *drm_agp_init(void); +extern int drm_agp_acquire(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int drm_agp_release(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int drm_agp_enable(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int drm_agp_info(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int drm_agp_alloc(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int drm_agp_free(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int drm_agp_unbind(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int drm_agp_bind(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +#endif #endif #endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c index 8fe6f7072..8c691c49b 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c @@ -1,8 +1,8 @@ /* drmstat.c -- DRM device status and testing program * Created: Tue Jan 5 08:19:24 1999 by faith@precisioninsight.com - * Revised: Sun Feb 13 23:35:00 2000 by kevin@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,7 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c,v 1.6 2000/02/23 04:47:27 martin Exp $ + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -187,7 +187,7 @@ int main(int argc, char **argv) case 'b': count = strtoul(optarg, &pt, 0); size = strtoul(pt+1, NULL, 0); - if ((r = drmAddBufs(fd, count, size, 0)) < 0) { + if ((r = drmAddBufs(fd, count, size, 0, 65536)) < 0) { drmError(r, argv[0]); return 1; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c index 2a064e5df..1eb2bdac7 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c @@ -1,8 +1,8 @@ /* fops.c -- File operations for DRM -*- linux-c -*- * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com - * Revised: Fri Dec 3 10:26:26 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,8 +23,10 @@ * 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. - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c,v 1.6 2000/02/23 04:47:27 martin Exp $ + * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * Daryll Strauss <daryll@valinux.com> * */ @@ -40,6 +42,7 @@ int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev) drm_file_t *priv; if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */ + if (!drm_cpu_valid()) return -EINVAL; DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor); @@ -211,10 +214,15 @@ int drm_write_string(drm_device_t *dev, const char *s) send -= count; } -#if LINUX_VERSION_CODE < 0x020315 +#if LINUX_VERSION_CODE < 0x020315 && !defined(KILLFASYNCHASTHREEPARAMETERS) + /* The extra parameter to kill_fasync was added in 2.3.21, and is + _not_ present in _stock_ 2.2.14 and 2.2.15. However, some + distributions patch 2.2.x kernels to add this parameter. The + Makefile.linux attempts to detect this addition and defines + KILLFASYNCHASTHREEPARAMETERS if three parameters are found. */ if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO); #else - /* Parameter added in 2.3.21 */ + /* Parameter added in 2.3.21 */ if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO, POLL_IN); #endif DRM_DEBUG("waking\n"); diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c index eec0f8592..eb78c0374 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c @@ -1,8 +1,8 @@ /* gamma_dma.c -- DMA support for GMX 2000 -*- linux-c -*- * Created: Fri Mar 19 14:30:16 1999 by faith@precisioninsight.com - * Revised: Thu Sep 16 12:55:37 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,8 +23,9 @@ * 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. - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c,v 1.2 2000/02/23 04:47:28 martin Exp $ + * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -87,13 +88,31 @@ static inline void gamma_dma_dispatch(drm_device_t *dev, unsigned long address, GAMMA_WRITE(GAMMA_DMACOUNT, length / 4); } -static inline void gamma_dma_quiescent(drm_device_t *dev) +static inline void gamma_dma_quiescent_single(drm_device_t *dev) +{ + while (GAMMA_READ(GAMMA_DMACOUNT)) + ; + while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3) + ; + + GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10); + GAMMA_WRITE(GAMMA_SYNC, 0); + + do { + while (!GAMMA_READ(GAMMA_OUTFIFOWORDS)) + ; + } while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG); +} + +static inline void gamma_dma_quiescent_dual(drm_device_t *dev) { while (GAMMA_READ(GAMMA_DMACOUNT)) ; while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3) ; + GAMMA_WRITE(GAMMA_BROADCASTMASK, 3); + GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10); GAMMA_WRITE(GAMMA_SYNC, 0); @@ -103,7 +122,6 @@ static inline void gamma_dma_quiescent(drm_device_t *dev) ; } while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG); - /* Read from second MX */ do { while (!GAMMA_READ(GAMMA_OUTFIFOWORDS + 0x10000)) @@ -788,8 +806,13 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd, if (!ret) { if (lock.flags & _DRM_LOCK_READY) gamma_dma_ready(dev); - if (lock.flags & _DRM_LOCK_QUIESCENT) - gamma_dma_quiescent(dev); + if (lock.flags & _DRM_LOCK_QUIESCENT) { + if (gamma_found() == 1) { + gamma_dma_quiescent_single(dev); + } else { + gamma_dma_quiescent_dual(dev); + } + } } DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c index ce970835a..a90f09b74 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c @@ -1,8 +1,8 @@ /* gamma.c -- 3dlabs GMX 2000 driver -*- linux-c -*- * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com - * Revised: Tue Oct 12 08:51:36 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,22 +24,31 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c,v 1.4 2000/02/23 04:47:28 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ #define EXPORT_SYMTAB #include "drmP.h" #include "gamma_drv.h" +#include <linux/pci.h> EXPORT_SYMBOL(gamma_init); EXPORT_SYMBOL(gamma_cleanup); +#ifndef PCI_DEVICE_ID_3DLABS_GAMMA +#define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008 +#endif +#ifndef PCI_DEVICE_ID_3DLABS_MX +#define PCI_DEVICE_ID_3DLABS_MX 0x0006 +#endif + #define GAMMA_NAME "gamma" #define GAMMA_DESC "3dlabs GMX 2000" -#define GAMMA_DATE "19990830" -#define GAMMA_MAJOR 0 +#define GAMMA_DATE "20000606" +#define GAMMA_MAJOR 1 #define GAMMA_MINOR 0 -#define GAMMA_PATCHLEVEL 5 +#define GAMMA_PATCHLEVEL 0 static drm_device_t gamma_device; @@ -98,10 +107,13 @@ static drm_ioctl_desc_t gamma_ioctls[] = { int init_module(void); void cleanup_module(void); static char *gamma = NULL; +static int devices = 0; MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas."); MODULE_DESCRIPTION("3dlabs GMX 2000"); MODULE_PARM(gamma, "s"); +MODULE_PARM(devices, "i"); +MODULE_PARM_DESC(devices, "devices=x, where x is the number of MX chips on your card\n"); /* init_module is called when insmod is used to load the module */ @@ -121,7 +133,7 @@ void cleanup_module(void) #ifndef MODULE /* gamma_setup is called by the kernel to parse command-line options passed * via the boot-loader (e.g., LILO). It calls the insmod option routine, - * drm_parse_drm. + * drm_parse_options. * * This is not currently supported, since it requires changes to * linux/init/main.c. */ @@ -271,6 +283,12 @@ static int gamma_takedown(drm_device_t *dev) - PAGE_SHIFT, DRM_MEM_SAREA); break; +#ifdef DRM_AGP + case _DRM_AGP: + /* Do nothing here, because this is all + handled in the AGP/GART driver. */ + break; +#endif } drm_free(map, sizeof(*map), DRM_MEM_MAPS); } @@ -310,6 +328,34 @@ static int gamma_takedown(drm_device_t *dev) return 0; } +int gamma_found(void) +{ + return devices; +} + +int gamma_find_devices(void) +{ + struct pci_dev *d = NULL, *one = NULL, *two = NULL; + + d = pci_find_device(PCI_VENDOR_ID_3DLABS,PCI_DEVICE_ID_3DLABS_GAMMA,d); + if (!d) return 0; + + one = pci_find_device(PCI_VENDOR_ID_3DLABS,PCI_DEVICE_ID_3DLABS_MX,d); + if (!one) return 0; + + /* Make sure it's on the same card, if not - no MX's found */ + if (PCI_SLOT(d->devfn) != PCI_SLOT(one->devfn)) return 0; + + two = pci_find_device(PCI_VENDOR_ID_3DLABS,PCI_DEVICE_ID_3DLABS_MX,one); + if (!two) return 1; + + /* Make sure it's on the same card, if not - only 1 MX found */ + if (PCI_SLOT(d->devfn) != PCI_SLOT(two->devfn)) return 1; + + /* Two MX's found - we don't currently support more than 2 */ + return 2; +} + /* gamma_init is called via init_module at module load time, or via * linux/init/main.c (this is not currently supported). */ @@ -327,6 +373,8 @@ int gamma_init(void) #ifdef MODULE drm_parse_options(gamma); #endif + devices = gamma_find_devices(); + if (devices == 0) return -1; if ((retcode = misc_register(&gamma_misc))) { DRM_ERROR("Cannot register \"%s\"\n", GAMMA_NAME); @@ -338,13 +386,14 @@ int gamma_init(void) drm_mem_init(); drm_proc_init(dev); - DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", + DRM_INFO("Initialized %s %d.%d.%d %s on minor %d with %d MX devices\n", GAMMA_NAME, GAMMA_MAJOR, GAMMA_MINOR, GAMMA_PATCHLEVEL, GAMMA_DATE, - gamma_misc.minor); + gamma_misc.minor, + devices); return 0; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h index d78a13eb7..55dc26bec 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h @@ -1,8 +1,8 @@ /* gamma_drv.h -- Private header for 3dlabs GMX 2000 driver -*- linux-c -*- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com - * Revised: Fri Aug 20 09:24:27 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,8 +24,6 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h,v 1.2 2000/02/23 04:47:28 martin Exp $ - * */ #ifndef _GAMMA_DRV_H_ @@ -53,5 +51,7 @@ extern int gamma_irq_install(drm_device_t *dev, int irq); extern int gamma_irq_uninstall(drm_device_t *dev); extern int gamma_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); +extern int gamma_find_devices(void); +extern int gamma_found(void); #endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c index 49455b434..fa1f84dcd 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c @@ -2,6 +2,7 @@ * Created: Thu Jan 6 01:47:26 2000 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,161 +24,35 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Jeff Hartmann <jhartmann@precisioninsight.com> + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c,v 1.1 2000/02/11 17:26:04 dawes Exp $ - * */ #define __NO_VERSION__ #include "drmP.h" +#include "i810_drv.h" #include "linux/un.h" int i810_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_device_dma_t *dma = dev->dma; - drm_buf_desc_t request; - drm_buf_entry_t *entry; - drm_buf_t *buf; - unsigned long offset; - unsigned long agp_offset; - int count; - int order; - int size; - int alignment; - int page_order; - int total; - int byte_count; - int i; - - if (!dma) return -EINVAL; - - copy_from_user_ret(&request, - (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); - - count = request.count; - order = drm_order(request.size); - size = 1 << order; - agp_offset = request.agp_start; - alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; - page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; - total = PAGE_SIZE << page_order; - byte_count = 0; - - if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; - if (dev->queue_count) return -EBUSY; /* Not while in use */ - spin_lock(&dev->count_lock); - if (dev->buf_use) { - spin_unlock(&dev->count_lock); - return -EBUSY; - } - atomic_inc(&dev->buf_alloc); - spin_unlock(&dev->count_lock); - - down(&dev->struct_sem); - entry = &dma->bufs[order]; - if (entry->buf_count) { - up(&dev->struct_sem); - atomic_dec(&dev->buf_alloc); - return -ENOMEM; /* May only call once for each order */ - } - - entry->buflist = drm_alloc(count * sizeof(*entry->buflist), - DRM_MEM_BUFS); - if (!entry->buflist) { - up(&dev->struct_sem); - atomic_dec(&dev->buf_alloc); - return -ENOMEM; - } - memset(entry->buflist, 0, count * sizeof(*entry->buflist)); - - entry->buf_size = size; - entry->page_order = page_order; - - while(entry->buf_count < count) { - for(offset = 0; offset + size <= total && entry->buf_count < count; - offset += alignment, ++entry->buf_count) { - buf = &entry->buflist[entry->buf_count]; - buf->idx = dma->buf_count + entry->buf_count; - buf->total = alignment; - buf->order = order; - buf->used = 0; - buf->offset = agp_offset - dev->agp->base + offset;/* ?? */ - buf->bus_address = agp_offset + offset; - buf->address = agp_offset + offset + dev->agp->base; - buf->next = NULL; - buf->waiting = 0; - buf->pending = 0; - init_waitqueue_head(&buf->dma_wait); - buf->pid = 0; -#if DRM_DMA_HISTOGRAM - buf->time_queued = 0; - buf->time_dispatched = 0; - buf->time_completed = 0; - buf->time_freed = 0; -#endif - DRM_DEBUG("buffer %d @ %p\n", - entry->buf_count, buf->address); - } - byte_count += PAGE_SIZE << page_order; - } - - dma->buflist = drm_realloc(dma->buflist, - dma->buf_count * sizeof(*dma->buflist), - (dma->buf_count + entry->buf_count) - * sizeof(*dma->buflist), - DRM_MEM_BUFS); - for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++) - dma->buflist[i] = &entry->buflist[i - dma->buf_count]; - - dma->buf_count += entry->buf_count; - dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order); - - drm_freelist_create(&entry->freelist, entry->buf_count); - for (i = 0; i < entry->buf_count; i++) { - drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]); - } - - up(&dev->struct_sem); - - request.count = entry->buf_count; - request.size = size; - - copy_to_user_ret((drm_buf_desc_t *)arg, - &request, - sizeof(request), - -EFAULT); - - atomic_dec(&dev->buf_alloc); - return 0; -} - -int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_device_dma_t *dma = dev->dma; - drm_buf_desc_t request; - int count; - int order; - int size; - int total; - int page_order; - drm_buf_entry_t *entry; - unsigned long page; - drm_buf_t *buf; - int alignment; - unsigned long offset; - int i; - int byte_count; - int page_count; + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_device_dma_t *dma = dev->dma; + drm_buf_desc_t request; + drm_buf_entry_t *entry; + drm_buf_t *buf; + unsigned long offset; + unsigned long agp_offset; + int count; + int order; + int size; + int alignment; + int page_order; + int total; + int byte_count; + int i; if (!dma) return -EINVAL; @@ -186,20 +61,17 @@ int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, sizeof(request), -EFAULT); - count = request.count; - order = drm_order(request.size); - size = 1 << order; - - DRM_DEBUG("count = %d, size = %d (%d), order = %d, queue_count = %d\n", - request.count, request.size, size, order, dev->queue_count); - - if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; - if (dev->queue_count) return -EBUSY; /* Not while in use */ - + count = request.count; + order = drm_order(request.size); + size = 1 << order; + agp_offset = request.agp_start; alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; - total = PAGE_SIZE << page_order; - + total = PAGE_SIZE << page_order; + byte_count = 0; + + if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; + if (dev->queue_count) return -EBUSY; /* Not while in use */ spin_lock(&dev->count_lock); if (dev->buf_use) { spin_unlock(&dev->count_lock); @@ -207,15 +79,15 @@ int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, } atomic_inc(&dev->buf_alloc); spin_unlock(&dev->count_lock); - + down(&dev->struct_sem); entry = &dma->bufs[order]; if (entry->buf_count) { up(&dev->struct_sem); atomic_dec(&dev->buf_alloc); - return -ENOMEM; /* May only call once for each order */ + return -ENOMEM; /* May only call once for each order */ } - + entry->buflist = drm_alloc(count * sizeof(*entry->buflist), DRM_MEM_BUFS); if (!entry->buflist) { @@ -224,69 +96,45 @@ int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, return -ENOMEM; } memset(entry->buflist, 0, count * sizeof(*entry->buflist)); - - entry->seglist = drm_alloc(count * sizeof(*entry->seglist), - DRM_MEM_SEGS); - if (!entry->seglist) { - drm_free(entry->buflist, - count * sizeof(*entry->buflist), - DRM_MEM_BUFS); - up(&dev->struct_sem); - atomic_dec(&dev->buf_alloc); - return -ENOMEM; - } - memset(entry->seglist, 0, count * sizeof(*entry->seglist)); - - dma->pagelist = drm_realloc(dma->pagelist, - dma->page_count * sizeof(*dma->pagelist), - (dma->page_count + (count << page_order)) - * sizeof(*dma->pagelist), - DRM_MEM_PAGES); - DRM_DEBUG("pagelist: %d entries\n", - dma->page_count + (count << page_order)); - - - entry->buf_size = size; + + entry->buf_size = size; entry->page_order = page_order; - byte_count = 0; - page_count = 0; - while (entry->buf_count < count) { - if (!(page = drm_alloc_pages(page_order, DRM_MEM_DMA))) break; - entry->seglist[entry->seg_count++] = page; - for (i = 0; i < (1 << page_order); i++) { - DRM_DEBUG("page %d @ 0x%08lx\n", - dma->page_count + page_count, - page + PAGE_SIZE * i); - dma->pagelist[dma->page_count + page_count++] - = page + PAGE_SIZE * i; - } - for (offset = 0; - offset + size <= total && entry->buf_count < count; - offset += alignment, ++entry->buf_count) { - buf = &entry->buflist[entry->buf_count]; - buf->idx = dma->buf_count + entry->buf_count; - buf->total = alignment; - buf->order = order; - buf->used = 0; - buf->offset = (dma->byte_count + byte_count + offset); - buf->address = (void *)(page + offset); - buf->next = NULL; - buf->waiting = 0; - buf->pending = 0; - init_waitqueue_head(&buf->dma_wait); - buf->pid = 0; + offset = 0; + + while(entry->buf_count < count) { + buf = &entry->buflist[entry->buf_count]; + buf->idx = dma->buf_count + entry->buf_count; + buf->total = alignment; + buf->order = order; + buf->used = 0; + buf->offset = offset; + buf->bus_address = dev->agp->base + agp_offset + offset; + buf->address = (void *)(agp_offset + offset + dev->agp->base); + buf->next = NULL; + buf->waiting = 0; + buf->pending = 0; + init_waitqueue_head(&buf->dma_wait); + buf->pid = 0; + + buf->dev_private = drm_alloc(sizeof(drm_i810_buf_priv_t), + DRM_MEM_BUFS); + buf->dev_priv_size = sizeof(drm_i810_buf_priv_t); + memset(buf->dev_private, 0, sizeof(drm_i810_buf_priv_t)); + #if DRM_DMA_HISTOGRAM - buf->time_queued = 0; - buf->time_dispatched = 0; - buf->time_completed = 0; - buf->time_freed = 0; + buf->time_queued = 0; + buf->time_dispatched = 0; + buf->time_completed = 0; + buf->time_freed = 0; #endif - DRM_DEBUG("buffer %d @ %p\n", - entry->buf_count, buf->address); - } + offset = offset + alignment; + entry->buf_count++; byte_count += PAGE_SIZE << page_order; + + DRM_DEBUG("buffer %d @ %p\n", + entry->buf_count, buf->address); } - + dma->buflist = drm_realloc(dma->buflist, dma->buf_count * sizeof(*dma->buflist), (dma->buf_count + entry->buf_count) @@ -294,45 +142,43 @@ int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, DRM_MEM_BUFS); for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++) dma->buflist[i] = &entry->buflist[i - dma->buf_count]; - - dma->buf_count += entry->buf_count; - dma->seg_count += entry->seg_count; - dma->page_count += entry->seg_count << page_order; - dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order); - + + dma->buf_count += entry->buf_count; + dma->byte_count += byte_count; drm_freelist_create(&entry->freelist, entry->buf_count); for (i = 0; i < entry->buf_count; i++) { drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]); } - + up(&dev->struct_sem); - + request.count = entry->buf_count; request.size = size; - + copy_to_user_ret((drm_buf_desc_t *)arg, &request, sizeof(request), -EFAULT); - + atomic_dec(&dev->buf_alloc); + dma->flags = _DRM_DMA_USE_AGP; return 0; } int i810_addbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { - drm_buf_desc_t request; + drm_buf_desc_t request; - copy_from_user_ret(&request, - (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + copy_from_user_ret(&request, + (drm_buf_desc_t *)arg, + sizeof(request), + -EFAULT); - if(request.flags & _DRM_AGP_BUFFER) - return i810_addbufs_agp(inode, filp, cmd, arg); - else - return i810_addbufs_pci(inode, filp, cmd, arg); + if(request.flags & _DRM_AGP_BUFFER) + return i810_addbufs_agp(inode, filp, cmd, arg); + else + return -EINVAL; } int i810_infobufs(struct inode *inode, struct file *filp, unsigned int cmd, @@ -486,99 +332,3 @@ int i810_freebufs(struct inode *inode, struct file *filp, unsigned int cmd, return 0; } -int i810_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) -{ - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_device_dma_t *dma = dev->dma; - int retcode = 0; - const int zero = 0; - unsigned long virtual; - unsigned long address; - drm_buf_map_t request; - int i; - - if (!dma) return -EINVAL; - - DRM_DEBUG("\n"); - - spin_lock(&dev->count_lock); - if (atomic_read(&dev->buf_alloc)) { - spin_unlock(&dev->count_lock); - return -EBUSY; - } - ++dev->buf_use; /* Can't allocate more after this call */ - spin_unlock(&dev->count_lock); - - copy_from_user_ret(&request, - (drm_buf_map_t *)arg, - sizeof(request), - -EFAULT); - - if (request.count >= dma->buf_count) { - if(dma->flags & _DRM_DMA_USE_AGP) { - /* This is an ugly vicious hack */ - drm_map_t *map = NULL; - for(i = 0; i < dev->map_count; i++) { - map = dev->maplist[i]; - if(map->type == _DRM_AGP) break; - } - if (i >= dev->map_count || !map) { - retcode = -EINVAL; - goto done; - } - - virtual = do_mmap(filp, 0, map->size, PROT_READ|PROT_WRITE, - MAP_SHARED, (unsigned long)map->handle); - } - else { - virtual = do_mmap(filp, 0, dma->byte_count, - PROT_READ|PROT_WRITE, MAP_SHARED, 0); - } - if (virtual > -1024UL) { - /* Real error */ - retcode = (signed long)virtual; - goto done; - } - request.virtual = (void *)virtual; - - for (i = 0; i < dma->buf_count; i++) { - if (copy_to_user(&request.list[i].idx, - &dma->buflist[i]->idx, - sizeof(request.list[0].idx))) { - retcode = -EFAULT; - goto done; - } - if (copy_to_user(&request.list[i].total, - &dma->buflist[i]->total, - sizeof(request.list[0].total))) { - retcode = -EFAULT; - goto done; - } - if (copy_to_user(&request.list[i].used, - &zero, - sizeof(zero))) { - retcode = -EFAULT; - goto done; - } - address = virtual + dma->buflist[i]->offset; - if (copy_to_user(&request.list[i].address, - &address, - sizeof(address))) { - retcode = -EFAULT; - goto done; - } - } - } -done: - request.count = dma->buf_count; - DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode); - - copy_to_user_ret((drm_buf_map_t *)arg, - &request, - sizeof(request), - -EFAULT); - - return retcode; -} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c new file mode 100644 index 000000000..689814db5 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c @@ -0,0 +1,205 @@ +/* i810_context.c -- IOCTLs for i810 contexts -*- linux-c -*- + * Created: Mon Dec 13 09:51:35 1999 by faith@precisioninsight.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * 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 (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 NONINFRINGEMENT. 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: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> + * + */ + +#include <linux/sched.h> + +#define __NO_VERSION__ +#include "drmP.h" +#include "i810_drv.h" + +static int i810_alloc_queue(drm_device_t *dev) +{ + int temp = drm_ctxbitmap_next(dev); + DRM_DEBUG("i810_alloc_queue: %d\n", temp); + return temp; +} + +int i810_context_switch(drm_device_t *dev, int old, int new) +{ + char buf[64]; + + atomic_inc(&dev->total_ctx); + + if (test_and_set_bit(0, &dev->context_flag)) { + DRM_ERROR("Reentering -- FIXME\n"); + return -EBUSY; + } + +#if DRM_DMA_HISTOGRAM + dev->ctx_start = get_cycles(); +#endif + + DRM_DEBUG("Context switch from %d to %d\n", old, new); + + if (new == dev->last_context) { + clear_bit(0, &dev->context_flag); + return 0; + } + + if (drm_flags & DRM_FLAG_NOCTX) { + i810_context_switch_complete(dev, new); + } else { + sprintf(buf, "C %d %d\n", old, new); + drm_write_string(dev, buf); + } + + return 0; +} + +int i810_context_switch_complete(drm_device_t *dev, int new) +{ + dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ + dev->last_switch = jiffies; + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("Lock isn't held after context switch\n"); + } + + /* If a context switch is ever initiated + when the kernel holds the lock, release + that lock here. */ +#if DRM_DMA_HISTOGRAM + atomic_inc(&dev->histo.ctx[drm_histogram_slot(get_cycles() + - dev->ctx_start)]); + +#endif + clear_bit(0, &dev->context_flag); + wake_up(&dev->context_wait); + + return 0; +} + +int i810_resctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_ctx_res_t res; + drm_ctx_t ctx; + int i; + + DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); + copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); + if (res.count >= DRM_RESERVED_CONTEXTS) { + memset(&ctx, 0, sizeof(ctx)); + for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) { + ctx.handle = i; + copy_to_user_ret(&res.contexts[i], + &i, + sizeof(i), + -EFAULT); + } + } + res.count = DRM_RESERVED_CONTEXTS; + copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT); + return 0; +} + +int i810_addctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + if ((ctx.handle = i810_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) { + /* Skip kernel's context and get a new one. */ + ctx.handle = i810_alloc_queue(dev); + } + if (ctx.handle == -1) { + DRM_DEBUG("Not enough free contexts.\n"); + /* Should this return -EBUSY instead? */ + return -ENOMEM; + } + DRM_DEBUG("%d\n", ctx.handle); + copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); + return 0; +} + +int i810_modctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + /* This does nothing for the i810 */ + return 0; +} + +int i810_getctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_ctx_t ctx; + + copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT); + /* This is 0, because we don't hanlde any context flags */ + ctx.flags = 0; + copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT); + return 0; +} + +int i810_switchctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + DRM_DEBUG("%d\n", ctx.handle); + return i810_context_switch(dev, dev->last_context, ctx.handle); +} + +int i810_newctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + DRM_DEBUG("%d\n", ctx.handle); + i810_context_switch_complete(dev, ctx.handle); + + return 0; +} + +int i810_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_ctx_t ctx; + + copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); + DRM_DEBUG("%d\n", ctx.handle); + if(ctx.handle != DRM_KERNEL_CONTEXT) { + drm_ctxbitmap_free(dev, ctx.handle); + } + + return 0; +} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c index 09959b657..94f35b61c 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c @@ -2,6 +2,7 @@ * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,10 +24,9 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Jeff Hartmann <jhartmann@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c,v 1.1 2000/02/11 17:26:04 dawes Exp $ + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> + * Keith Whitwell <keithw@valinux.com> * */ @@ -36,6 +36,18 @@ #include <linux/interrupt.h> /* For task queue support */ +/* in case we don't have a 2.3.99-pre6 kernel or later: */ +#ifndef VM_DONTCOPY +#define VM_DONTCOPY 0 +#endif + +#define I810_BUF_FREE 2 +#define I810_BUF_CLIENT 1 +#define I810_BUF_HARDWARE 0 + +#define I810_BUF_UNMAPPED 0 +#define I810_BUF_MAPPED 1 + #define I810_REG(reg) 2 #define I810_BASE(reg) ((unsigned long) \ dev->maplist[I810_REG(reg)]->handle) @@ -43,544 +55,835 @@ #define I810_DEREF(reg) *(__volatile__ int *)I810_ADDR(reg) #define I810_READ(reg) I810_DEREF(reg) #define I810_WRITE(reg,val) do { I810_DEREF(reg) = val; } while (0) - -void i810_dma_init(drm_device_t *dev) +#define I810_DEREF16(reg) *(__volatile__ u16 *)I810_ADDR(reg) +#define I810_READ16(reg) I810_DEREF16(reg) +#define I810_WRITE16(reg,val) do { I810_DEREF16(reg) = val; } while (0) + +#define RING_LOCALS unsigned int outring, ringmask; volatile char *virt; + +#define BEGIN_LP_RING(n) do { \ + if (I810_VERBOSE) \ + DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n", \ + n, __FUNCTION__); \ + if (dev_priv->ring.space < n*4) \ + i810_wait_ring(dev, n*4); \ + dev_priv->ring.space -= n*4; \ + outring = dev_priv->ring.tail; \ + ringmask = dev_priv->ring.tail_mask; \ + virt = dev_priv->ring.virtual_start; \ +} while (0) + +#define ADVANCE_LP_RING() do { \ + if (I810_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING\n"); \ + dev_priv->ring.tail = outring; \ + I810_WRITE(LP_RING + RING_TAIL, outring); \ +} while(0) + +#define OUT_RING(n) do { \ + if (I810_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \ + *(volatile unsigned int *)(virt + outring) = n; \ + outring += 4; \ + outring &= ringmask; \ +} while (0); + +static inline void i810_print_status_page(drm_device_t *dev) { - printk(KERN_INFO "i810_dma_init\n"); + drm_device_dma_t *dma = dev->dma; + drm_i810_private_t *dev_priv = dev->dev_private; + u32 *temp = (u32 *)dev_priv->hw_status_page; + int i; + + DRM_DEBUG( "hw_status: Interrupt Status : %x\n", temp[0]); + DRM_DEBUG( "hw_status: LpRing Head ptr : %x\n", temp[1]); + DRM_DEBUG( "hw_status: IRing Head ptr : %x\n", temp[2]); + DRM_DEBUG( "hw_status: Reserved : %x\n", temp[3]); + DRM_DEBUG( "hw_status: Driver Counter : %d\n", temp[5]); + for(i = 6; i < dma->buf_count + 6; i++) { + DRM_DEBUG( "buffer status idx : %d used: %d\n", i - 6, temp[i]); + } } -void i810_dma_cleanup(drm_device_t *dev) +static drm_buf_t *i810_freelist_get(drm_device_t *dev) { - printk(KERN_INFO "i810_dma_cleanup\n"); + drm_device_dma_t *dma = dev->dma; + int i; + int used; + + /* Linear search might not be the best solution */ + + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + /* In use is already a pointer */ + used = cmpxchg(buf_priv->in_use, I810_BUF_FREE, + I810_BUF_CLIENT); + if(used == I810_BUF_FREE) { + return buf; + } + } + return NULL; } -static inline void i810_dma_dispatch(drm_device_t *dev, unsigned long address, - unsigned long length) +/* This should only be called if the buffer is not sent to the hardware + * yet, the hardware updates in use for us once its on the ring buffer. + */ + +static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf) { - printk(KERN_INFO "i810_dma_dispatch\n"); + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + int used; + + /* In use is already a pointer */ + used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, I810_BUF_FREE); + if(used != I810_BUF_CLIENT) { + DRM_ERROR("Freeing buffer thats not in use : %d\n", buf->idx); + return -EINVAL; + } + + return 0; } -static inline void i810_dma_quiescent(drm_device_t *dev) +static struct file_operations i810_buffer_fops = { + open: i810_open, + flush: drm_flush, + release: i810_release, + ioctl: i810_ioctl, + mmap: i810_mmap_buffers, + read: drm_read, + fasync: drm_fasync, + poll: drm_poll, +}; + +int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) { + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_i810_private_t *dev_priv = dev->dev_private; + drm_buf_t *buf = dev_priv->mmap_buffer; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + + vma->vm_flags |= (VM_IO | VM_DONTCOPY); + vma->vm_file = filp; + + buf_priv->currently_mapped = I810_BUF_MAPPED; + + if (remap_page_range(vma->vm_start, + VM_OFFSET(vma), + vma->vm_end - vma->vm_start, + vma->vm_page_prot)) return -EAGAIN; + return 0; } -static inline void i810_dma_ready(drm_device_t *dev) +static int i810_map_buffer(drm_buf_t *buf, struct file *filp) { - i810_dma_quiescent(dev); - printk(KERN_INFO "i810_dma_ready\n"); + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + drm_i810_private_t *dev_priv = dev->dev_private; + struct file_operations *old_fops; + int retcode = 0; + + if(buf_priv->currently_mapped == I810_BUF_MAPPED) return -EINVAL; + down(¤t->mm->mmap_sem); + old_fops = filp->f_op; + filp->f_op = &i810_buffer_fops; + dev_priv->mmap_buffer = buf; + buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total, + PROT_READ|PROT_WRITE, + MAP_SHARED, + buf->bus_address); + dev_priv->mmap_buffer = NULL; + filp->f_op = old_fops; + if ((unsigned long)buf_priv->virtual > -1024UL) { + /* Real error */ + DRM_DEBUG("mmap error\n"); + retcode = (signed int)buf_priv->virtual; + buf_priv->virtual = 0; + } + up(¤t->mm->mmap_sem); + return retcode; } -static inline int i810_dma_is_ready(drm_device_t *dev) +static int i810_unmap_buffer(drm_buf_t *buf) { + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + int retcode = 0; - i810_dma_quiescent(dev); + if(buf_priv->currently_mapped != I810_BUF_MAPPED) return -EINVAL; + down(¤t->mm->mmap_sem); + retcode = do_munmap((unsigned long)buf_priv->virtual, + (size_t) buf->total); + buf_priv->currently_mapped = I810_BUF_UNMAPPED; + buf_priv->virtual = 0; + up(¤t->mm->mmap_sem); - printk(KERN_INFO "i810_dma_is_ready\n"); - return 1; + return retcode; } - -static void i810_dma_service(int irq, void *device, struct pt_regs *regs) +static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d, + struct file *filp) { - drm_device_t *dev = (drm_device_t *)device; - drm_device_dma_t *dma = dev->dma; - - atomic_inc(&dev->total_irq); - if (i810_dma_is_ready(dev)) { - /* Free previous buffer */ - if (test_and_set_bit(0, &dev->dma_flag)) { - atomic_inc(&dma->total_missed_free); - return; - } - if (dma->this_buffer) { - drm_free_buffer(dev, dma->this_buffer); - dma->this_buffer = NULL; - } - clear_bit(0, &dev->dma_flag); - - /* Dispatch new buffer */ - queue_task(&dev->tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); + drm_file_t *priv = filp->private_data; + drm_buf_t *buf; + drm_i810_buf_priv_t *buf_priv; + int retcode = 0; + + buf = i810_freelist_get(dev); + if (!buf) { + retcode = -ENOMEM; + DRM_DEBUG("%s retcode %d\n", __FUNCTION__, retcode); + goto out_get_buf; + } + + retcode = i810_map_buffer(buf, filp); + if(retcode) { + i810_freelist_put(dev, buf); + DRM_DEBUG("mapbuf failed in %s retcode %d\n", + __FUNCTION__, retcode); + goto out_get_buf; } + buf->pid = priv->pid; + buf_priv = buf->dev_private; + d->granted = 1; + d->request_idx = buf->idx; + d->request_size = buf->total; + d->virtual = buf_priv->virtual; + +out_get_buf: + return retcode; } -/* Only called by i810_dma_schedule. */ -static int i810_do_dma(drm_device_t *dev, int locked) +static unsigned long i810_alloc_page(drm_device_t *dev) { - unsigned long address; - unsigned long length; - drm_buf_t *buf; - int retcode = 0; - drm_device_dma_t *dma = dev->dma; -#if DRM_DMA_HISTOGRAM - cycles_t dma_start, dma_stop; -#endif - - if (test_and_set_bit(0, &dev->dma_flag)) { - atomic_inc(&dma->total_missed_dma); - return -EBUSY; - } + unsigned long address; + + address = __get_free_page(GFP_KERNEL); + if(address == 0UL) + return 0; -#if DRM_DMA_HISTOGRAM - dma_start = get_cycles(); -#endif - - if (!dma->next_buffer) { - DRM_ERROR("No next_buffer\n"); - clear_bit(0, &dev->dma_flag); - return -EINVAL; - } + atomic_inc(&mem_map[MAP_NR((void *) address)].count); + set_bit(PG_locked, &mem_map[MAP_NR((void *) address)].flags); + + return address; +} - buf = dma->next_buffer; - address = (unsigned long)buf->bus_address; - length = buf->used; +static void i810_free_page(drm_device_t *dev, unsigned long page) +{ + if(page == 0UL) + return; + atomic_dec(&mem_map[MAP_NR((void *) page)].count); + clear_bit(PG_locked, &mem_map[MAP_NR((void *) page)].flags); + wake_up(&mem_map[MAP_NR((void *) page)].wait); + free_page(page); + return; +} - DRM_DEBUG("context %d, buffer %d (%ld bytes)\n", - buf->context, buf->idx, length); - - if (buf->list == DRM_LIST_RECLAIM) { - drm_clear_next_buffer(dev); - drm_free_buffer(dev, buf); - clear_bit(0, &dev->dma_flag); - return -EINVAL; - } - - if (!length) { - DRM_ERROR("0 length buffer\n"); - drm_clear_next_buffer(dev); - drm_free_buffer(dev, buf); - clear_bit(0, &dev->dma_flag); - return 0; - } - - if (!i810_dma_is_ready(dev)) { - clear_bit(0, &dev->dma_flag); - return -EBUSY; - } +static int i810_dma_cleanup(drm_device_t *dev) +{ + drm_device_dma_t *dma = dev->dma; - if (buf->while_locked) { - if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { - DRM_ERROR("Dispatching buffer %d from pid %d" - " \"while locked\", but no lock held\n", - buf->idx, buf->pid); + if(dev->dev_private) { + int i; + drm_i810_private_t *dev_priv = + (drm_i810_private_t *) dev->dev_private; + + if(dev_priv->ring.virtual_start) { + drm_ioremapfree((void *) dev_priv->ring.virtual_start, + dev_priv->ring.Size); + } + if(dev_priv->hw_status_page != 0UL) { + i810_free_page(dev, dev_priv->hw_status_page); + /* Need to rewrite hardware status page */ + I810_WRITE(0x02080, 0x1ffff000); } - } else { - if (!locked && !drm_lock_take(&dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - atomic_inc(&dma->total_missed_lock); - clear_bit(0, &dev->dma_flag); - return -EBUSY; + drm_free(dev->dev_private, sizeof(drm_i810_private_t), + DRM_MEM_DRIVER); + dev->dev_private = NULL; + + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + drm_ioremapfree(buf_priv->kernel_virtual, buf->total); } } + return 0; +} - if (dev->last_context != buf->context - && !(dev->queuelist[buf->context]->flags - & _DRM_CONTEXT_PRESERVED)) { - /* PRE: dev->last_context != buf->context */ - if (drm_context_switch(dev, dev->last_context, buf->context)) { - drm_clear_next_buffer(dev); - drm_free_buffer(dev, buf); +static int i810_wait_ring(drm_device_t *dev, int n) +{ + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_ring_buffer_t *ring = &(dev_priv->ring); + int iters = 0; + unsigned long end; + unsigned int last_head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; + + end = jiffies + (HZ*3); + while (ring->space < n) { + int i; + + ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; + ring->space = ring->head - (ring->tail+8); + if (ring->space < 0) ring->space += ring->Size; + + if (ring->head != last_head) + end = jiffies + (HZ*3); + + iters++; + if((signed)(end - jiffies) <= 0) { + DRM_ERROR("space: %d wanted %d\n", ring->space, n); + DRM_ERROR("lockup\n"); + goto out_wait_ring; } - retcode = -EBUSY; - goto cleanup; - - /* POST: we will wait for the context - switch and will dispatch on a later call - when dev->last_context == buf->context. - NOTE WE HOLD THE LOCK THROUGHOUT THIS - TIME! */ - } - - drm_clear_next_buffer(dev); - buf->pending = 1; - buf->waiting = 0; - buf->list = DRM_LIST_PEND; -#if DRM_DMA_HISTOGRAM - buf->time_dispatched = get_cycles(); -#endif - - i810_dma_dispatch(dev, address, length); - drm_free_buffer(dev, dma->this_buffer); - dma->this_buffer = buf; - atomic_add(length, &dma->total_bytes); - atomic_inc(&dma->total_dmas); - - if (!buf->while_locked && !dev->context_flag && !locked) { - if (drm_lock_free(dev, &dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - DRM_ERROR("\n"); - } + for (i = 0 ; i < 2000 ; i++) ; } -cleanup: - clear_bit(0, &dev->dma_flag); - -#if DRM_DMA_HISTOGRAM - dma_stop = get_cycles(); - atomic_inc(&dev->histo.dma[drm_histogram_slot(dma_stop - dma_start)]); -#endif - - return retcode; +out_wait_ring: + return iters; } -static void i810_dma_schedule_timer_wrapper(unsigned long dev) +static void i810_kernel_lost_context(drm_device_t *dev) { - i810_dma_schedule((drm_device_t *)dev, 0); + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_ring_buffer_t *ring = &(dev_priv->ring); + + ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR; + ring->tail = I810_READ(LP_RING + RING_TAIL); + ring->space = ring->head - (ring->tail+8); + if (ring->space < 0) ring->space += ring->Size; } -static void i810_dma_schedule_tq_wrapper(void *dev) +static int i810_freelist_init(drm_device_t *dev) { - i810_dma_schedule(dev, 0); + drm_device_dma_t *dma = dev->dma; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + int my_idx = 24; + u32 *hw_status = (u32 *)(dev_priv->hw_status_page + my_idx); + int i; + + if(dma->buf_count > 1019) { + /* Not enough space in the status page for the freelist */ + return -EINVAL; + } + + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + + buf_priv->in_use = hw_status++; + buf_priv->my_use_idx = my_idx; + my_idx += 4; + + *buf_priv->in_use = I810_BUF_FREE; + + buf_priv->kernel_virtual = drm_ioremap(buf->bus_address, + buf->total); + } + return 0; } -int i810_dma_schedule(drm_device_t *dev, int locked) +static int i810_dma_initialize(drm_device_t *dev, + drm_i810_private_t *dev_priv, + drm_i810_init_t *init) { - int next; - drm_queue_t *q; - drm_buf_t *buf; - int retcode = 0; - int processed = 0; - int missed; - int expire = 20; - drm_device_dma_t *dma = dev->dma; -#if DRM_DMA_HISTOGRAM - cycles_t schedule_start; -#endif + drm_map_t *sarea_map; - if (test_and_set_bit(0, &dev->interrupt_flag)) { - /* Not reentrant */ - atomic_inc(&dma->total_missed_sched); - return -EBUSY; + dev->dev_private = (void *) dev_priv; + memset(dev_priv, 0, sizeof(drm_i810_private_t)); + + if (init->ring_map_idx >= dev->map_count || + init->buffer_map_idx >= dev->map_count) { + i810_dma_cleanup(dev); + DRM_ERROR("ring_map or buffer_map are invalid\n"); + return -EINVAL; + } + + dev_priv->ring_map_idx = init->ring_map_idx; + dev_priv->buffer_map_idx = init->buffer_map_idx; + sarea_map = dev->maplist[0]; + dev_priv->sarea_priv = (drm_i810_sarea_t *) + ((u8 *)sarea_map->handle + + init->sarea_priv_offset); + + atomic_set(&dev_priv->flush_done, 0); + init_waitqueue_head(&dev_priv->flush_queue); + + dev_priv->ring.Start = init->ring_start; + dev_priv->ring.End = init->ring_end; + dev_priv->ring.Size = init->ring_size; + + dev_priv->ring.virtual_start = drm_ioremap(dev->agp->base + + init->ring_start, + init->ring_size); + + dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; + + if (dev_priv->ring.virtual_start == NULL) { + i810_dma_cleanup(dev); + DRM_ERROR("can not ioremap virtual address for" + " ring buffer\n"); + return -ENOMEM; } - missed = atomic_read(&dma->total_missed_sched); -#if DRM_DMA_HISTOGRAM - schedule_start = get_cycles(); -#endif + dev_priv->w = init->w; + dev_priv->h = init->h; + dev_priv->pitch = init->pitch; + dev_priv->back_offset = init->back_offset; + dev_priv->depth_offset = init->depth_offset; -again: - if (dev->context_flag) { - clear_bit(0, &dev->interrupt_flag); - return -EBUSY; + dev_priv->front_di1 = init->front_offset | init->pitch_bits; + dev_priv->back_di1 = init->back_offset | init->pitch_bits; + dev_priv->zi1 = init->depth_offset | init->pitch_bits; + + + /* Program Hardware Status Page */ + dev_priv->hw_status_page = i810_alloc_page(dev); + memset((void *) dev_priv->hw_status_page, 0, PAGE_SIZE); + if(dev_priv->hw_status_page == 0UL) { + i810_dma_cleanup(dev); + DRM_ERROR("Can not allocate hardware status page\n"); + return -ENOMEM; } - if (dma->next_buffer) { - /* Unsent buffer that was previously - selected, but that couldn't be sent - because the lock could not be obtained - or the DMA engine wasn't ready. Try - again. */ - atomic_inc(&dma->total_tried); - if (!(retcode = i810_do_dma(dev, locked))) { - atomic_inc(&dma->total_hit); - ++processed; - } - } else { - do { - next = drm_select_queue(dev, - i810_dma_schedule_timer_wrapper); - if (next >= 0) { - q = dev->queuelist[next]; - buf = drm_waitlist_get(&q->waitlist); - dma->next_buffer = buf; - dma->next_queue = q; - if (buf && buf->list == DRM_LIST_RECLAIM) { - drm_clear_next_buffer(dev); - drm_free_buffer(dev, buf); - } - } - } while (next >= 0 && !dma->next_buffer); - if (dma->next_buffer) { - if (!(retcode = i810_do_dma(dev, locked))) { - ++processed; - } - } + DRM_DEBUG("hw status page @ %lx\n", dev_priv->hw_status_page); + + I810_WRITE(0x02080, virt_to_bus((void *)dev_priv->hw_status_page)); + DRM_DEBUG("Enabled hardware status page\n"); + + /* Now we need to init our freelist */ + if(i810_freelist_init(dev) != 0) { + i810_dma_cleanup(dev); + DRM_ERROR("Not enough space in the status page for" + " the freelist\n"); + return -ENOMEM; } + return 0; +} - if (--expire) { - if (missed != atomic_read(&dma->total_missed_sched)) { - atomic_inc(&dma->total_lost); - if (i810_dma_is_ready(dev)) goto again; - } - if (processed && i810_dma_is_ready(dev)) { - atomic_inc(&dma->total_lost); - processed = 0; - goto again; - } - } +int i810_dma_init(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_i810_private_t *dev_priv; + drm_i810_init_t init; + int retcode = 0; - clear_bit(0, &dev->interrupt_flag); + copy_from_user_ret(&init, (drm_i810_init_t *)arg, + sizeof(init), -EFAULT); -#if DRM_DMA_HISTOGRAM - atomic_inc(&dev->histo.schedule[drm_histogram_slot(get_cycles() - - schedule_start)]); -#endif - return retcode; + switch(init.func) { + case I810_INIT_DMA: + dev_priv = drm_alloc(sizeof(drm_i810_private_t), + DRM_MEM_DRIVER); + if(dev_priv == NULL) return -ENOMEM; + retcode = i810_dma_initialize(dev, dev_priv, &init); + break; + case I810_CLEANUP_DMA: + retcode = i810_dma_cleanup(dev); + break; + default: + retcode = -EINVAL; + break; + } + + return retcode; } -static int i810_dma_priority(drm_device_t *dev, drm_dma_t *d) -{ - unsigned long address; - unsigned long length; - int must_free = 0; - int retcode = 0; - int i; - int idx; - drm_buf_t *buf; - drm_buf_t *last_buf = NULL; - drm_device_dma_t *dma = dev->dma; - DECLARE_WAITQUEUE(entry, current); - /* Turn off interrupt handling */ - while (test_and_set_bit(0, &dev->interrupt_flag)) { - schedule(); - if (signal_pending(current)) return -EINTR; - } - if (!(d->flags & _DRM_DMA_WHILE_LOCKED)) { - while (!drm_lock_take(&dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - schedule(); - if (signal_pending(current)) { - clear_bit(0, &dev->interrupt_flag); - return -EINTR; - } - } - ++must_free; + +/* Most efficient way to verify state for the i810 is as it is + * emitted. Non-conformant state is silently dropped. + * + * Use 'volatile' & local var tmp to force the emitted values to be + * identical to the verified ones. + */ +static void i810EmitContextVerified( drm_device_t *dev, + volatile unsigned int *code ) +{ + drm_i810_private_t *dev_priv = dev->dev_private; + int i, j = 0; + unsigned int tmp; + RING_LOCALS; + + BEGIN_LP_RING( I810_CTX_SETUP_SIZE ); + + OUT_RING( GFX_OP_COLOR_FACTOR ); + OUT_RING( code[I810_CTXREG_CF1] ); + + OUT_RING( GFX_OP_STIPPLE ); + OUT_RING( code[I810_CTXREG_ST1] ); + + for ( i = 4 ; i < I810_CTX_SETUP_SIZE ; i++ ) { + tmp = code[i]; + + if ((tmp & (7<<29)) == (3<<29) && + (tmp & (0x1f<<24)) < (0x1d<<24)) + { + OUT_RING( tmp ); + j++; + } } - atomic_inc(&dma->total_prio); - for (i = 0; i < d->send_count; i++) { - idx = d->send_indices[i]; - if (idx < 0 || idx >= dma->buf_count) { - DRM_ERROR("Index %d (of %d max)\n", - d->send_indices[i], dma->buf_count - 1); - continue; - } - buf = dma->buflist[ idx ]; - if (buf->pid != current->pid) { - DRM_ERROR("Process %d using buffer owned by %d\n", - current->pid, buf->pid); - retcode = -EINVAL; - goto cleanup; - } - if (buf->list != DRM_LIST_NONE) { - DRM_ERROR("Process %d using %d's buffer on list %d\n", - current->pid, buf->pid, buf->list); - retcode = -EINVAL; - goto cleanup; - } - /* This isn't a race condition on - buf->list, since our concern is the - buffer reclaim during the time the - process closes the /dev/drm? handle, so - it can't also be doing DMA. */ - buf->list = DRM_LIST_PRIO; - buf->used = d->send_sizes[i]; - buf->context = d->context; - buf->while_locked = d->flags & _DRM_DMA_WHILE_LOCKED; - address = (unsigned long)buf->address; - length = buf->used; - if (!length) { - DRM_ERROR("0 length buffer\n"); - } - if (buf->pending) { - DRM_ERROR("Sending pending buffer:" - " buffer %d, offset %d\n", - d->send_indices[i], i); - retcode = -EINVAL; - goto cleanup; - } - if (buf->waiting) { - DRM_ERROR("Sending waiting buffer:" - " buffer %d, offset %d\n", - d->send_indices[i], i); - retcode = -EINVAL; - goto cleanup; + if (j & 1) + OUT_RING( 0 ); + + ADVANCE_LP_RING(); +} + +static void i810EmitTexVerified( drm_device_t *dev, + volatile unsigned int *code ) +{ + drm_i810_private_t *dev_priv = dev->dev_private; + int i, j = 0; + unsigned int tmp; + RING_LOCALS; + + BEGIN_LP_RING( I810_TEX_SETUP_SIZE ); + + OUT_RING( GFX_OP_MAP_INFO ); + OUT_RING( code[I810_TEXREG_MI1] ); + OUT_RING( code[I810_TEXREG_MI2] ); + OUT_RING( code[I810_TEXREG_MI3] ); + + for ( i = 4 ; i < I810_TEX_SETUP_SIZE ; i++ ) { + tmp = code[i]; + + if ((tmp & (7<<29)) == (3<<29) && + (tmp & (0x1f<<24)) < (0x1d<<24)) + { + OUT_RING( tmp ); + j++; } - buf->pending = 1; + } - if (dev->last_context != buf->context - && !(dev->queuelist[buf->context]->flags - & _DRM_CONTEXT_PRESERVED)) { - add_wait_queue(&dev->context_wait, &entry); - current->state = TASK_INTERRUPTIBLE; - /* PRE: dev->last_context != buf->context */ - drm_context_switch(dev, dev->last_context, - buf->context); - /* POST: we will wait for the context - switch and will dispatch on a later call - when dev->last_context == buf->context. - NOTE WE HOLD THE LOCK THROUGHOUT THIS - TIME! */ - schedule(); - current->state = TASK_RUNNING; - remove_wait_queue(&dev->context_wait, &entry); - if (signal_pending(current)) { - retcode = -EINTR; - goto cleanup; - } - if (dev->last_context != buf->context) { - DRM_ERROR("Context mismatch: %d %d\n", - dev->last_context, - buf->context); - } - } + if (j & 1) + OUT_RING( 0 ); -#if DRM_DMA_HISTOGRAM - buf->time_queued = get_cycles(); - buf->time_dispatched = buf->time_queued; -#endif - i810_dma_dispatch(dev, address, length); - if (drm_lock_free(dev, &dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - DRM_ERROR("\n"); - } + ADVANCE_LP_RING(); +} - atomic_add(length, &dma->total_bytes); - atomic_inc(&dma->total_dmas); - - if (last_buf) { - drm_free_buffer(dev, last_buf); - } - last_buf = buf; + +/* Need to do some additional checking when setting the dest buffer. + */ +static void i810EmitDestVerified( drm_device_t *dev, + volatile unsigned int *code ) +{ + drm_i810_private_t *dev_priv = dev->dev_private; + unsigned int tmp; + RING_LOCALS; + + BEGIN_LP_RING( I810_DEST_SETUP_SIZE + 2 ); + + tmp = code[I810_DESTREG_DI1]; + if (tmp == dev_priv->front_di1 || tmp == dev_priv->back_di1) { + OUT_RING( CMD_OP_DESTBUFFER_INFO ); + OUT_RING( tmp ); + } else + DRM_DEBUG("bad di1 %x (allow %x or %x)\n", + tmp, dev_priv->front_di1, dev_priv->back_di1); + + /* invarient: + */ + OUT_RING( CMD_OP_Z_BUFFER_INFO ); + OUT_RING( dev_priv->zi1 ); + + OUT_RING( GFX_OP_DESTBUFFER_VARS ); + OUT_RING( code[I810_DESTREG_DV1] ); + + OUT_RING( GFX_OP_DRAWRECT_INFO ); + OUT_RING( code[I810_DESTREG_DR1] ); + OUT_RING( code[I810_DESTREG_DR2] ); + OUT_RING( code[I810_DESTREG_DR3] ); + OUT_RING( code[I810_DESTREG_DR4] ); + OUT_RING( 0 ); + + ADVANCE_LP_RING(); +} + + + +static void i810EmitState( drm_device_t *dev ) +{ + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int dirty = sarea_priv->dirty; + + if (dirty & I810_UPLOAD_BUFFERS) { + i810EmitDestVerified( dev, sarea_priv->BufferState ); + sarea_priv->dirty &= ~I810_UPLOAD_BUFFERS; } + if (dirty & I810_UPLOAD_CTX) { + i810EmitContextVerified( dev, sarea_priv->ContextState ); + sarea_priv->dirty &= ~I810_UPLOAD_CTX; + } -cleanup: - if (last_buf) { - i810_dma_ready(dev); - drm_free_buffer(dev, last_buf); + if (dirty & I810_UPLOAD_TEX0) { + i810EmitTexVerified( dev, sarea_priv->TexState[0] ); + sarea_priv->dirty &= ~I810_UPLOAD_TEX0; } - - if (must_free && !dev->context_flag) { - if (drm_lock_free(dev, &dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - DRM_ERROR("\n"); - } + + if (dirty & I810_UPLOAD_TEX1) { + i810EmitTexVerified( dev, sarea_priv->TexState[1] ); + sarea_priv->dirty &= ~I810_UPLOAD_TEX1; } - clear_bit(0, &dev->interrupt_flag); - return retcode; } -static int i810_dma_send_buffers(drm_device_t *dev, drm_dma_t *d) + + +/* need to verify + */ +static void i810_dma_dispatch_clear( drm_device_t *dev, int flags, + unsigned int clear_color, + unsigned int clear_zval ) { - DECLARE_WAITQUEUE(entry, current); - drm_buf_t *last_buf = NULL; - int retcode = 0; - drm_device_dma_t *dma = dev->dma; + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; + int nbox = sarea_priv->nbox; + drm_clip_rect_t *pbox = sarea_priv->boxes; + int pitch = dev_priv->pitch; + int cpp = 2; + int i; + RING_LOCALS; + + i810_kernel_lost_context(dev); + + if (nbox > I810_NR_SAREA_CLIPRECTS) + nbox = I810_NR_SAREA_CLIPRECTS; + + for (i = 0 ; i < nbox ; i++, pbox++) { + unsigned int x = pbox->x1; + unsigned int y = pbox->y1; + unsigned int width = (pbox->x2 - x) * cpp; + unsigned int height = pbox->y2 - y; + unsigned int start = y * pitch + x * cpp; + + if (pbox->x1 > pbox->x2 || + pbox->y1 > pbox->y2 || + pbox->x2 > dev_priv->w || + pbox->y2 > dev_priv->h) + continue; - if (d->flags & _DRM_DMA_BLOCK) { - last_buf = dma->buflist[d->send_indices[d->send_count-1]]; - add_wait_queue(&last_buf->dma_wait, &entry); - } - - if ((retcode = drm_dma_enqueue(dev, d))) { - if (d->flags & _DRM_DMA_BLOCK) - remove_wait_queue(&last_buf->dma_wait, &entry); - return retcode; - } - - i810_dma_schedule(dev, 0); - - if (d->flags & _DRM_DMA_BLOCK) { - DRM_DEBUG("%d waiting\n", current->pid); - current->state = TASK_INTERRUPTIBLE; - for (;;) { - if (!last_buf->waiting - && !last_buf->pending) - break; /* finished */ - schedule(); - if (signal_pending(current)) { - retcode = -EINTR; /* Can't restart */ - break; - } + if ( flags & I810_FRONT ) { + DRM_DEBUG("clear front\n"); + BEGIN_LP_RING( 6 ); + OUT_RING( BR00_BITBLT_CLIENT | + BR00_OP_COLOR_BLT | 0x3 ); + OUT_RING( BR13_SOLID_PATTERN | (0xF0 << 16) | pitch ); + OUT_RING( (height << 16) | width ); + OUT_RING( start ); + OUT_RING( clear_color ); + OUT_RING( 0 ); + ADVANCE_LP_RING(); } - current->state = TASK_RUNNING; - DRM_DEBUG("%d running\n", current->pid); - remove_wait_queue(&last_buf->dma_wait, &entry); - if (!retcode - || (last_buf->list==DRM_LIST_PEND && !last_buf->pending)) { - if (!waitqueue_active(&last_buf->dma_wait)) { - drm_free_buffer(dev, last_buf); - } + + if ( flags & I810_BACK ) { + DRM_DEBUG("clear back\n"); + BEGIN_LP_RING( 6 ); + OUT_RING( BR00_BITBLT_CLIENT | + BR00_OP_COLOR_BLT | 0x3 ); + OUT_RING( BR13_SOLID_PATTERN | (0xF0 << 16) | pitch ); + OUT_RING( (height << 16) | width ); + OUT_RING( dev_priv->back_offset + start ); + OUT_RING( clear_color ); + OUT_RING( 0 ); + ADVANCE_LP_RING(); } - if (retcode) { - DRM_ERROR("ctx%d w%d p%d c%d i%d l%d %d/%d\n", - d->context, - last_buf->waiting, - last_buf->pending, - DRM_WAITCOUNT(dev, d->context), - last_buf->idx, - last_buf->list, - last_buf->pid, - current->pid); + + if ( flags & I810_DEPTH ) { + DRM_DEBUG("clear depth\n"); + BEGIN_LP_RING( 6 ); + OUT_RING( BR00_BITBLT_CLIENT | + BR00_OP_COLOR_BLT | 0x3 ); + OUT_RING( BR13_SOLID_PATTERN | (0xF0 << 16) | pitch ); + OUT_RING( (height << 16) | width ); + OUT_RING( dev_priv->depth_offset + start ); + OUT_RING( clear_zval ); + OUT_RING( 0 ); + ADVANCE_LP_RING(); } } - return retcode; } -int i810_dma(struct inode *inode, struct file *filp, unsigned int cmd, - unsigned long arg) +static void i810_dma_dispatch_swap( drm_device_t *dev ) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_device_dma_t *dma = dev->dma; - int retcode = 0; - drm_dma_t d; + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; + int nbox = sarea_priv->nbox; + drm_clip_rect_t *pbox = sarea_priv->boxes; + int pitch = dev_priv->pitch; + int cpp = 2; + int ofs = dev_priv->back_offset; + int i; + RING_LOCALS; + + DRM_DEBUG("swapbuffers\n"); + + i810_kernel_lost_context(dev); + + if (nbox > I810_NR_SAREA_CLIPRECTS) + nbox = I810_NR_SAREA_CLIPRECTS; + + for (i = 0 ; i < nbox; i++, pbox++) + { + unsigned int w = pbox->x2 - pbox->x1; + unsigned int h = pbox->y2 - pbox->y1; + unsigned int dst = pbox->x1*cpp + pbox->y1*pitch; + unsigned int start = ofs + dst; + + if (pbox->x1 > pbox->x2 || + pbox->y1 > pbox->y2 || + pbox->x2 > dev_priv->w || + pbox->y2 > dev_priv->h) + continue; + + DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n", + pbox[i].x1, pbox[i].y1, + pbox[i].x2, pbox[i].y2); + + BEGIN_LP_RING( 6 ); + OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_SRC_COPY_BLT | 0x4 ); + OUT_RING( pitch | (0xCC << 16)); + OUT_RING( (h << 16) | (w * cpp)); + OUT_RING( dst ); + OUT_RING( pitch ); + OUT_RING( start ); + ADVANCE_LP_RING(); + } +} - printk("i810_dma start\n"); - copy_from_user_ret(&d, (drm_dma_t *)arg, sizeof(d), -EFAULT); - DRM_DEBUG("%d %d: %d send, %d req\n", - current->pid, d.context, d.send_count, d.request_count); - if (d.context == DRM_KERNEL_CONTEXT || d.context >= dev->queue_slots) { - DRM_ERROR("Process %d using context %d\n", - current->pid, d.context); - return -EINVAL; +static void i810_dma_dispatch_vertex(drm_device_t *dev, + drm_buf_t *buf, + int discard, + int used) +{ + drm_i810_private_t *dev_priv = dev->dev_private; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_clip_rect_t *box = sarea_priv->boxes; + int nbox = sarea_priv->nbox; + unsigned long address = (unsigned long)buf->bus_address; + unsigned long start = address - dev->agp->base; + int i = 0, u; + RING_LOCALS; + + i810_kernel_lost_context(dev); + + if (nbox > I810_NR_SAREA_CLIPRECTS) + nbox = I810_NR_SAREA_CLIPRECTS; + + if (discard) { + u = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, + I810_BUF_HARDWARE); + if(u != I810_BUF_CLIENT) { + DRM_DEBUG("xxxx 2\n"); + } } - if (d.send_count < 0 || d.send_count > dma->buf_count) { - DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n", - current->pid, d.send_count, dma->buf_count); - return -EINVAL; + if (used > 4*1024) + used = 0; + + if (sarea_priv->dirty) + i810EmitState( dev ); + + DRM_DEBUG("dispatch vertex addr 0x%lx, used 0x%x nbox %d\n", + address, used, nbox); + + dev_priv->counter++; + DRM_DEBUG( "dispatch counter : %ld\n", dev_priv->counter); + DRM_DEBUG( "i810_dma_dispatch\n"); + DRM_DEBUG( "start : %lx\n", start); + DRM_DEBUG( "used : %d\n", used); + DRM_DEBUG( "start + used - 4 : %ld\n", start + used - 4); + + if (buf_priv->currently_mapped == I810_BUF_MAPPED) { + *(u32 *)buf_priv->virtual = (GFX_OP_PRIMITIVE | + sarea_priv->vertex_prim | + ((used/4)-2)); + + if (used & 4) { + *(u32 *)((u32)buf_priv->virtual + used) = 0; + used += 4; + } + + i810_unmap_buffer(buf); } - if (d.request_count < 0 || d.request_count > dma->buf_count) { - DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", - current->pid, d.request_count, dma->buf_count); - return -EINVAL; + + if (used) { + do { + if (i < nbox) { + BEGIN_LP_RING(4); + OUT_RING( GFX_OP_SCISSOR | SC_UPDATE_SCISSOR | + SC_ENABLE ); + OUT_RING( GFX_OP_SCISSOR_INFO ); + OUT_RING( box[i].x1 | (box[i].y1<<16) ); + OUT_RING( (box[i].x2-1) | ((box[i].y2-1)<<16) ); + ADVANCE_LP_RING(); + } + + BEGIN_LP_RING(4); + OUT_RING( CMD_OP_BATCH_BUFFER ); + OUT_RING( start | BB1_PROTECTED ); + OUT_RING( start + used - 4 ); + OUT_RING( 0 ); + ADVANCE_LP_RING(); + + } while (++i < nbox); } - if (d.send_count) { -#if 0 - if (d.flags & _DRM_DMA_PRIORITY) - retcode = i810_dma_priority(dev, &d); - else - retcode = i810_dma_send_buffers(dev, &d); -#endif - printk("i810_dma priority\n"); - - retcode = i810_dma_priority(dev, &d); + BEGIN_LP_RING(10); + OUT_RING( CMD_STORE_DWORD_IDX ); + OUT_RING( 20 ); + OUT_RING( dev_priv->counter ); + OUT_RING( 0 ); + + if (discard) { + OUT_RING( CMD_STORE_DWORD_IDX ); + OUT_RING( buf_priv->my_use_idx ); + OUT_RING( I810_BUF_FREE ); + OUT_RING( 0 ); } - d.granted_count = 0; + OUT_RING( CMD_REPORT_HEAD ); + OUT_RING( 0 ); + ADVANCE_LP_RING(); +} - if (!retcode && d.request_count) { - retcode = drm_dma_get_buffers(dev, &d); - } - DRM_DEBUG("%d returning, granted = %d\n", - current->pid, d.granted_count); - copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT); +/* Interrupts are only for flushing */ +static void i810_dma_service(int irq, void *device, struct pt_regs *regs) +{ + drm_device_t *dev = (drm_device_t *)device; + u16 temp; + + atomic_inc(&dev->total_irq); + temp = I810_READ16(I810REG_INT_IDENTITY_R); + temp = temp & ~(0x6000); + if(temp != 0) I810_WRITE16(I810REG_INT_IDENTITY_R, + temp); /* Clear all interrupts */ + else + return; + + queue_task(&dev->tq, &tq_immediate); + mark_bh(IMMEDIATE_BH); +} - printk("i810_dma end (granted)\n"); - return retcode; +static void i810_dma_task_queue(void *device) +{ + drm_device_t *dev = (drm_device_t *) device; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + + atomic_set(&dev_priv->flush_done, 1); + wake_up_interruptible(&dev_priv->flush_queue); } int i810_irq_install(drm_device_t *dev, int irq) { int retcode; - + u16 temp; + if (!irq) return -EINVAL; down(&dev->struct_sem); @@ -591,6 +894,7 @@ int i810_irq_install(drm_device_t *dev, int irq) dev->irq = irq; up(&dev->struct_sem); + DRM_DEBUG( "Interrupt Install : %d\n", irq); DRM_DEBUG("%d\n", irq); dev->context_flag = 0; @@ -603,16 +907,25 @@ int i810_irq_install(drm_device_t *dev, int irq) dev->tq.next = NULL; dev->tq.sync = 0; - dev->tq.routine = i810_dma_schedule_tq_wrapper; + dev->tq.routine = i810_dma_task_queue; dev->tq.data = dev; - /* Before installing handler */ - /* TODO */ + temp = I810_READ16(I810REG_HWSTAM); + temp = temp & 0x6000; + I810_WRITE16(I810REG_HWSTAM, temp); + + temp = I810_READ16(I810REG_INT_MASK_R); + temp = temp & 0x6000; + I810_WRITE16(I810REG_INT_MASK_R, temp); /* Unmask interrupts */ + temp = I810_READ16(I810REG_INT_ENABLE_R); + temp = temp & 0x6000; + I810_WRITE16(I810REG_INT_ENABLE_R, temp); /* Disable all interrupts */ + /* Install handler */ if ((retcode = request_irq(dev->irq, i810_dma_service, - 0, + SA_SHIRQ, dev->devname, dev))) { down(&dev->struct_sem); @@ -620,15 +933,21 @@ int i810_irq_install(drm_device_t *dev, int irq) up(&dev->struct_sem); return retcode; } - - /* After installing handler */ - /* TODO */ + temp = I810_READ16(I810REG_INT_ENABLE_R); + temp = temp & 0x6000; + temp = temp | 0x0003; + I810_WRITE16(I810REG_INT_ENABLE_R, + temp); /* Enable bp & user interrupts */ return 0; } int i810_irq_uninstall(drm_device_t *dev) { int irq; + u16 temp; + + +/* return 0; */ down(&dev->struct_sem); irq = dev->irq; @@ -636,16 +955,25 @@ int i810_irq_uninstall(drm_device_t *dev) up(&dev->struct_sem); if (!irq) return -EINVAL; - + + DRM_DEBUG( "Interrupt UnInstall: %d\n", irq); DRM_DEBUG("%d\n", irq); - - /* TODO : Disable interrupts */ + + temp = I810_READ16(I810REG_INT_IDENTITY_R); + temp = temp & ~(0x6000); + if(temp != 0) I810_WRITE16(I810REG_INT_IDENTITY_R, + temp); /* Clear all interrupts */ + + temp = I810_READ16(I810REG_INT_ENABLE_R); + temp = temp & 0x6000; + I810_WRITE16(I810REG_INT_ENABLE_R, + temp); /* Disable all interrupts */ + free_irq(irq, dev); return 0; } - int i810_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { @@ -654,8 +982,7 @@ int i810_control(struct inode *inode, struct file *filp, unsigned int cmd, drm_control_t ctl; int retcode; - printk(KERN_INFO "i810_control\n"); - i810_dma_init(dev); + DRM_DEBUG( "i810_control\n"); copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT); @@ -674,20 +1001,161 @@ int i810_control(struct inode *inode, struct file *filp, unsigned int cmd, return 0; } +static inline void i810_dma_emit_flush(drm_device_t *dev) +{ + drm_i810_private_t *dev_priv = dev->dev_private; + RING_LOCALS; + + i810_kernel_lost_context(dev); + + BEGIN_LP_RING(2); + OUT_RING( CMD_REPORT_HEAD ); + OUT_RING( GFX_OP_USER_INTERRUPT ); + ADVANCE_LP_RING(); + +/* i810_wait_ring( dev, dev_priv->ring.Size - 8 ); */ +/* atomic_set(&dev_priv->flush_done, 1); */ +/* wake_up_interruptible(&dev_priv->flush_queue); */ +} + +static inline void i810_dma_quiescent_emit(drm_device_t *dev) +{ + drm_i810_private_t *dev_priv = dev->dev_private; + RING_LOCALS; + + i810_kernel_lost_context(dev); + + BEGIN_LP_RING(4); + OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE ); + OUT_RING( CMD_REPORT_HEAD ); + OUT_RING( 0 ); + OUT_RING( GFX_OP_USER_INTERRUPT ); + ADVANCE_LP_RING(); + +/* i810_wait_ring( dev, dev_priv->ring.Size - 8 ); */ +/* atomic_set(&dev_priv->flush_done, 1); */ +/* wake_up_interruptible(&dev_priv->flush_queue); */ +} + +static void i810_dma_quiescent(drm_device_t *dev) +{ + DECLARE_WAITQUEUE(entry, current); + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + unsigned long end; + + if(dev_priv == NULL) { + return; + } + atomic_set(&dev_priv->flush_done, 0); + current->state = TASK_INTERRUPTIBLE; + add_wait_queue(&dev_priv->flush_queue, &entry); + end = jiffies + (HZ*3); + + for (;;) { + i810_dma_quiescent_emit(dev); + if (atomic_read(&dev_priv->flush_done) == 1) break; + if((signed)(end - jiffies) <= 0) { + DRM_ERROR("lockup\n"); + break; + } + schedule_timeout(HZ*3); + if (signal_pending(current)) { + break; + } + } + + current->state = TASK_RUNNING; + remove_wait_queue(&dev_priv->flush_queue, &entry); + + return; +} + +static int i810_flush_queue(drm_device_t *dev) +{ + DECLARE_WAITQUEUE(entry, current); + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + drm_device_dma_t *dma = dev->dma; + unsigned long end; + int i, ret = 0; + + if(dev_priv == NULL) { + return 0; + } + atomic_set(&dev_priv->flush_done, 0); + current->state = TASK_INTERRUPTIBLE; + add_wait_queue(&dev_priv->flush_queue, &entry); + end = jiffies + (HZ*3); + for (;;) { + i810_dma_emit_flush(dev); + if (atomic_read(&dev_priv->flush_done) == 1) break; + if((signed)(end - jiffies) <= 0) { + DRM_ERROR("lockup\n"); + break; + } + schedule_timeout(HZ*3); + if (signal_pending(current)) { + ret = -EINTR; /* Can't restart */ + break; + } + } + + current->state = TASK_RUNNING; + remove_wait_queue(&dev_priv->flush_queue, &entry); + + + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + + int used = cmpxchg(buf_priv->in_use, I810_BUF_HARDWARE, + I810_BUF_FREE); + + if (used == I810_BUF_HARDWARE) + DRM_DEBUG("reclaimed from HARDWARE\n"); + if (used == I810_BUF_CLIENT) + DRM_DEBUG("still on client HARDWARE\n"); + } + + return ret; +} + +/* Must be called with the lock held */ +void i810_reclaim_buffers(drm_device_t *dev, pid_t pid) +{ + drm_device_dma_t *dma = dev->dma; + int i; + + if (!dma) return; + if (!dev->dev_private) return; + if (!dma->buflist) return; + + i810_flush_queue(dev); + + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_i810_buf_priv_t *buf_priv = buf->dev_private; + + if (buf->pid == pid && buf_priv) { + int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, + I810_BUF_FREE); + + if (used == I810_BUF_CLIENT) + DRM_DEBUG("reclaimed from client\n"); + if(buf_priv->currently_mapped == I810_BUF_MAPPED) + buf_priv->currently_mapped = I810_BUF_UNMAPPED; + } + } +} + int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; + DECLARE_WAITQUEUE(entry, current); int ret = 0; drm_lock_t lock; - drm_queue_t *q; -#if DRM_DMA_HISTOGRAM - cycles_t start; - - dev->lck_start = start = get_cycles(); -#endif copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); @@ -696,26 +1164,18 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, current->pid, lock.context); return -EINVAL; } + + DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", + lock.context, current->pid, dev->lock.hw_lock->lock, + lock.flags); - if (lock.context < 0 || lock.context >= dev->queue_count) { + if (lock.context < 0) { return -EINVAL; } - q = dev->queuelist[lock.context]; - - ret = drm_flush_block_and_flush(dev, lock.context, lock.flags); + /* Only one queue: + */ if (!ret) { - if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) - != lock.context) { - long j = jiffies - dev->lock.lock_time; - - if (j > 0 && j <= DRM_LOCK_SLICE) { - /* Can't take lock if we just had it and - there is contention. */ - current->state = TASK_INTERRUPTIBLE; - schedule_timeout(j); - } - } add_wait_queue(&dev->lock.lock_queue, &entry); for (;;) { if (!dev->lock.hw_lock) { @@ -728,13 +1188,13 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, dev->lock.pid = current->pid; dev->lock.lock_time = jiffies; atomic_inc(&dev->total_locks); - atomic_inc(&q->total_locks); break; /* Got lock */ } /* Contention */ atomic_inc(&dev->total_sleeps); current->state = TASK_INTERRUPTIBLE; + DRM_DEBUG("Calling lock schedule\n"); schedule(); if (signal_pending(current)) { ret = -ERESTARTSYS; @@ -744,19 +1204,153 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, current->state = TASK_RUNNING; remove_wait_queue(&dev->lock.lock_queue, &entry); } - - drm_flush_unblock(dev, lock.context, lock.flags); /* cleanup phase */ if (!ret) { - if (lock.flags & _DRM_LOCK_READY) - i810_dma_ready(dev); - if (lock.flags & _DRM_LOCK_QUIESCENT) - i810_dma_quiescent(dev); + if (lock.flags & _DRM_LOCK_QUIESCENT) { + DRM_DEBUG("_DRM_LOCK_QUIESCENT\n"); + DRM_DEBUG("fred\n"); + i810_dma_quiescent(dev); + } } + DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); + return ret; +} -#if DRM_DMA_HISTOGRAM - atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); -#endif +int i810_flush_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + + DRM_DEBUG("i810_flush_ioctl\n"); + if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("i810_flush_ioctl called without lock held\n"); + return -EINVAL; + } + + i810_flush_queue(dev); + return 0; +} + + +int i810_dma_vertex(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_device_dma_t *dma = dev->dma; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + u32 *hw_status = (u32 *)dev_priv->hw_status_page; + drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) + dev_priv->sarea_priv; + drm_i810_vertex_t vertex; + + copy_from_user_ret(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex), + -EFAULT); + + if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("i810_dma_vertex called without lock held\n"); + return -EINVAL; + } + + DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n", + vertex.idx, vertex.used, vertex.discard); + + i810_dma_dispatch_vertex( dev, + dma->buflist[ vertex.idx ], + vertex.discard, vertex.used ); + + atomic_add(vertex.used, &dma->total_bytes); + atomic_inc(&dma->total_dmas); + sarea_priv->last_enqueue = dev_priv->counter-1; + sarea_priv->last_dispatch = (int) hw_status[5]; + + return 0; +} + + + +int i810_clear_bufs(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_i810_clear_t clear; + + copy_from_user_ret(&clear, (drm_i810_clear_t *)arg, sizeof(clear), + -EFAULT); + + if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("i810_clear_bufs called without lock held\n"); + return -EINVAL; + } + + i810_dma_dispatch_clear( dev, clear.flags, + clear.clear_color, + clear.clear_depth ); + return 0; +} + +int i810_swap_bufs(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + + DRM_DEBUG("i810_swap_bufs\n"); + + if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("i810_swap_buf called without lock held\n"); + return -EINVAL; + } + + i810_dma_dispatch_swap( dev ); + return 0; +} + +int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + u32 *hw_status = (u32 *)dev_priv->hw_status_page; + drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) + dev_priv->sarea_priv; + + sarea_priv->last_dispatch = (int) hw_status[5]; + return 0; +} + +int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + int retcode = 0; + drm_i810_dma_t d; + drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; + u32 *hw_status = (u32 *)dev_priv->hw_status_page; + drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) + dev_priv->sarea_priv; + + DRM_DEBUG("getbuf\n"); + copy_from_user_ret(&d, (drm_i810_dma_t *)arg, sizeof(d), -EFAULT); + + if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("i810_dma called without lock held\n"); + return -EINVAL; + } - return ret; + d.granted = 0; + + retcode = i810_dma_get_buffer(dev, &d, filp); + + DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", + current->pid, retcode, d.granted); + + copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT); + sarea_priv->last_dispatch = (int) hw_status[5]; + + return retcode; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c index f33153a36..b523db902 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c @@ -2,6 +2,7 @@ * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,25 +24,25 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Jeff Hartmann <jhartmann@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c,v 1.1 2000/02/11 17:26:05 dawes Exp $ + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> * */ #define EXPORT_SYMTAB #include "drmP.h" #include "i810_drv.h" + + EXPORT_SYMBOL(i810_init); EXPORT_SYMBOL(i810_cleanup); #define I810_NAME "i810" -#define I810_DESC "Matrox g200/g400" +#define I810_DESC "Intel I810" #define I810_DATE "19991213" -#define I810_MAJOR 0 +#define I810_MAJOR 1 #define I810_MINOR 0 -#define I810_PATCHLEVEL 1 +#define I810_PATCHLEVEL 0 static drm_device_t i810_device; drm_ctx_t i810_res_ctx; @@ -54,6 +55,7 @@ static struct file_operations i810_fops = { mmap: drm_mmap, read: drm_read, fasync: drm_fasync, + poll: drm_poll, }; static struct miscdevice i810_misc = { @@ -77,21 +79,18 @@ static drm_ioctl_desc_t i810_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { i810_addbufs, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { i810_markbufs, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { i810_infobufs, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { i810_mapbufs, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { i810_freebufs, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { drm_addctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { drm_rmctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { drm_modctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { drm_getctx, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { drm_switchctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { drm_newctx, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { drm_resctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { i810_addctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { i810_rmctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { i810_modctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { i810_getctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { i810_switchctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { i810_newctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { i810_resctx, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { i810_dma, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { i810_lock, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { i810_unlock, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 }, @@ -104,6 +103,14 @@ static drm_ioctl_desc_t i810_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_I810_INIT)] = { i810_dma_init, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_I810_VERTEX)] = { i810_dma_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_I810_CLEAR)] = { i810_clear_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_I810_FLUSH)] = { i810_flush_ioctl,1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_I810_GETAGE)] = { i810_getage, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_I810_GETBUF)] = { i810_getbuf, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_I810_SWAP)] = { i810_swap_bufs, 1, 0 }, }; #define I810_IOCTL_COUNT DRM_ARRAY_SIZE(i810_ioctls) @@ -121,7 +128,7 @@ MODULE_PARM(i810, "s"); int init_module(void) { - printk("doing i810_init()\n"); + DRM_DEBUG("doing i810_init()\n"); return i810_init(); } @@ -364,7 +371,7 @@ int i810_init(void) #ifdef MODULE drm_parse_options(i810); #endif - printk("doing misc_register\n"); + DRM_DEBUG("doing misc_register\n"); if ((retcode = misc_register(&i810_misc))) { DRM_ERROR("Cannot register \"%s\"\n", I810_NAME); return retcode; @@ -372,13 +379,22 @@ int i810_init(void) dev->device = MKDEV(MISC_MAJOR, i810_misc.minor); dev->name = I810_NAME; - printk("doing mem init\n"); + DRM_DEBUG("doing mem init\n"); drm_mem_init(); - printk("doing proc init\n"); + DRM_DEBUG("doing proc init\n"); drm_proc_init(dev); - printk("doing agp init\n"); + DRM_DEBUG("doing agp init\n"); dev->agp = drm_agp_init(); - printk("doing ctxbitmap init\n"); + if(dev->agp == NULL) { + DRM_INFO("The i810 drm module requires the agpgart module" + " to function correctly\nPlease load the agpgart" + " module before you load the i810 module\n"); + drm_proc_cleanup(); + misc_deregister(&i810_misc); + i810_takedown(dev); + return -ENOMEM; + } + DRM_DEBUG("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); drm_proc_cleanup(); @@ -386,10 +402,6 @@ int i810_init(void) i810_takedown(dev); return retcode; } -#if 0 - printk("doing i810_dma_init\n"); - i810_dma_init(dev); -#endif DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", I810_NAME, @@ -417,7 +429,6 @@ void i810_cleanup(void) DRM_INFO("Module unloaded\n"); } drm_ctxbitmap_cleanup(dev); - i810_dma_cleanup(dev); i810_takedown(dev); if (dev->agp) { drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); @@ -484,24 +495,82 @@ int i810_release(struct inode *inode, struct file *filp) drm_device_t *dev = priv->dev; int retcode = 0; - DRM_DEBUG("open_count = %d\n", dev->open_count); - if (!(retcode = drm_release(inode, filp))) { - MOD_DEC_USE_COUNT; - atomic_inc(&dev->total_close); - spin_lock(&dev->count_lock); - if (!--dev->open_count) { - if (atomic_read(&dev->ioctl_count) || dev->blocked) { - DRM_ERROR("Device busy: %d %d\n", - atomic_read(&dev->ioctl_count), - dev->blocked); - spin_unlock(&dev->count_lock); - return -EBUSY; + DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n", + current->pid, dev->device, dev->open_count); + + if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) + && dev->lock.pid == current->pid) { + i810_reclaim_buffers(dev, priv->pid); + DRM_ERROR("Process %d dead, freeing lock for context %d\n", + current->pid, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + drm_lock_free(dev, + &dev->lock.hw_lock->lock, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + + /* FIXME: may require heavy-handed reset of + hardware at this point, possibly + processed via a callback to the X + server. */ + } else if (dev->lock.hw_lock) { + /* The lock is required to reclaim buffers */ + DECLARE_WAITQUEUE(entry, current); + add_wait_queue(&dev->lock.lock_queue, &entry); + for (;;) { + if (!dev->lock.hw_lock) { + /* Device has been unregistered */ + retcode = -EINTR; + break; + } + if (drm_lock_take(&dev->lock.hw_lock->lock, + DRM_KERNEL_CONTEXT)) { + dev->lock.pid = priv->pid; + dev->lock.lock_time = jiffies; + atomic_inc(&dev->total_locks); + break; /* Got lock */ + } + /* Contention */ + atomic_inc(&dev->total_sleeps); + current->state = TASK_INTERRUPTIBLE; + schedule(); + if (signal_pending(current)) { + retcode = -ERESTARTSYS; + break; } - spin_unlock(&dev->count_lock); - return i810_takedown(dev); } - spin_unlock(&dev->count_lock); + current->state = TASK_RUNNING; + remove_wait_queue(&dev->lock.lock_queue, &entry); + if(!retcode) { + i810_reclaim_buffers(dev, priv->pid); + drm_lock_free(dev, &dev->lock.hw_lock->lock, + DRM_KERNEL_CONTEXT); + } + } + drm_fasync(-1, filp, 0); + + down(&dev->struct_sem); + if (priv->prev) priv->prev->next = priv->next; + else dev->file_first = priv->next; + if (priv->next) priv->next->prev = priv->prev; + else dev->file_last = priv->prev; + up(&dev->struct_sem); + + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); + MOD_DEC_USE_COUNT; + atomic_inc(&dev->total_close); + spin_lock(&dev->count_lock); + if (!--dev->open_count) { + if (atomic_read(&dev->ioctl_count) || dev->blocked) { + DRM_ERROR("Device busy: %d %d\n", + atomic_read(&dev->ioctl_count), + dev->blocked); + spin_unlock(&dev->count_lock); + return -EBUSY; + } + spin_unlock(&dev->count_lock); + return i810_takedown(dev); } + spin_unlock(&dev->count_lock); return retcode; } @@ -566,8 +635,7 @@ int i810_unlock(struct inode *inode, struct file *filp, unsigned int cmd, atomic_inc(&dev->total_unlocks); if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) atomic_inc(&dev->total_contends); - drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); - i810_dma_schedule(dev, 1); + drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); if (!dev->context_flag) { if (drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h index 0f5f42bb6..c387bf727 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h @@ -2,6 +2,7 @@ * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,15 +24,58 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Jeff Hartmann <jhartmann@precisioninsight.com> + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h,v 1.1 2000/02/11 17:26:05 dawes Exp $ */ #ifndef _I810_DRV_H_ #define _I810_DRV_H_ +typedef struct drm_i810_buf_priv { + u32 *in_use; + int my_use_idx; + int currently_mapped; + void *virtual; + void *kernel_virtual; + int map_count; + struct vm_area_struct *vma; +} drm_i810_buf_priv_t; + +typedef struct _drm_i810_ring_buffer{ + int tail_mask; + unsigned long Start; + unsigned long End; + unsigned long Size; + u8 *virtual_start; + int head; + int tail; + int space; +} drm_i810_ring_buffer_t; + +typedef struct drm_i810_private { + int ring_map_idx; + int buffer_map_idx; + + drm_i810_ring_buffer_t ring; + drm_i810_sarea_t *sarea_priv; + + unsigned long hw_status_page; + unsigned long counter; + + atomic_t flush_done; + wait_queue_head_t flush_queue; /* Processes waiting until flush */ + drm_buf_t *mmap_buffer; + + + u32 front_di1, back_di1, zi1; + + int back_offset; + int depth_offset; + int w, h; + int pitch; +} drm_i810_private_t; + /* i810_drv.c */ extern int i810_init(void); extern void i810_cleanup(void); @@ -46,16 +90,22 @@ extern int i810_unlock(struct inode *inode, struct file *filp, /* i810_dma.c */ extern int i810_dma_schedule(drm_device_t *dev, int locked); -extern int i810_dma(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); +extern int i810_getbuf(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); extern int i810_irq_install(drm_device_t *dev, int irq); extern int i810_irq_uninstall(drm_device_t *dev); extern int i810_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern void i810_dma_init(drm_device_t *dev); -extern void i810_dma_cleanup(drm_device_t *dev); +extern int i810_dma_init(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int i810_flush_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern void i810_reclaim_buffers(drm_device_t *dev, pid_t pid); +extern int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg); +extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma); /* i810_bufs.c */ @@ -67,10 +117,108 @@ extern int i810_markbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int i810_freebufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -extern int i810_mapbufs(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg); extern int i810_addmap(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); + /* i810_context.c */ +extern int i810_resctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int i810_addctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int i810_modctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int i810_getctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int i810_switchctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int i810_newctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int i810_rmctx(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); + +extern int i810_context_switch(drm_device_t *dev, int old, int new); +extern int i810_context_switch_complete(drm_device_t *dev, int new); + +#define I810_VERBOSE 0 + + +int i810_dma_vertex(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); + +int i810_swap_bufs(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); + +int i810_clear_bufs(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); + +#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23)) +#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23)) +#define CMD_REPORT_HEAD (7<<23) +#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1) +#define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1) + +#define INST_PARSER_CLIENT 0x00000000 +#define INST_OP_FLUSH 0x02000000 +#define INST_FLUSH_MAP_CACHE 0x00000001 + + +#define BB1_START_ADDR_MASK (~0x7) +#define BB1_PROTECTED (1<<0) +#define BB1_UNPROTECTED (0<<0) +#define BB2_END_ADDR_MASK (~0x7) + +#define I810REG_HWSTAM 0x02098 +#define I810REG_INT_IDENTITY_R 0x020a4 +#define I810REG_INT_MASK_R 0x020a8 +#define I810REG_INT_ENABLE_R 0x020a0 + +#define LP_RING 0x2030 +#define HP_RING 0x2040 +#define RING_TAIL 0x00 +#define TAIL_ADDR 0x000FFFF8 +#define RING_HEAD 0x04 +#define HEAD_WRAP_COUNT 0xFFE00000 +#define HEAD_WRAP_ONE 0x00200000 +#define HEAD_ADDR 0x001FFFFC +#define RING_START 0x08 +#define START_ADDR 0x00FFFFF8 +#define RING_LEN 0x0C +#define RING_NR_PAGES 0x000FF000 +#define RING_REPORT_MASK 0x00000006 +#define RING_REPORT_64K 0x00000002 +#define RING_REPORT_128K 0x00000004 +#define RING_NO_REPORT 0x00000000 +#define RING_VALID_MASK 0x00000001 +#define RING_VALID 0x00000001 +#define RING_INVALID 0x00000000 + +#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19)) +#define SC_UPDATE_SCISSOR (0x1<<1) +#define SC_ENABLE_MASK (0x1<<0) +#define SC_ENABLE (0x1<<0) + +#define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1)) +#define SCI_YMIN_MASK (0xffff<<16) +#define SCI_XMIN_MASK (0xffff<<0) +#define SCI_YMAX_MASK (0xffff<<16) +#define SCI_XMAX_MASK (0xffff<<0) + +#define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0) +#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16)) +#define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x2) +#define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0) +#define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3)) +#define GFX_OP_PRIMITIVE ((0x3<<29)|(0x1f<<24)) + +#define CMD_OP_Z_BUFFER_INFO ((0x0<<29)|(0x16<<23)) +#define CMD_OP_DESTBUFFER_INFO ((0x0<<29)|(0x15<<23)) + +#define BR00_BITBLT_CLIENT 0x40000000 +#define BR00_OP_COLOR_BLT 0x10000000 +#define BR00_OP_SRC_COPY_BLT 0x10C00000 +#define BR13_SOLID_PATTERN 0x80000000 + + #endif + diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c index 25c0aed22..aefc884eb 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c @@ -1,8 +1,8 @@ /* init.c -- Setup/Cleanup for DRM -*- linux-c -*- * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com - * Revised: Fri Aug 20 09:27:02 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c,v 1.2 2000/02/23 04:47:29 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -34,7 +35,7 @@ int drm_flags = 0; /* drm_parse_option parses a single option. See description for - drm_parse_drm for details. */ + drm_parse_options for details. */ static void drm_parse_option(char *s) { @@ -96,3 +97,10 @@ void drm_parse_options(char *s) } } +int drm_cpu_valid(void) +{ +#if defined(__i386__) + if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */ +#endif + return 1; +} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c index 8edfb4374..b246f76e5 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c @@ -1,8 +1,8 @@ /* ioctl.c -- IOCTL processing for DRM -*- linux-c -*- * Created: Fri Jan 8 09:01:26 1999 by faith@precisioninsight.com - * Revised: Fri Aug 20 09:27:02 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c,v 1.2 2000/02/23 04:47:29 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c index af8f6150a..f62495aa2 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c @@ -1,8 +1,8 @@ /* lists.c -- Buffer list handling routines -*- linux-c -*- * Created: Mon Apr 19 20:54:22 1999 by faith@precisioninsight.com - * Revised: Sun Feb 13 23:37:52 2000 by kevin@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c,v 1.6 2000/02/23 04:56:42 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c index adf27ab5d..550827278 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c @@ -1,8 +1,8 @@ /* lock.c -- IOCTLs for locking -*- linux-c -*- * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com - * Revised: Sun Feb 13 23:38:25 2000 by kevin@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c,v 1.5 2000/02/23 04:47:29 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c index a8a81abd8..0e92401bb 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c @@ -1,8 +1,8 @@ /* memory.c -- Memory management wrappers for DRM -*- linux-c -*- * Created: Thu Feb 4 14:00:34 1999 by faith@precisioninsight.com - * Revised: Sun Feb 13 23:39:37 2000 by kevin@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c,v 1.5 2000/02/23 04:47:30 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -44,21 +45,25 @@ static spinlock_t drm_mem_lock = SPIN_LOCK_UNLOCKED; static unsigned long drm_ram_available = 0; /* In pages */ static unsigned long drm_ram_used = 0; static drm_mem_stats_t drm_mem_stats[] = { - [DRM_MEM_DMA] = { "dmabufs" }, - [DRM_MEM_SAREA] = { "sareas" }, - [DRM_MEM_DRIVER] = { "driver" }, - [DRM_MEM_MAGIC] = { "magic" }, - [DRM_MEM_IOCTLS] = { "ioctltab" }, - [DRM_MEM_MAPS] = { "maplist" }, - [DRM_MEM_VMAS] = { "vmalist" }, - [DRM_MEM_BUFS] = { "buflist" }, - [DRM_MEM_SEGS] = { "seglist" }, - [DRM_MEM_PAGES] = { "pagelist" }, - [DRM_MEM_FILES] = { "files" }, - [DRM_MEM_QUEUES] = { "queues" }, - [DRM_MEM_CMDS] = { "commands" }, - [DRM_MEM_MAPPINGS] = { "mappings" }, - [DRM_MEM_BUFLISTS] = { "buflists" }, + [DRM_MEM_DMA] = { "dmabufs" }, + [DRM_MEM_SAREA] = { "sareas" }, + [DRM_MEM_DRIVER] = { "driver" }, + [DRM_MEM_MAGIC] = { "magic" }, + [DRM_MEM_IOCTLS] = { "ioctltab" }, + [DRM_MEM_MAPS] = { "maplist" }, + [DRM_MEM_VMAS] = { "vmalist" }, + [DRM_MEM_BUFS] = { "buflist" }, + [DRM_MEM_SEGS] = { "seglist" }, + [DRM_MEM_PAGES] = { "pagelist" }, + [DRM_MEM_FILES] = { "files" }, + [DRM_MEM_QUEUES] = { "queues" }, + [DRM_MEM_CMDS] = { "commands" }, + [DRM_MEM_MAPPINGS] = { "mappings" }, + [DRM_MEM_BUFLISTS] = { "buflists" }, + [DRM_MEM_AGPLISTS] = { "agplist" }, + [DRM_MEM_TOTALAGP] = { "totalagp" }, + [DRM_MEM_BOUNDAGP] = { "boundagp" }, + [DRM_MEM_CTXBITMAP] = { "ctxbitmap"}, { NULL, 0, } /* Last entry must be null */ }; @@ -324,3 +329,120 @@ void drm_ioremapfree(void *pt, unsigned long size) free_count, alloc_count); } } + +#ifdef DRM_AGP +agp_memory *drm_alloc_agp(int pages, u32 type) +{ + agp_memory *handle; + + if (!pages) { + DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n"); + return NULL; + } + + if (drm_agp.allocate_memory) { + if ((handle = (*drm_agp.allocate_memory)(pages, + type))) { + spin_lock(&drm_mem_lock); + ++drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count; + drm_mem_stats[DRM_MEM_TOTALAGP].bytes_allocated + += pages << PAGE_SHIFT; + spin_unlock(&drm_mem_lock); + return handle; + } + } + spin_lock(&drm_mem_lock); + ++drm_mem_stats[DRM_MEM_TOTALAGP].fail_count; + spin_unlock(&drm_mem_lock); + return NULL; +} + +int drm_free_agp(agp_memory *handle, int pages) +{ + int alloc_count; + int free_count; + int retval = -EINVAL; + + if (!handle) { + DRM_MEM_ERROR(DRM_MEM_TOTALAGP, + "Attempt to free NULL AGP handle\n"); + return retval;; + } + + if (drm_agp.free_memory) { + (*drm_agp.free_memory)(handle); + spin_lock(&drm_mem_lock); + free_count = ++drm_mem_stats[DRM_MEM_TOTALAGP].free_count; + alloc_count = drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count; + drm_mem_stats[DRM_MEM_TOTALAGP].bytes_freed + += pages << PAGE_SHIFT; + spin_unlock(&drm_mem_lock); + if (free_count > alloc_count) { + DRM_MEM_ERROR(DRM_MEM_TOTALAGP, + "Excess frees: %d frees, %d allocs\n", + free_count, alloc_count); + } + return 0; + } + return retval; +} + +int drm_bind_agp(agp_memory *handle, unsigned int start) +{ + int retcode = -EINVAL; + + DRM_DEBUG("drm_bind_agp called\n"); + if (!handle) { + DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, + "Attempt to bind NULL AGP handle\n"); + return retcode; + } + + DRM_DEBUG("drm_agp.bind_memory : %p\n", drm_agp.bind_memory); + if (drm_agp.bind_memory) { + if (!(retcode = (*drm_agp.bind_memory)(handle, start))) { + spin_lock(&drm_mem_lock); + ++drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count; + drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_allocated + += handle->page_count << PAGE_SHIFT; + spin_unlock(&drm_mem_lock); + DRM_DEBUG("drm_agp.bind_memory: retcode %d\n", retcode); + return retcode; + } + } + spin_lock(&drm_mem_lock); + ++drm_mem_stats[DRM_MEM_BOUNDAGP].fail_count; + spin_unlock(&drm_mem_lock); + return retcode; +} + +int drm_unbind_agp(agp_memory *handle) +{ + int alloc_count; + int free_count; + int retcode = -EINVAL; + + if (!handle) { + DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, + "Attempt to unbind NULL AGP handle\n"); + return retcode; + } + + if (drm_agp.unbind_memory) { + int c = handle->page_count; + if ((retcode = (*drm_agp.unbind_memory)(handle))) + return retcode; + spin_lock(&drm_mem_lock); + free_count = ++drm_mem_stats[DRM_MEM_BOUNDAGP].free_count; + alloc_count = drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count; + drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_freed += c << PAGE_SHIFT; + spin_unlock(&drm_mem_lock); + if (free_count > alloc_count) { + DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, + "Excess frees: %d frees, %d allocs\n", + free_count, alloc_count); + } + } + return retcode; +} +#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c index 34f1112a6..b97eb4959 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c @@ -2,6 +2,7 @@ * Created: Thu Jan 6 01:47:26 2000 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,179 +24,176 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Jeff Hartmann <jhartmann@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c,v 1.1 2000/02/11 17:26:06 dawes Exp $ + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> * */ #define __NO_VERSION__ #include "drmP.h" #include "mga_drv.h" -#include "mga_dma.h" #include "linux/un.h" int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_device_dma_t *dma = dev->dma; - drm_buf_desc_t request; - drm_buf_entry_t *entry; - drm_buf_t *buf; - unsigned long offset; - unsigned long agp_offset; - int count; - int order; - int size; - int alignment; - int page_order; - int total; - int byte_count; - int i; - - if (!dma) return -EINVAL; - - copy_from_user_ret(&request, - (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); - - count = request.count; - order = drm_order(request.size); - size = 1 << order; - agp_offset = request.agp_start; - alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; - page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; - total = PAGE_SIZE << page_order; - byte_count = 0; - - DRM_DEBUG("count: %d\n", count); - DRM_DEBUG("order: %d\n", order); - DRM_DEBUG("size: %d\n", size); - DRM_DEBUG("agp_offset: %d\n", agp_offset); - DRM_DEBUG("alignment: %d\n", alignment); - DRM_DEBUG("page_order: %d\n", page_order); - DRM_DEBUG("total: %d\n", total); - DRM_DEBUG("byte_count: %d\n", byte_count); - - if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; - if (dev->queue_count) return -EBUSY; /* Not while in use */ - spin_lock(&dev->count_lock); - if (dev->buf_use) { - spin_unlock(&dev->count_lock); - return -EBUSY; - } - atomic_inc(&dev->buf_alloc); - spin_unlock(&dev->count_lock); + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_device_dma_t *dma = dev->dma; + drm_buf_desc_t request; + drm_buf_entry_t *entry; + drm_buf_t *buf; + unsigned long offset; + unsigned long agp_offset; + int count; + int order; + int size; + int alignment; + int page_order; + int total; + int byte_count; + int i; + + if (!dma) return -EINVAL; + + copy_from_user_ret(&request, + (drm_buf_desc_t *)arg, + sizeof(request), + -EFAULT); + + count = request.count; + order = drm_order(request.size); + size = 1 << order; + agp_offset = request.agp_start; + alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size; + page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; + total = PAGE_SIZE << page_order; + byte_count = 0; + + DRM_DEBUG("count: %d\n", count); + DRM_DEBUG("order: %d\n", order); + DRM_DEBUG("size: %d\n", size); + DRM_DEBUG("agp_offset: %ld\n", agp_offset); + DRM_DEBUG("alignment: %d\n", alignment); + DRM_DEBUG("page_order: %d\n", page_order); + DRM_DEBUG("total: %d\n", total); + DRM_DEBUG("byte_count: %d\n", byte_count); + + if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL; + if (dev->queue_count) return -EBUSY; /* Not while in use */ + spin_lock(&dev->count_lock); + if (dev->buf_use) { + spin_unlock(&dev->count_lock); + return -EBUSY; + } + atomic_inc(&dev->buf_alloc); + spin_unlock(&dev->count_lock); - down(&dev->struct_sem); - entry = &dma->bufs[order]; - if (entry->buf_count) { - up(&dev->struct_sem); - atomic_dec(&dev->buf_alloc); - return -ENOMEM; /* May only call once for each order */ - } + down(&dev->struct_sem); + entry = &dma->bufs[order]; + if (entry->buf_count) { + up(&dev->struct_sem); + atomic_dec(&dev->buf_alloc); + return -ENOMEM; /* May only call once for each order */ + } - entry->buflist = drm_alloc(count * sizeof(*entry->buflist), - DRM_MEM_BUFS); - if (!entry->buflist) { - up(&dev->struct_sem); - atomic_dec(&dev->buf_alloc); - return -ENOMEM; - } - memset(entry->buflist, 0, count * sizeof(*entry->buflist)); + entry->buflist = drm_alloc(count * sizeof(*entry->buflist), + DRM_MEM_BUFS); + if (!entry->buflist) { + up(&dev->struct_sem); + atomic_dec(&dev->buf_alloc); + return -ENOMEM; + } + memset(entry->buflist, 0, count * sizeof(*entry->buflist)); - entry->buf_size = size; - entry->page_order = page_order; - offset = 0; + entry->buf_size = size; + entry->page_order = page_order; + offset = 0; - while(entry->buf_count < count) { - buf = &entry->buflist[entry->buf_count]; - buf->idx = dma->buf_count + entry->buf_count; - buf->total = alignment; - buf->order = order; - buf->used = 0; - - DRM_DEBUG("offset : %d\n", offset); - - buf->offset = offset; /* Hrm */ - buf->bus_address = dev->agp->base + agp_offset + offset; - buf->address = (void *)(agp_offset + offset + dev->agp->base); - buf->next = NULL; - buf->waiting = 0; - buf->pending = 0; - init_waitqueue_head(&buf->dma_wait); - buf->pid = 0; - - buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS); - buf->dev_priv_size = sizeof(drm_mga_buf_priv_t); + while(entry->buf_count < count) { + buf = &entry->buflist[entry->buf_count]; + buf->idx = dma->buf_count + entry->buf_count; + buf->total = alignment; + buf->order = order; + buf->used = 0; + + DRM_DEBUG("offset : %ld\n", offset); + + buf->offset = offset; /* Hrm */ + buf->bus_address = dev->agp->base + agp_offset + offset; + buf->address = (void *)(agp_offset + offset + dev->agp->base); + buf->next = NULL; + buf->waiting = 0; + buf->pending = 0; + init_waitqueue_head(&buf->dma_wait); + buf->pid = 0; + + buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS); + buf->dev_priv_size = sizeof(drm_mga_buf_priv_t); #if DRM_DMA_HISTOGRAM - buf->time_queued = 0; - buf->time_dispatched = 0; - buf->time_completed = 0; - buf->time_freed = 0; + buf->time_queued = 0; + buf->time_dispatched = 0; + buf->time_completed = 0; + buf->time_freed = 0; #endif - offset = offset + alignment; - entry->buf_count++; - byte_count += PAGE_SIZE << page_order; + offset = offset + alignment; + entry->buf_count++; + byte_count += PAGE_SIZE << page_order; - DRM_DEBUG("buffer %d @ %p\n", - entry->buf_count, buf->address); - } + DRM_DEBUG("buffer %d @ %p\n", + entry->buf_count, buf->address); + } - dma->buflist = drm_realloc(dma->buflist, - dma->buf_count * sizeof(*dma->buflist), - (dma->buf_count + entry->buf_count) - * sizeof(*dma->buflist), - DRM_MEM_BUFS); - for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++) - dma->buflist[i] = &entry->buflist[i - dma->buf_count]; + dma->buflist = drm_realloc(dma->buflist, + dma->buf_count * sizeof(*dma->buflist), + (dma->buf_count + entry->buf_count) + * sizeof(*dma->buflist), + DRM_MEM_BUFS); + for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++) + dma->buflist[i] = &entry->buflist[i - dma->buf_count]; - dma->buf_count += entry->buf_count; + dma->buf_count += entry->buf_count; - DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); + DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count); - dma->byte_count += byte_count; + dma->byte_count += byte_count; - DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); + DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count); - drm_freelist_create(&entry->freelist, entry->buf_count); - for (i = 0; i < entry->buf_count; i++) { - drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]); - } + drm_freelist_create(&entry->freelist, entry->buf_count); + for (i = 0; i < entry->buf_count; i++) { + drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]); + } - up(&dev->struct_sem); + up(&dev->struct_sem); - request.count = entry->buf_count; - request.size = size; + request.count = entry->buf_count; + request.size = size; - copy_to_user_ret((drm_buf_desc_t *)arg, - &request, - sizeof(request), - -EFAULT); + copy_to_user_ret((drm_buf_desc_t *)arg, + &request, + sizeof(request), + -EFAULT); - atomic_dec(&dev->buf_alloc); + atomic_dec(&dev->buf_alloc); - DRM_DEBUG("count: %d\n", count); - DRM_DEBUG("order: %d\n", order); - DRM_DEBUG("size: %d\n", size); - DRM_DEBUG("agp_offset: %d\n", agp_offset); - DRM_DEBUG("alignment: %d\n", alignment); - DRM_DEBUG("page_order: %d\n", page_order); - DRM_DEBUG("total: %d\n", total); - DRM_DEBUG("byte_count: %d\n", byte_count); + DRM_DEBUG("count: %d\n", count); + DRM_DEBUG("order: %d\n", order); + DRM_DEBUG("size: %d\n", size); + DRM_DEBUG("agp_offset: %ld\n", agp_offset); + DRM_DEBUG("alignment: %d\n", alignment); + DRM_DEBUG("page_order: %d\n", page_order); + DRM_DEBUG("total: %d\n", total); + DRM_DEBUG("byte_count: %d\n", byte_count); - dma->flags = _DRM_DMA_USE_AGP; + dma->flags = _DRM_DMA_USE_AGP; - DRM_DEBUG("dma->flags : %lx\n", dma->flags); + DRM_DEBUG("dma->flags : %x\n", dma->flags); - return 0; + return 0; } int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, @@ -362,17 +360,17 @@ int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd, int mga_addbufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { - drm_buf_desc_t request; + drm_buf_desc_t request; - copy_from_user_ret(&request, - (drm_buf_desc_t *)arg, - sizeof(request), - -EFAULT); + copy_from_user_ret(&request, + (drm_buf_desc_t *)arg, + sizeof(request), + -EFAULT); - if(request.flags & _DRM_AGP_BUFFER) - return mga_addbufs_agp(inode, filp, cmd, arg); - else - return mga_addbufs_pci(inode, filp, cmd, arg); + if(request.flags & _DRM_AGP_BUFFER) + return mga_addbufs_agp(inode, filp, cmd, arg); + else + return mga_addbufs_pci(inode, filp, cmd, arg); } int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd, @@ -546,7 +544,7 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, spin_lock(&dev->count_lock); if (atomic_read(&dev->buf_alloc)) { spin_unlock(&dev->count_lock); - DRM_DEBUG("Buzy\n"); + DRM_DEBUG("Busy\n"); return -EBUSY; } ++dev->buf_use; /* Can't allocate more after this call */ @@ -558,79 +556,84 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd, -EFAULT); DRM_DEBUG("mga_mapbufs\n"); - DRM_DEBUG("dma->flags : %lx\n", dma->flags); + DRM_DEBUG("dma->flags : %x\n", dma->flags); - if (request.count >= dma->buf_count) { - if(dma->flags & _DRM_DMA_USE_AGP) { - drm_mga_private_t *dev_priv = dev->dev_private; - drm_map_t *map = NULL; + if (request.count >= dma->buf_count) { + if(dma->flags & _DRM_DMA_USE_AGP) { + drm_mga_private_t *dev_priv = dev->dev_private; + drm_map_t *map = NULL; - map = dev->maplist[dev_priv->buffer_map_idx]; - if (!map) { - DRM_DEBUG("map is null\n"); - retcode = -EINVAL; - goto done; - } - - DRM_DEBUG("map->offset : %lx\n", map->offset); - DRM_DEBUG("map->size : %lx\n", map->size); - DRM_DEBUG("map->type : %d\n", map->type); - DRM_DEBUG("map->flags : %x\n", map->flags); - DRM_DEBUG("map->handle : %lx\n", map->handle); - DRM_DEBUG("map->mtrr : %d\n", map->mtrr); - - virtual = do_mmap(filp, 0, map->size, PROT_READ|PROT_WRITE, - MAP_SHARED, (unsigned long)map->offset); - } else { - virtual = do_mmap(filp, 0, dma->byte_count, - PROT_READ|PROT_WRITE, MAP_SHARED, 0); - } - if (virtual > -1024UL) { - /* Real error */ - DRM_DEBUG("mmap error\n"); - retcode = (signed long)virtual; - goto done; - } - request.virtual = (void *)virtual; + map = dev->maplist[dev_priv->buffer_map_idx]; + if (!map) { + DRM_DEBUG("map is null\n"); + retcode = -EINVAL; + goto done; + } + + DRM_DEBUG("map->offset : %lx\n", map->offset); + DRM_DEBUG("map->size : %lx\n", map->size); + DRM_DEBUG("map->type : %d\n", map->type); + DRM_DEBUG("map->flags : %x\n", map->flags); + DRM_DEBUG("map->handle : %p\n", map->handle); + DRM_DEBUG("map->mtrr : %d\n", map->mtrr); + down(¤t->mm->mmap_sem); + virtual = do_mmap(filp, 0, map->size, + PROT_READ|PROT_WRITE, + MAP_SHARED, + (unsigned long)map->offset); + up(¤t->mm->mmap_sem); + } else { + down(¤t->mm->mmap_sem); + virtual = do_mmap(filp, 0, dma->byte_count, + PROT_READ|PROT_WRITE, MAP_SHARED, 0); + up(¤t->mm->mmap_sem); + } + if (virtual > -1024UL) { + /* Real error */ + DRM_DEBUG("mmap error\n"); + retcode = (signed long)virtual; + goto done; + } + request.virtual = (void *)virtual; - for (i = 0; i < dma->buf_count; i++) { - if (copy_to_user(&request.list[i].idx, - &dma->buflist[i]->idx, - sizeof(request.list[0].idx))) { - retcode = -EFAULT; - goto done; - } - if (copy_to_user(&request.list[i].total, - &dma->buflist[i]->total, - sizeof(request.list[0].total))) { - retcode = -EFAULT; - goto done; - } - if (copy_to_user(&request.list[i].used, - &zero, - sizeof(zero))) { - retcode = -EFAULT; - goto done; - } - address = virtual + dma->buflist[i]->offset; - if (copy_to_user(&request.list[i].address, - &address, - sizeof(address))) { - retcode = -EFAULT; - goto done; - } - } - } - done: - request.count = dma->buf_count; - DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode); + for (i = 0; i < dma->buf_count; i++) { + if (copy_to_user(&request.list[i].idx, + &dma->buflist[i]->idx, + sizeof(request.list[0].idx))) { + retcode = -EFAULT; + goto done; + } + if (copy_to_user(&request.list[i].total, + &dma->buflist[i]->total, + sizeof(request.list[0].total))) { + retcode = -EFAULT; + goto done; + } + if (copy_to_user(&request.list[i].used, + &zero, + sizeof(zero))) { + retcode = -EFAULT; + goto done; + } + address = virtual + dma->buflist[i]->offset; + if (copy_to_user(&request.list[i].address, + &address, + sizeof(address))) { + retcode = -EFAULT; + goto done; + } + } + } + done: + request.count = dma->buf_count; + DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode); - copy_to_user_ret((drm_buf_map_t *)arg, - &request, - sizeof(request), - -EFAULT); + copy_to_user_ret((drm_buf_map_t *)arg, + &request, + sizeof(request), + -EFAULT); - DRM_DEBUG("retcode : %d\n", retcode); + DRM_DEBUG("retcode : %d\n", retcode); - return retcode; + return retcode; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c index fb0d336fa..d02592740 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c @@ -2,6 +2,7 @@ * Created: Mon Dec 13 09:51:35 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,9 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Author: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c,v 1.1 2000/02/11 17:26:06 dawes Exp $ + * Author: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> * */ @@ -38,7 +38,7 @@ static int mga_alloc_queue(drm_device_t *dev) { int temp = drm_ctxbitmap_next(dev); - printk("mga_alloc_queue: %d\n", temp); + DRM_DEBUG("mga_alloc_queue: %d\n", temp); return temp; } @@ -57,7 +57,7 @@ int mga_context_switch(drm_device_t *dev, int old, int new) dev->ctx_start = get_cycles(); #endif - printk("Context switch from %d to %d\n", old, new); + DRM_DEBUG("Context switch from %d to %d\n", old, new); if (new == dev->last_context) { clear_bit(0, &dev->context_flag); @@ -104,7 +104,7 @@ int mga_resctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_ctx_t ctx; int i; - printk("%d\n", DRM_RESERVED_CONTEXTS); + DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS); copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT); if (res.count >= DRM_RESERVED_CONTEXTS) { memset(&ctx, 0, sizeof(ctx)); @@ -134,11 +134,11 @@ int mga_addctx(struct inode *inode, struct file *filp, unsigned int cmd, ctx.handle = mga_alloc_queue(dev); } if (ctx.handle == -1) { - printk("Not enough free contexts.\n"); + DRM_DEBUG("Not enough free contexts.\n"); /* Should this return -EBUSY instead? */ return -ENOMEM; } - printk("%d\n", ctx.handle); + DRM_DEBUG("%d\n", ctx.handle); copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); return 0; } @@ -170,7 +170,7 @@ int mga_switchctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_ctx_t ctx; copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); - printk("%d\n", ctx.handle); + DRM_DEBUG("%d\n", ctx.handle); return mga_context_switch(dev, dev->last_context, ctx.handle); } @@ -182,7 +182,7 @@ int mga_newctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_ctx_t ctx; copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); - printk("%d\n", ctx.handle); + DRM_DEBUG("%d\n", ctx.handle); mga_context_switch_complete(dev, ctx.handle); return 0; @@ -194,51 +194,11 @@ int mga_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, drm_file_t *priv = filp->private_data; drm_device_t *dev = priv->dev; drm_ctx_t ctx; - drm_queue_t *q; - drm_buf_t *buf; copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); - printk("%d\n", ctx.handle); - if(ctx.handle == DRM_KERNEL_CONTEXT) { - q = dev->queuelist[ctx.handle]; - atomic_inc(&q->use_count); - if (atomic_read(&q->use_count) == 1) { - /* No longer in use */ - atomic_dec(&q->use_count); - return -EINVAL; - } - atomic_inc(&q->finalization); /* Mark queue in finalization state */ - atomic_sub(2, &q->use_count); - /* Mark queue as unused (pending finalization) */ - - while (test_and_set_bit(0, &dev->interrupt_flag)) { - printk("Calling schedule from rmctx\n"); - schedule(); - if (signal_pending(current)) { - clear_bit(0, &dev->interrupt_flag); - return -EINTR; - } - } - - /* Remove queued buffers */ - while ((buf = drm_waitlist_get(&q->waitlist))) { - drm_free_buffer(dev, buf); - } - clear_bit(0, &dev->interrupt_flag); - - /* Wakeup blocked processes */ - wake_up_interruptible(&q->read_queue); - wake_up_interruptible(&q->write_queue); - wake_up_interruptible(&q->flush_queue); - - /* Finalization over. Queue is made - available when both use_count and - finalization become 0, which won't - happen until all the waiting processes - stop waiting. */ - atomic_dec(&q->finalization); - } else { - drm_ctxbitmap_free(dev, ctx.handle); + DRM_DEBUG("%d\n", ctx.handle); + if(ctx.handle != DRM_KERNEL_CONTEXT) { + drm_ctxbitmap_free(dev, ctx.handle); } return 0; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c index 2e24e5b48..25e3622ca 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c @@ -2,6 +2,7 @@ * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,19 +24,15 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Jeff Hartmann <jhartmann@precisioninsight.com> - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c,v 1.1 2000/02/11 17:26:07 dawes Exp $ + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> + * Keith Whitwell <keithw@valinux.com> * */ #define __NO_VERSION__ #include "drmP.h" #include "mga_drv.h" -#include "mgareg_flags.h" -#include "mga_dma.h" -#include "mga_state.h" #include <linux/interrupt.h> /* For task queue support */ @@ -48,643 +45,575 @@ #define MGA_WRITE(reg,val) do { MGA_DEREF(reg) = val; } while (0) #define PDEA_pagpxfer_enable 0x2 -#define MGA_SYNC_TAG 0x423f4200 - -typedef enum { - TT_GENERAL, - TT_BLIT, - TT_VECTOR, - TT_VERTEX -} transferType_t; +static int mga_flush_queue(drm_device_t *dev); -static void mga_delay(void) +static unsigned long mga_alloc_page(drm_device_t *dev) { - return; + unsigned long address; + + DRM_DEBUG("%s\n", __FUNCTION__); + address = __get_free_page(GFP_KERNEL); + if(address == 0UL) { + return 0; + } + atomic_inc(&mem_map[MAP_NR((void *) address)].count); + set_bit(PG_locked, &mem_map[MAP_NR((void *) address)].flags); + + return address; } -int mga_dma_cleanup(drm_device_t *dev) +static void mga_free_page(drm_device_t *dev, unsigned long page) { - if(dev->dev_private) { - drm_mga_private_t *dev_priv = - (drm_mga_private_t *) dev->dev_private; - - if(dev_priv->ioremap) { - int temp = (dev_priv->warp_ucode_size + - dev_priv->primary_size + - PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE; + DRM_DEBUG("%s\n", __FUNCTION__); - drm_ioremapfree((void *) dev_priv->ioremap, temp); - } - - drm_free(dev->dev_private, sizeof(drm_mga_private_t), - DRM_MEM_DRIVER); - dev->dev_private = NULL; + if(page == 0UL) { + return; } - - return 0; + atomic_dec(&mem_map[MAP_NR((void *) page)].count); + clear_bit(PG_locked, &mem_map[MAP_NR((void *) page)].flags); + wake_up(&mem_map[MAP_NR((void *) page)].wait); + free_page(page); + return; } -static int mga_alloc_kernel_queue(drm_device_t *dev) +static void mga_delay(void) { - drm_queue_t *queue = NULL; - /* Allocate a new queue */ - down(&dev->struct_sem); - - if(dev->queue_count != 0) { - /* Reseting the kernel context here is not - * a race, since it can only happen when that - * queue is empty. - */ - queue = dev->queuelist[DRM_KERNEL_CONTEXT]; - printk("Kernel queue already allocated\n"); - } else { - queue = drm_alloc(sizeof(*queue), DRM_MEM_QUEUES); - if(!queue) { - up(&dev->struct_sem); - printk("out of memory\n"); - return -ENOMEM; - } - ++dev->queue_count; - dev->queuelist = drm_alloc(sizeof(*dev->queuelist), - DRM_MEM_QUEUES); - if(!dev->queuelist) { - up(&dev->struct_sem); - drm_free(queue, sizeof(*queue), DRM_MEM_QUEUES); - printk("out of memory\n"); - return -ENOMEM; - } - } - - memset(queue, 0, sizeof(*queue)); - atomic_set(&queue->use_count, 1); - atomic_set(&queue->finalization, 0); - atomic_set(&queue->block_count, 0); - atomic_set(&queue->block_read, 0); - atomic_set(&queue->block_write, 0); - atomic_set(&queue->total_queued, 0); - atomic_set(&queue->total_flushed, 0); - atomic_set(&queue->total_locks, 0); - - init_waitqueue_head(&queue->write_queue); - init_waitqueue_head(&queue->read_queue); - init_waitqueue_head(&queue->flush_queue); - - queue->flags = 0; - - drm_waitlist_create(&queue->waitlist, dev->dma->buf_count); - - dev->queue_slots = 1; - dev->queuelist[DRM_KERNEL_CONTEXT] = queue; - dev->queue_count--; - - up(&dev->struct_sem); - printk("%d (new)\n", dev->queue_count - 1); - return DRM_KERNEL_CONTEXT; + return; } -static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { - drm_mga_private_t *dev_priv; - drm_map_t *prim_map = NULL; - drm_map_t *sarea_map = NULL; - int temp; +void mga_flush_write_combine(void) +{ + int xchangeDummy; + DRM_DEBUG("%s\n", __FUNCTION__); + __asm__ volatile(" push %%eax ; xchg %%eax, %0 ; pop %%eax" : : "m" (xchangeDummy)); + __asm__ volatile(" push %%eax ; push %%ebx ; push %%ecx ; push %%edx ;" + " movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;" + " pop %%eax" : /* no outputs */ : /* no inputs */ ); +} - dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); - if(dev_priv == NULL) return -ENOMEM; - dev->dev_private = (void *) dev_priv; +/* These are two age tags that will never be sent to + * the hardware */ +#define MGA_BUF_USED 0xffffffff +#define MGA_BUF_FREE 0 - printk("dev_private\n"); +static int mga_freelist_init(drm_device_t *dev) +{ + drm_device_dma_t *dma = dev->dma; + drm_buf_t *buf; + drm_mga_buf_priv_t *buf_priv; + drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; + drm_mga_freelist_t *item; + int i; - memset(dev_priv, 0, sizeof(drm_mga_private_t)); - atomic_set(&dev_priv->pending_bufs, 0); + DRM_DEBUG("%s\n", __FUNCTION__); - if((init->reserved_map_idx >= dev->map_count) || - (init->buffer_map_idx >= dev->map_count)) { - mga_dma_cleanup(dev); - printk("reserved_map or buffer_map are invalid\n"); - return -EINVAL; - } + dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); + if(dev_priv->head == NULL) return -ENOMEM; + memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t)); + dev_priv->head->age = MGA_BUF_USED; - if(mga_alloc_kernel_queue(dev) != DRM_KERNEL_CONTEXT) { - mga_dma_cleanup(dev); - DRM_ERROR("Kernel context queue not present\n"); + for (i = 0; i < dma->buf_count; i++) { + buf = dma->buflist[ i ]; + buf_priv = buf->dev_private; + item = drm_alloc(sizeof(drm_mga_freelist_t), + DRM_MEM_DRIVER); + if(item == NULL) return -ENOMEM; + memset(item, 0, sizeof(drm_mga_freelist_t)); + item->age = MGA_BUF_FREE; + item->prev = dev_priv->head; + item->next = dev_priv->head->next; + if(dev_priv->head->next != NULL) + dev_priv->head->next->prev = item; + if(item->next == NULL) dev_priv->tail = item; + item->buf = buf; + buf_priv->my_freelist = item; + buf_priv->discard = 0; + buf_priv->dispatched = 0; + dev_priv->head->next = item; } - - dev_priv->reserved_map_idx = init->reserved_map_idx; - dev_priv->buffer_map_idx = init->buffer_map_idx; - sarea_map = dev->maplist[0]; - dev_priv->sarea_priv = (drm_mga_sarea_t *) - ((u8 *)sarea_map->handle + - init->sarea_priv_offset); - printk("sarea_priv\n"); - - /* Scale primary size to the next page */ - dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) / - PAGE_SIZE) * PAGE_SIZE; - dev_priv->warp_ucode_size = init->warp_ucode_size; - dev_priv->chipset = init->chipset; - dev_priv->fbOffset = init->fbOffset; - dev_priv->backOffset = init->backOffset; - dev_priv->depthOffset = init->depthOffset; - dev_priv->textureOffset = init->textureOffset; - dev_priv->textureSize = init->textureSize; - dev_priv->cpp = init->cpp; - dev_priv->sgram = init->sgram; - dev_priv->stride = init->stride; - - dev_priv->frontOrg = init->frontOrg; - dev_priv->backOrg = init->backOrg; - dev_priv->depthOrg = init->depthOrg; - dev_priv->mAccess = init->mAccess; - - printk("memcpy\n"); - memcpy(&dev_priv->WarpIndex, &init->WarpIndex, - sizeof(mgaWarpIndex) * MGA_MAX_WARP_PIPES); - printk("memcpy done\n"); - prim_map = dev->maplist[init->reserved_map_idx]; - dev_priv->prim_phys_head = dev->agp->base + init->reserved_map_agpstart; - temp = init->warp_ucode_size + dev_priv->primary_size; - temp = ((temp + PAGE_SIZE - 1) / - PAGE_SIZE) * PAGE_SIZE; - printk("temp : %x\n", temp); - printk("dev->agp->base: %lx\n", dev->agp->base); - printk("init->reserved_map_agpstart: %x\n", init->reserved_map_agpstart); - - - dev_priv->ioremap = drm_ioremap(dev->agp->base + init->reserved_map_agpstart, - temp); - if(dev_priv->ioremap == NULL) { - printk("Ioremap failed\n"); - mga_dma_cleanup(dev); - return -ENOMEM; - } - - + return 0; +} - dev_priv->prim_head = (u32 *)dev_priv->ioremap; - printk("dev_priv->prim_head : %p\n", dev_priv->prim_head); - dev_priv->current_dma_ptr = dev_priv->prim_head; - dev_priv->prim_num_dwords = 0; - dev_priv->prim_max_dwords = dev_priv->primary_size / 4; - - printk("dma initialization\n"); +static void mga_freelist_cleanup(drm_device_t *dev) +{ + drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; + drm_mga_freelist_t *item; + drm_mga_freelist_t *prev; - /* Private is now filled in, initialize the hardware */ - { - PRIMLOCALS; - PRIMRESET( dev_priv ); - PRIMGETPTR( dev_priv ); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DWGSYNC, 0); - PRIMOUTREG(MGAREG_SOFTRAP, 0); - PRIMADVANCE( dev_priv ); + DRM_DEBUG("%s\n", __FUNCTION__); - /* Poll for the first buffer to insure that - * the status register will be correct - */ - printk("phys_head : %lx\n", phys_head); + item = dev_priv->head; + while(item) { + prev = item; + item = item->next; + drm_free(prev, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER); + } - MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG); + dev_priv->head = dev_priv->tail = NULL; +} - while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) { - int i; - for(i = 0 ; i < 4096; i++) mga_delay(); +/* Frees dispatch lock */ +static inline void mga_dma_quiescent(drm_device_t *dev) +{ + drm_device_dma_t *dma = dev->dma; + drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned long end; + int i; + + DRM_DEBUG("%s\n", __FUNCTION__); + end = jiffies + (HZ*3); + while(1) { + if(!test_and_set_bit(MGA_IN_DISPATCH, + &dev_priv->dispatch_status)) { + break; } - - MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL); - - MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) | - PDEA_pagpxfer_enable)); - - while(MGA_READ(MGAREG_DWGSYNC) == MGA_SYNC_TAG) { - int i; - for(i = 0; i < 4096; i++) mga_delay(); + if((signed)(end - jiffies) <= 0) { + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), + atomic_read(&dma->total_lost)); + DRM_ERROR("lockup\n"); + goto out_nolock; + } + for (i = 0 ; i < 2000 ; i++) mga_delay(); + } + end = jiffies + (HZ*3); + DRM_DEBUG("quiescent status : %x\n", MGA_READ(MGAREG_STATUS)); + while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) { + if((signed)(end - jiffies) <= 0) { + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), + atomic_read(&dma->total_lost)); + DRM_ERROR("lockup\n"); + goto out_status; } + for (i = 0 ; i < 2000 ; i++) mga_delay(); + } + sarea_priv->dirty |= MGA_DMA_FLUSH; + +out_status: + clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); +out_nolock: +} +static void mga_reset_freelist(drm_device_t *dev) +{ + drm_device_dma_t *dma = dev->dma; + drm_buf_t *buf; + drm_mga_buf_priv_t *buf_priv; + int i; + + for (i = 0; i < dma->buf_count; i++) { + buf = dma->buflist[ i ]; + buf_priv = buf->dev_private; + buf_priv->my_freelist->age = MGA_BUF_FREE; } - - printk("dma init was successful\n"); - return 0; } -int mga_dma_init(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) +/* Least recently used : + * These operations are not atomic b/c they are protected by the + * hardware lock */ + +drm_buf_t *mga_freelist_get(drm_device_t *dev) { - drm_file_t *priv = filp->private_data; - drm_device_t *dev = priv->dev; - drm_mga_init_t init; + DECLARE_WAITQUEUE(entry, current); + drm_mga_private_t *dev_priv = + (drm_mga_private_t *) dev->dev_private; + drm_mga_freelist_t *prev; + drm_mga_freelist_t *next; + static int failed = 0; + + DRM_DEBUG("%s : tail->age : %d last_prim_age : %d\n", __FUNCTION__, + dev_priv->tail->age, dev_priv->last_prim_age); - copy_from_user_ret(&init, (drm_mga_init_t *)arg, sizeof(init), -EFAULT); + if(failed >= 1000 && dev_priv->tail->age >= dev_priv->last_prim_age) { + DRM_DEBUG("I'm waiting on the freelist!!! %d\n", + dev_priv->last_prim_age); + set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); + current->state = TASK_INTERRUPTIBLE; + add_wait_queue(&dev_priv->buf_queue, &entry); + for (;;) { + mga_dma_schedule(dev, 0); + if(!test_bit(MGA_IN_GETBUF, + &dev_priv->dispatch_status)) + break; + atomic_inc(&dev->total_sleeps); + schedule(); + if (signal_pending(current)) { + clear_bit(MGA_IN_GETBUF, + &dev_priv->dispatch_status); + goto failed_getbuf; + } + } + current->state = TASK_RUNNING; + remove_wait_queue(&dev_priv->buf_queue, &entry); + } - switch(init.func) { - case MGA_INIT_DMA: - return mga_dma_initialize(dev, &init); - case MGA_CLEANUP_DMA: - return mga_dma_cleanup(dev); + if(dev_priv->tail->age < dev_priv->last_prim_age) { + prev = dev_priv->tail->prev; + next = dev_priv->tail; + prev->next = NULL; + next->prev = next->next = NULL; + dev_priv->tail = prev; + next->age = MGA_BUF_USED; + failed = 0; + return next->buf; } - return -EINVAL; +failed_getbuf: + failed++; + return NULL; } -#define MGA_ILOAD_CMD (DC_opcod_iload | DC_atype_rpl | \ - DC_linear_linear | DC_bltmod_bfcol | \ - (0xC << DC_bop_SHIFT) | DC_sgnzero_enable | \ - DC_shftzero_enable | DC_clipdis_enable) - -static void __mga_iload_small(drm_device_t *dev, - drm_buf_t *buf, - int use_agp) +int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf) { - drm_mga_private_t *dev_priv = dev->dev_private; + drm_mga_private_t *dev_priv = + (drm_mga_private_t *) dev->dev_private; drm_mga_buf_priv_t *buf_priv = buf->dev_private; - drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - unsigned long address = (unsigned long)buf->bus_address; - int length = buf->used; - int y1 = buf_priv->boxes[0].y1; - int x1 = buf_priv->boxes[0].x1; - int y2 = buf_priv->boxes[0].y2; - int x2 = buf_priv->boxes[0].x2; - int dstorg = buf_priv->ContextState[MGA_CTXREG_DSTORG]; - int maccess = buf_priv->ContextState[MGA_CTXREG_MACCESS]; - PRIMLOCALS; - - PRIMRESET(dev_priv); - PRIMGETPTR(dev_priv); + drm_mga_freelist_t *prev; + drm_mga_freelist_t *head; + drm_mga_freelist_t *next; + + DRM_DEBUG("%s\n", __FUNCTION__); + + if(buf_priv->my_freelist->age == MGA_BUF_USED) { + /* Discarded buffer, put it on the tail */ + next = buf_priv->my_freelist; + next->age = MGA_BUF_FREE; + prev = dev_priv->tail; + prev->next = next; + next->prev = prev; + next->next = NULL; + dev_priv->tail = next; + DRM_DEBUG("Discarded\n"); + } else { + /* Normally aged buffer, put it on the head + 1, + * as the real head is a sentinal element + */ + next = buf_priv->my_freelist; + head = dev_priv->head; + prev = head->next; + head->next = next; + prev->prev = next; + next->prev = head; + next->next = prev; + } - PRIMOUTREG(MGAREG_DSTORG, dstorg | use_agp); - PRIMOUTREG(MGAREG_MACCESS, maccess); - PRIMOUTREG(MGAREG_PITCH, (1 << 15)); - PRIMOUTREG(MGAREG_YDST, y1 * (x2 - x1)); - PRIMOUTREG(MGAREG_LEN, 1); - PRIMOUTREG(MGAREG_FXBNDRY, ((x2 - x1) * (y2 - y1) - 1) << 16); - PRIMOUTREG(MGAREG_AR0, (x2 - x1) * (y2 - y1) - 1); - PRIMOUTREG(MGAREG_AR3, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DWGCTL+MGAREG_MGA_EXEC, MGA_ILOAD_CMD); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_SECADDRESS, address | TT_BLIT); - PRIMOUTREG(MGAREG_SECEND, (address + length) | use_agp); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DWGSYNC, 0); - PRIMOUTREG(MGAREG_SOFTRAP, 0); - PRIMADVANCE(dev_priv); -#if 0 - /* For now we need to set this in the ioctl */ - sarea_priv->dirty |= MGASAREA_NEW_CONTEXT; -#endif - MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG); - while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ; - - MGA_WRITE(MGAREG_PRIMADDRESS, dev_priv->prim_phys_head | TT_GENERAL); - MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp); + return 0; } -static void __mga_iload_xy(drm_device_t *dev, - drm_buf_t *buf, - int use_agp) +static int mga_init_primary_bufs(drm_device_t *dev, drm_mga_init_t *init) { - drm_mga_private_t *dev_priv = dev->dev_private; - drm_mga_buf_priv_t *buf_priv = buf->dev_private; - drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - unsigned long address = (unsigned long)buf->bus_address; - int length = buf->used; - int y1 = buf_priv->boxes[0].y1; - int x1 = buf_priv->boxes[0].x1; - int y2 = buf_priv->boxes[0].y2; - int x2 = buf_priv->boxes[0].x2; - int dstorg = buf_priv->ContextState[MGA_CTXREG_DSTORG]; - int maccess = buf_priv->ContextState[MGA_CTXREG_MACCESS]; - int pitch = buf_priv->ServerState[MGA_2DREG_PITCH]; - int width, height; - int texperdword = 0; - PRIMLOCALS; - - width = (x2 - x1); - height = (y2 - y1); - switch((maccess & 0x00000003)) { - case 0: - texperdword = 4; - break; - case 1: - texperdword = 2; - break; - case 2: - texperdword = 1; - break; - default: - DRM_ERROR("Invalid maccess value passed to __mga_iload_xy\n"); - return; + drm_mga_private_t *dev_priv = dev->dev_private; + drm_mga_prim_buf_t *prim_buffer; + int i, temp, size_of_buf; + int offset = init->reserved_map_agpstart; + + DRM_DEBUG("%s\n", __FUNCTION__); + dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) / + PAGE_SIZE) * PAGE_SIZE; + size_of_buf = dev_priv->primary_size / MGA_NUM_PRIM_BUFS; + dev_priv->warp_ucode_size = init->warp_ucode_size; + dev_priv->prim_bufs = drm_alloc(sizeof(drm_mga_prim_buf_t *) * + (MGA_NUM_PRIM_BUFS + 1), + DRM_MEM_DRIVER); + if(dev_priv->prim_bufs == NULL) { + DRM_ERROR("Unable to allocate memory for prim_buf\n"); + return -ENOMEM; } + memset(dev_priv->prim_bufs, + 0, sizeof(drm_mga_prim_buf_t *) * (MGA_NUM_PRIM_BUFS + 1)); - x2 = x1 + width; - x2 = (x2 + (texperdword - 1)) & ~(texperdword - 1); - x1 = (x1 + (texperdword - 1)) & ~(texperdword - 1); - width = x2 - x1; - - PRIMRESET(dev_priv); - PRIMGETPTR(dev_priv); - PRIMOUTREG(MGAREG_DSTORG, dstorg | use_agp); - PRIMOUTREG(MGAREG_MACCESS, maccess); - PRIMOUTREG(MGAREG_PITCH, pitch); - PRIMOUTREG(MGAREG_YDSTLEN, (y1 << 16) | height); - - PRIMOUTREG(MGAREG_FXBNDRY, ((x1+width-1) << 16) | x1); - PRIMOUTREG(MGAREG_AR0, width * height - 1); - PRIMOUTREG(MGAREG_AR3, 0 ); - PRIMOUTREG(MGAREG_DWGCTL+MGAREG_MGA_EXEC, MGA_ILOAD_CMD); - - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_SECADDRESS, address | TT_BLIT); - PRIMOUTREG(MGAREG_SECEND, (address + length) | use_agp); + temp = init->warp_ucode_size + dev_priv->primary_size; + temp = ((temp + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE; - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DMAPAD, 0); - PRIMOUTREG(MGAREG_DWGSYNC, 0); - PRIMOUTREG(MGAREG_SOFTRAP, 0); - PRIMADVANCE(dev_priv); -#if 0 - /* For now we need to set this in the ioctl */ - sarea_priv->dirty |= MGASAREA_NEW_CONTEXT; -#endif - MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG); - while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ; - - MGA_WRITE(MGAREG_PRIMADDRESS, dev_priv->prim_phys_head | TT_GENERAL); - MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp); + dev_priv->ioremap = drm_ioremap(dev->agp->base + offset, + temp); + if(dev_priv->ioremap == NULL) { + DRM_DEBUG("Ioremap failed\n"); + return -ENOMEM; + } + init_waitqueue_head(&dev_priv->wait_queue); + + for(i = 0; i < MGA_NUM_PRIM_BUFS; i++) { + prim_buffer = drm_alloc(sizeof(drm_mga_prim_buf_t), + DRM_MEM_DRIVER); + if(prim_buffer == NULL) return -ENOMEM; + memset(prim_buffer, 0, sizeof(drm_mga_prim_buf_t)); + prim_buffer->phys_head = offset + dev->agp->base; + prim_buffer->current_dma_ptr = + prim_buffer->head = + (u32 *) (dev_priv->ioremap + + offset - + init->reserved_map_agpstart); + prim_buffer->num_dwords = 0; + prim_buffer->max_dwords = size_of_buf / sizeof(u32); + prim_buffer->max_dwords -= 5; /* Leave room for the softrap */ + prim_buffer->sec_used = 0; + prim_buffer->idx = i; + prim_buffer->prim_age = i + 1; + offset = offset + size_of_buf; + dev_priv->prim_bufs[i] = prim_buffer; + } + dev_priv->current_prim_idx = 0; + dev_priv->next_prim = + dev_priv->last_prim = + dev_priv->current_prim = + dev_priv->prim_bufs[0]; + dev_priv->next_prim_age = 2; + dev_priv->last_prim_age = 1; + set_bit(MGA_BUF_IN_USE, &dev_priv->current_prim->buffer_status); + return 0; } -static void mga_dma_dispatch_iload(drm_device_t *dev, drm_buf_t *buf) +void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim) { - drm_mga_buf_priv_t *buf_priv = buf->dev_private; - - int use_agp = PDEA_pagpxfer_enable; - int x1 = buf_priv->boxes[0].x1; - int x2 = buf_priv->boxes[0].x2; + drm_mga_private_t *dev_priv = dev->dev_private; + drm_device_dma_t *dma = dev->dma; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + int use_agp = PDEA_pagpxfer_enable; + unsigned long end; + int i; + int next_idx; + PRIMLOCALS; + + DRM_DEBUG("%s\n", __FUNCTION__); + dev_priv->last_prim = prim; - if((x2 - x1) < 32) { - printk("using iload small\n"); - __mga_iload_small(dev, buf, use_agp); + /* We never check for overflow, b/c there is always room */ + PRIMPTR(prim); + if(num_dwords <= 0) { + DRM_DEBUG("num_dwords == 0 when dispatched\n"); + goto out_prim_wait; + } + PRIMOUTREG( MGAREG_DMAPAD, 0); + PRIMOUTREG( MGAREG_DMAPAD, 0); + PRIMOUTREG( MGAREG_DMAPAD, 0); + PRIMOUTREG( MGAREG_SOFTRAP, 0); + PRIMFINISH(prim); + + end = jiffies + (HZ*3); + if(sarea_priv->dirty & MGA_DMA_FLUSH) { + DRM_DEBUG("Dma top flush\n"); + while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) { + if((signed)(end - jiffies) <= 0) { + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), + atomic_read(&dma->total_lost)); + DRM_ERROR("lockup in fire primary " + "(Dma Top Flush)\n"); + goto out_prim_wait; + } + + for (i = 0 ; i < 4096 ; i++) mga_delay(); + } + sarea_priv->dirty &= ~(MGA_DMA_FLUSH); } else { - printk("using iload xy\n"); - __mga_iload_xy(dev, buf, use_agp); - } -} - -static void mga_dma_dispatch_vertex(drm_device_t *dev, drm_buf_t *buf) -{ - drm_mga_private_t *dev_priv = dev->dev_private; - drm_mga_buf_priv_t *buf_priv = buf->dev_private; - unsigned long address = (unsigned long)buf->bus_address; - int length = buf->used; - int use_agp = PDEA_pagpxfer_enable; - int i, count; - PRIMLOCALS; - - PRIMRESET(dev_priv); - - count = buf_priv->nbox; - if (count == 0) - count = 1; - - mgaEmitState( dev_priv, buf_priv ); - - for (i = 0 ; i < count ; i++) { - if (i < buf_priv->nbox) - mgaEmitClipRect( dev_priv, &buf_priv->boxes[i] ); - - PRIMGETPTR(dev_priv); - PRIMOUTREG( MGAREG_DMAPAD, 0); - PRIMOUTREG( MGAREG_DMAPAD, 0); - PRIMOUTREG( MGAREG_SECADDRESS, address | TT_VERTEX); - PRIMOUTREG( MGAREG_SECEND, (address + length) | use_agp); - - PRIMOUTREG( MGAREG_DMAPAD, 0); - PRIMOUTREG( MGAREG_DMAPAD, 0); - PRIMOUTREG( MGAREG_DWGSYNC, 0); - PRIMOUTREG( MGAREG_SOFTRAP, 0); - PRIMADVANCE(dev_priv); + DRM_DEBUG("Status wait\n"); + while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) { + if((signed)(end - jiffies) <= 0) { + DRM_ERROR("irqs: %d wanted %d\n", + atomic_read(&dev->total_irq), + atomic_read(&dma->total_lost)); + DRM_ERROR("lockup in fire primary " + "(Status Wait)\n"); + goto out_prim_wait; + } + + for (i = 0 ; i < 4096 ; i++) mga_delay(); + } } - PRIMGETPTR( dev_priv ); - - MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG); - while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ; - - MGA_WRITE(MGAREG_PRIMADDRESS, dev_priv->prim_phys_head | TT_GENERAL); - MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp); + mga_flush_write_combine(); + atomic_inc(&dev_priv->pending_bufs); + MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL); + MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp); + prim->num_dwords = 0; + sarea_priv->last_enqueue = prim->prim_age; + + next_idx = prim->idx + 1; + if(next_idx >= MGA_NUM_PRIM_BUFS) + next_idx = 0; + + dev_priv->next_prim = dev_priv->prim_bufs[next_idx]; + return; + + out_prim_wait: + prim->num_dwords = 0; + prim->sec_used = 0; + clear_bit(MGA_BUF_IN_USE, &prim->buffer_status); + wake_up_interruptible(&dev_priv->wait_queue); + clear_bit(MGA_BUF_SWAP_PENDING, &prim->buffer_status); + clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); } - -/* Used internally for the small buffers generated from client state - * information. - */ -static void mga_dma_dispatch_general(drm_device_t *dev, drm_buf_t *buf) +int mga_advance_primary(drm_device_t *dev) { + DECLARE_WAITQUEUE(entry, current); drm_mga_private_t *dev_priv = dev->dev_private; - unsigned long address = (unsigned long)buf->bus_address; - int length = buf->used; - int use_agp = PDEA_pagpxfer_enable; - PRIMLOCALS; - - PRIMRESET(dev_priv); - PRIMGETPTR(dev_priv); - - PRIMOUTREG( MGAREG_DMAPAD, 0); - PRIMOUTREG( MGAREG_DMAPAD, 0); - PRIMOUTREG( MGAREG_SECADDRESS, address | TT_GENERAL); - PRIMOUTREG( MGAREG_SECEND, (address + length) | use_agp); - - PRIMOUTREG( MGAREG_DMAPAD, 0); - PRIMOUTREG( MGAREG_DMAPAD, 0); - PRIMOUTREG( MGAREG_DWGSYNC, 0); - PRIMOUTREG( MGAREG_SOFTRAP, 0); - PRIMADVANCE(dev_priv); + drm_mga_prim_buf_t *prim_buffer; + drm_device_dma_t *dma = dev->dma; + int next_prim_idx; + int ret = 0; + + /* This needs to reset the primary buffer if available, + * we should collect stats on how many times it bites + * it's tail */ + DRM_DEBUG("%s\n", __FUNCTION__); + + next_prim_idx = dev_priv->current_prim_idx + 1; + if(next_prim_idx >= MGA_NUM_PRIM_BUFS) + next_prim_idx = 0; + prim_buffer = dev_priv->prim_bufs[next_prim_idx]; + set_bit(MGA_IN_WAIT, &dev_priv->dispatch_status); + + /* In use is cleared in interrupt handler */ + + if(test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) { + add_wait_queue(&dev_priv->wait_queue, &entry); + current->state = TASK_INTERRUPTIBLE; + + for (;;) { + mga_dma_schedule(dev, 0); + if(!test_and_set_bit(MGA_BUF_IN_USE, + &prim_buffer->buffer_status)) + break; + atomic_inc(&dev->total_sleeps); + atomic_inc(&dma->total_missed_sched); + schedule(); + if (signal_pending(current)) { + ret = -ERESTARTSYS; + break; + } + } + current->state = TASK_RUNNING; + remove_wait_queue(&dev_priv->wait_queue, &entry); + if(ret) return ret; + } + clear_bit(MGA_IN_WAIT, &dev_priv->dispatch_status); + + /* This primary buffer is now free to use */ + prim_buffer->current_dma_ptr = prim_buffer->head; + prim_buffer->num_dwords = 0; + prim_buffer->sec_used = 0; + prim_buffer->prim_age = dev_priv->next_prim_age++; + if(prim_buffer->prim_age == 0 || prim_buffer->prim_age == 0xffffffff) { + mga_flush_queue(dev); + mga_dma_quiescent(dev); + mga_reset_freelist(dev); + prim_buffer->prim_age = (dev_priv->next_prim_age += 2); + } - MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG); - while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ; + /* Reset all buffer status stuff */ + clear_bit(MGA_BUF_NEEDS_OVERFLOW, &prim_buffer->buffer_status); + clear_bit(MGA_BUF_FORCE_FIRE, &prim_buffer->buffer_status); + clear_bit(MGA_BUF_SWAP_PENDING, &prim_buffer->buffer_status); - MGA_WRITE(MGAREG_PRIMADDRESS, dev_priv->prim_phys_head | TT_GENERAL); - MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp); + dev_priv->current_prim = prim_buffer; + dev_priv->current_prim_idx = next_prim_idx; + return 0; } -/* Frees dispatch lock */ -static inline void mga_dma_quiescent(drm_device_t *dev) +/* More dynamic performance decisions */ +static inline int mga_decide_to_fire(drm_device_t *dev) { drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; + drm_device_dma_t *dma = dev->dma; - while(1) { - atomic_inc(&dev_priv->dispatch_lock); - if(atomic_read(&dev_priv->dispatch_lock) == 1) { - break; - } else { - atomic_dec(&dev_priv->dispatch_lock); - } - } - while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) ; -#if 0 - MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG); -#endif - while(MGA_READ(MGAREG_DWGSYNC) == MGA_SYNC_TAG) ; - MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG); - while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ; - atomic_dec(&dev_priv->dispatch_lock); -} + DRM_DEBUG("%s\n", __FUNCTION__); -/* Keeps dispatch lock held */ + if(test_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status)) { + atomic_inc(&dma->total_prio); + return 1; + } -static inline int mga_dma_is_ready(drm_device_t *dev) -{ - drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - - atomic_inc(&dev_priv->dispatch_lock); - if(atomic_read(&dev_priv->dispatch_lock) == 1) { - /* We got the lock */ - return 1; - } else { - atomic_dec(&dev_priv->dispatch_lock); - return 0; + if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) && + dev_priv->next_prim->num_dwords) { + atomic_inc(&dma->total_prio); + return 1; } -} -static inline int mga_dma_is_ready_no_hold(drm_device_t *dev) -{ - drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; + if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) && + dev_priv->next_prim->num_dwords) { + atomic_inc(&dma->total_prio); + return 1; + } - atomic_inc(&dev_priv->dispatch_lock); - if(atomic_read(&dev_priv->dispatch_lock) == 1) { - /* We got the lock, but free it */ - atomic_dec(&dev_priv->dispatch_lock); - return 1; - } else { - atomic_dec(&dev_priv->dispatch_lock); - return 0; + if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS - 1) { + if(test_bit(MGA_BUF_SWAP_PENDING, + &dev_priv->next_prim->buffer_status)) { + atomic_inc(&dma->total_dmas); + return 1; + } } -} - -static void mga_dma_service(int irq, void *device, struct pt_regs *regs) -{ - drm_device_t *dev = (drm_device_t *)device; - drm_device_dma_t *dma = dev->dma; - drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - - atomic_dec(&dev_priv->dispatch_lock); - atomic_inc(&dev->total_irq); - MGA_WRITE(MGAREG_ICLEAR, 0xfa7); - /* Free previous buffer */ - if (test_and_set_bit(0, &dev->dma_flag)) { - atomic_inc(&dma->total_missed_free); - return; - } - if (dma->this_buffer) { - drm_free_buffer(dev, dma->this_buffer); - dma->this_buffer = NULL; + if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS / 2) { + if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 8) { + atomic_inc(&dma->total_hit); + return 1; + } } - clear_bit(0, &dev->dma_flag); - /* Dispatch new buffer */ - queue_task(&dev->tq, &tq_immediate); - mark_bh(IMMEDIATE_BH); + if(atomic_read(&dev_priv->pending_bufs) >= MGA_NUM_PRIM_BUFS / 2) { + if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 4) { + atomic_inc(&dma->total_missed_free); + return 1; + } + } + atomic_inc(&dma->total_tried); + return 0; } -/* Only called by mga_dma_schedule. */ -static int mga_do_dma(drm_device_t *dev, int locked) +int mga_dma_schedule(drm_device_t *dev, int locked) { - drm_buf_t *buf; - int retcode = 0; - drm_device_dma_t *dma = dev->dma; drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; - drm_mga_buf_priv_t *buf_priv; + drm_device_dma_t *dma = dev->dma; - printk("mga_do_dma\n"); - if (test_and_set_bit(0, &dev->dma_flag)) { + if (test_and_set_bit(0, &dev->dma_flag)) { atomic_inc(&dma->total_missed_dma); return -EBUSY; } - - if (!dma->next_buffer) { - DRM_ERROR("No next_buffer\n"); - clear_bit(0, &dev->dma_flag); - return -EINVAL; - } - - buf = dma->next_buffer; - - printk("context %d, buffer %d\n", buf->context, buf->idx); - - if (buf->list == DRM_LIST_RECLAIM) { - drm_clear_next_buffer(dev); - drm_free_buffer(dev, buf); - clear_bit(0, &dev->dma_flag); - return -EINVAL; - } + + DRM_DEBUG("%s\n", __FUNCTION__); - if (!buf->used) { - DRM_ERROR("0 length buffer\n"); - drm_clear_next_buffer(dev); - drm_free_buffer(dev, buf); - clear_bit(0, &dev->dma_flag); - return 0; - } - - if (mga_dma_is_ready(dev) == 0) { - clear_bit(0, &dev->dma_flag); - return -EBUSY; + if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) || + test_bit(MGA_IN_WAIT, &dev_priv->dispatch_status) || + test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) { + locked = 1; } - /* Always hold the hardware lock while dispatching. - */ - if (!locked && !drm_lock_take(&dev->lock.hw_lock->lock, - DRM_KERNEL_CONTEXT)) { - atomic_inc(&dma->total_missed_lock); - clear_bit(0, &dev->dma_flag); - atomic_dec(&dev_priv->dispatch_lock); - return -EBUSY; + if (!locked && + !drm_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { + atomic_inc(&dma->total_missed_lock); + clear_bit(0, &dev->dma_flag); + DRM_DEBUG("Not locked\n"); + return -EBUSY; } - - dma->next_queue = dev->queuelist[DRM_KERNEL_CONTEXT]; - drm_clear_next_buffer(dev); - buf->pending = 1; - buf->waiting = 0; - buf->list = DRM_LIST_PEND; - - buf_priv = buf->dev_private; - - printk("dispatch!\n"); - switch (buf_priv->dma_type) { - case MGA_DMA_GENERAL: - mga_dma_dispatch_general(dev, buf); - break; - case MGA_DMA_VERTEX: - mga_dma_dispatch_vertex(dev, buf); - break; -/* case MGA_DMA_SETUP: */ -/* mga_dma_dispatch_setup(dev, address, length); */ -/* break; */ - case MGA_DMA_ILOAD: - mga_dma_dispatch_iload(dev, buf); - break; - default: - printk("bad buffer type %x in dispatch\n", buf_priv->dma_type); - break; + DRM_DEBUG("I'm locked\n"); + + if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) { + /* Fire dma buffer */ + if(mga_decide_to_fire(dev)) { + DRM_DEBUG("idx :%d\n", dev_priv->next_prim->idx); + clear_bit(MGA_BUF_FORCE_FIRE, + &dev_priv->next_prim->buffer_status); + if(dev_priv->current_prim == dev_priv->next_prim) { + /* Schedule overflow for a later time */ + set_bit(MGA_BUF_NEEDS_OVERFLOW, + &dev_priv->next_prim->buffer_status); + } + mga_fire_primary(dev, dev_priv->next_prim); + } else { + clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); + } + } else { + DRM_DEBUG("I can't get the dispatch lock\n"); } - atomic_dec(&dev_priv->pending_bufs); - - drm_free_buffer(dev, dma->this_buffer); - dma->this_buffer = buf; - - atomic_add(buf->used, &dma->total_bytes); - atomic_inc(&dma->total_dmas); - + if (!locked) { if (drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { @@ -692,90 +621,242 @@ static int mga_do_dma(drm_device_t *dev, int locked) } } - clear_bit(0, &dev->dma_flag); - - if(!atomic_read(&dev_priv->pending_bufs)) { - wake_up_interruptible(&dev->queuelist[DRM_KERNEL_CONTEXT]->flush_queue); - } - -#if 0 - wake_up_interruptible(&dev->lock.lock_queue); -#endif - - /* We hold the dispatch lock until the interrupt handler - * frees it - */ - return retcode; + if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) && + dev_priv->next_prim->num_dwords == 0 && + atomic_read(&dev_priv->pending_bufs) == 0) { + /* Everything has been processed by the hardware */ + clear_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status); + wake_up_interruptible(&dev_priv->flush_queue); + } + + if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) && + dev_priv->tail->age < dev_priv->last_prim_age) { + clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status); + DRM_DEBUG("Waking up buf queue\n"); + wake_up_interruptible(&dev_priv->buf_queue); + } else if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) { + DRM_DEBUG("Not waking buf_queue on %d %d\n", + atomic_read(&dev->total_irq), + dev_priv->last_prim_age); + } + + clear_bit(0, &dev->dma_flag); + return 0; } -static void mga_dma_schedule_timer_wrapper(unsigned long dev) +static void mga_dma_service(int irq, void *device, struct pt_regs *regs) { - mga_dma_schedule((drm_device_t *)dev, 0); + drm_device_t *dev = (drm_device_t *)device; + drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; + drm_mga_prim_buf_t *last_prim_buffer; + + DRM_DEBUG("%s\n", __FUNCTION__); + atomic_inc(&dev->total_irq); + if((MGA_READ(MGAREG_STATUS) & 0x00000001) != 0x00000001) return; + MGA_WRITE(MGAREG_ICLEAR, 0x00000001); + last_prim_buffer = dev_priv->last_prim; + last_prim_buffer->num_dwords = 0; + last_prim_buffer->sec_used = 0; + dev_priv->sarea_priv->last_dispatch = + dev_priv->last_prim_age = last_prim_buffer->prim_age; + clear_bit(MGA_BUF_IN_USE, &last_prim_buffer->buffer_status); + wake_up_interruptible(&dev_priv->wait_queue); + clear_bit(MGA_BUF_SWAP_PENDING, &last_prim_buffer->buffer_status); + clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status); + atomic_dec(&dev_priv->pending_bufs); + queue_task(&dev->tq, &tq_immediate); + mark_bh(IMMEDIATE_BH); } -static void mga_dma_schedule_tq_wrapper(void *dev) +static void mga_dma_task_queue(void *device) { - mga_dma_schedule(dev, 0); + DRM_DEBUG("%s\n", __FUNCTION__); + mga_dma_schedule((drm_device_t *)device, 0); } -int mga_dma_schedule(drm_device_t *dev, int locked) +int mga_dma_cleanup(drm_device_t *dev) { - drm_queue_t *q; - drm_buf_t *buf; - int retcode = 0; - int processed = 0; - int missed; - int expire = 20; - drm_device_dma_t *dma = dev->dma; - - printk("mga_dma_schedule\n"); - - if (test_and_set_bit(0, &dev->interrupt_flag)) { - /* Not reentrant */ - atomic_inc(&dma->total_missed_sched); - return -EBUSY; - } - missed = atomic_read(&dma->total_missed_sched); + DRM_DEBUG("%s\n", __FUNCTION__); -again: - /* There is only one queue: - */ - if (!dma->next_buffer && DRM_WAITCOUNT(dev, DRM_KERNEL_CONTEXT)) { - q = dev->queuelist[DRM_KERNEL_CONTEXT]; - buf = drm_waitlist_get(&q->waitlist); - dma->next_buffer = buf; - dma->next_queue = q; - if (buf && buf->list == DRM_LIST_RECLAIM) { - drm_clear_next_buffer(dev); - drm_free_buffer(dev, buf); + if(dev->dev_private) { + drm_mga_private_t *dev_priv = + (drm_mga_private_t *) dev->dev_private; + + if(dev_priv->ioremap) { + int temp = (dev_priv->warp_ucode_size + + dev_priv->primary_size + + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE; + + drm_ioremapfree((void *) dev_priv->ioremap, temp); + } + if(dev_priv->status_page != NULL) { + iounmap(dev_priv->status_page); + } + if(dev_priv->real_status_page != 0UL) { + mga_free_page(dev, dev_priv->real_status_page); + } + if(dev_priv->prim_bufs != NULL) { + int i; + for(i = 0; i < MGA_NUM_PRIM_BUFS; i++) { + if(dev_priv->prim_bufs[i] != NULL) { + drm_free(dev_priv->prim_bufs[i], + sizeof(drm_mga_prim_buf_t), + DRM_MEM_DRIVER); + } + } + drm_free(dev_priv->prim_bufs, sizeof(void *) * + (MGA_NUM_PRIM_BUFS + 1), + DRM_MEM_DRIVER); + } + if(dev_priv->head != NULL) { + mga_freelist_cleanup(dev); } + + + drm_free(dev->dev_private, sizeof(drm_mga_private_t), + DRM_MEM_DRIVER); + dev->dev_private = NULL; } - if (dma->next_buffer) { - if (!(retcode = mga_do_dma(dev, locked))) - ++processed; + return 0; +} + +static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) { + drm_mga_private_t *dev_priv; + drm_map_t *sarea_map = NULL; + int i; + + DRM_DEBUG("%s\n", __FUNCTION__); + + dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER); + if(dev_priv == NULL) return -ENOMEM; + dev->dev_private = (void *) dev_priv; + + memset(dev_priv, 0, sizeof(drm_mga_private_t)); + + if((init->reserved_map_idx >= dev->map_count) || + (init->buffer_map_idx >= dev->map_count)) { + mga_dma_cleanup(dev); + DRM_DEBUG("reserved_map or buffer_map are invalid\n"); + return -EINVAL; } + + dev_priv->reserved_map_idx = init->reserved_map_idx; + dev_priv->buffer_map_idx = init->buffer_map_idx; + sarea_map = dev->maplist[0]; + dev_priv->sarea_priv = (drm_mga_sarea_t *) + ((u8 *)sarea_map->handle + + init->sarea_priv_offset); - /* Try again if we succesfully dispatched a buffer, or if someone - * tried to schedule while we were working. - */ - if (--expire) { - if (missed != atomic_read(&dma->total_missed_sched)) { - atomic_inc(&dma->total_lost); - if (mga_dma_is_ready_no_hold(dev)) - goto again; - } + /* Scale primary size to the next page */ + dev_priv->chipset = init->chipset; + dev_priv->frontOffset = init->frontOffset; + dev_priv->backOffset = init->backOffset; + dev_priv->depthOffset = init->depthOffset; + dev_priv->textureOffset = init->textureOffset; + dev_priv->textureSize = init->textureSize; + dev_priv->cpp = init->cpp; + dev_priv->sgram = init->sgram; + dev_priv->stride = init->stride; - if (processed && mga_dma_is_ready_no_hold(dev)) { - atomic_inc(&dma->total_lost); - processed = 0; - goto again; - } + dev_priv->mAccess = init->mAccess; + init_waitqueue_head(&dev_priv->flush_queue); + init_waitqueue_head(&dev_priv->buf_queue); + dev_priv->WarpPipe = -1; + + DRM_DEBUG("chipset: %d ucode_size: %d backOffset: %x depthOffset: %x\n", + dev_priv->chipset, dev_priv->warp_ucode_size, + dev_priv->backOffset, dev_priv->depthOffset); + DRM_DEBUG("cpp: %d sgram: %d stride: %d maccess: %x\n", + dev_priv->cpp, dev_priv->sgram, dev_priv->stride, + dev_priv->mAccess); + + memcpy(&dev_priv->WarpIndex, &init->WarpIndex, + sizeof(drm_mga_warp_index_t) * MGA_MAX_WARP_PIPES); + + for (i = 0 ; i < MGA_MAX_WARP_PIPES ; i++) + DRM_DEBUG("warp pipe %d: installed: %d phys: %lx size: %x\n", + i, + dev_priv->WarpIndex[i].installed, + dev_priv->WarpIndex[i].phys_addr, + dev_priv->WarpIndex[i].size); + + if(mga_init_primary_bufs(dev, init) != 0) { + DRM_ERROR("Can not initialize primary buffers\n"); + mga_dma_cleanup(dev); + return -ENOMEM; } - - clear_bit(0, &dev->interrupt_flag); - - return retcode; + dev_priv->real_status_page = mga_alloc_page(dev); + if(dev_priv->real_status_page == 0UL) { + mga_dma_cleanup(dev); + DRM_ERROR("Can not allocate status page\n"); + return -ENOMEM; + } + + dev_priv->status_page = + ioremap_nocache(virt_to_bus((void *)dev_priv->real_status_page), + PAGE_SIZE); + + if(dev_priv->status_page == NULL) { + mga_dma_cleanup(dev); + DRM_ERROR("Can not remap status page\n"); + return -ENOMEM; + } + + /* Write status page when secend or softrap occurs */ + MGA_WRITE(MGAREG_PRIMPTR, + virt_to_bus((void *)dev_priv->real_status_page) | 0x00000003); + + + /* Private is now filled in, initialize the hardware */ + { + PRIMLOCALS; + PRIMGETPTR( dev_priv ); + + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0x0100); + PRIMOUTREG(MGAREG_SOFTRAP, 0); + /* Poll for the first buffer to insure that + * the status register will be correct + */ + + mga_flush_write_combine(); + MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL); + + MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) | + PDEA_pagpxfer_enable)); + + while(MGA_READ(MGAREG_DWGSYNC) != 0x0100) ; + } + + if(mga_freelist_init(dev) != 0) { + DRM_ERROR("Could not initialize freelist\n"); + mga_dma_cleanup(dev); + return -ENOMEM; + } + return 0; +} + +int mga_dma_init(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_mga_init_t init; + + DRM_DEBUG("%s\n", __FUNCTION__); + + copy_from_user_ret(&init, (drm_mga_init_t *)arg, sizeof(init), -EFAULT); + + switch(init.func) { + case MGA_INIT_DMA: + return mga_dma_initialize(dev, &init); + case MGA_CLEANUP_DMA: + return mga_dma_cleanup(dev); + } + + return -EINVAL; } int mga_irq_install(drm_device_t *dev, int irq) @@ -792,7 +873,7 @@ int mga_irq_install(drm_device_t *dev, int irq) dev->irq = irq; up(&dev->struct_sem); - printk("install irq handler %d\n", irq); + DRM_DEBUG("install irq handler %d\n", irq); dev->context_flag = 0; dev->interrupt_flag = 0; @@ -802,17 +883,15 @@ int mga_irq_install(drm_device_t *dev, int irq) dev->dma->this_buffer = NULL; dev->tq.next = NULL; dev->tq.sync = 0; - dev->tq.routine = mga_dma_schedule_tq_wrapper; + dev->tq.routine = mga_dma_task_queue; dev->tq.data = dev; /* Before installing handler */ - MGA_WRITE(MGAREG_ICLEAR, 0xfa7); MGA_WRITE(MGAREG_IEN, 0); - /* Install handler */ if ((retcode = request_irq(dev->irq, mga_dma_service, - 0, + SA_SHIRQ, dev->devname, dev))) { down(&dev->struct_sem); @@ -820,11 +899,9 @@ int mga_irq_install(drm_device_t *dev, int irq) up(&dev->struct_sem); return retcode; } - /* After installing handler */ - MGA_WRITE(MGAREG_ICLEAR, 0xfa7); + MGA_WRITE(MGAREG_ICLEAR, 0x00000001); MGA_WRITE(MGAREG_IEN, 0x00000001); - return 0; } @@ -838,19 +915,13 @@ int mga_irq_uninstall(drm_device_t *dev) up(&dev->struct_sem); if (!irq) return -EINVAL; - - printk("remove irq handler %d\n", irq); - - MGA_WRITE(MGAREG_ICLEAR, 0xfa7); + DRM_DEBUG("remove irq handler %d\n", irq); + MGA_WRITE(MGAREG_ICLEAR, 0x00000001); MGA_WRITE(MGAREG_IEN, 0); - MGA_WRITE(MGAREG_ICLEAR, 0xfa7); - free_irq(irq, dev); - return 0; } - int mga_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { @@ -859,7 +930,9 @@ int mga_control(struct inode *inode, struct file *filp, unsigned int cmd, drm_control_t ctl; copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT); - + + DRM_DEBUG("%s\n", __FUNCTION__); + switch (ctl.func) { case DRM_INST_HANDLER: return mga_irq_install(dev, ctl.irq); @@ -870,36 +943,69 @@ int mga_control(struct inode *inode, struct file *filp, unsigned int cmd, } } -int mga_flush_queue(drm_device_t *dev) +static int mga_flush_queue(drm_device_t *dev) { DECLARE_WAITQUEUE(entry, current); - drm_queue_t *q = dev->queuelist[DRM_KERNEL_CONTEXT]; - drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; + drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; int ret = 0; - - printk("mga_flush_queue\n"); - if(atomic_read(&dev_priv->pending_bufs) != 0) { - current->state = TASK_INTERRUPTIBLE; - add_wait_queue(&q->flush_queue, &entry); - for (;;) { - if (!atomic_read(&dev_priv->pending_bufs)) break; - printk("Calling schedule from flush_queue : %d\n", - atomic_read(&dev_priv->pending_bufs)); - mga_dma_schedule(dev, 1); - schedule(); - if (signal_pending(current)) { - ret = -EINTR; /* Can't restart */ - break; - } - } - printk("Exited out of schedule from flush_queue\n"); - current->state = TASK_RUNNING; - remove_wait_queue(&q->flush_queue, &entry); + + DRM_DEBUG("%s\n", __FUNCTION__); + + if(dev_priv == NULL) { + return 0; } + if(dev_priv->next_prim->num_dwords != 0) { + set_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status); + current->state = TASK_INTERRUPTIBLE; + add_wait_queue(&dev_priv->flush_queue, &entry); + for (;;) { + mga_dma_schedule(dev, 0); + if (!test_bit(MGA_IN_FLUSH, + &dev_priv->dispatch_status)) + break; + atomic_inc(&dev->total_sleeps); + schedule(); + if (signal_pending(current)) { + ret = -EINTR; /* Can't restart */ + clear_bit(MGA_IN_FLUSH, + &dev_priv->dispatch_status); + break; + } + } + current->state = TASK_RUNNING; + remove_wait_queue(&dev_priv->flush_queue, &entry); + } return ret; } +/* Must be called with the lock held */ +void mga_reclaim_buffers(drm_device_t *dev, pid_t pid) +{ + drm_device_dma_t *dma = dev->dma; + int i; + + if (!dma) return; + if(dev->dev_private == NULL) return; + if(dma->buflist == NULL) return; + + DRM_DEBUG("%s\n", __FUNCTION__); + mga_flush_queue(dev); + + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[ i ]; + drm_mga_buf_priv_t *buf_priv = buf->dev_private; + + /* Only buffers that need to get reclaimed ever + * get set to free + */ + if (buf->pid == pid && buf_priv) { + if(buf_priv->my_freelist->age == MGA_BUF_USED) + buf_priv->my_freelist->age = MGA_BUF_FREE; + } + } +} + int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { @@ -909,6 +1015,7 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, int ret = 0; drm_lock_t lock; + DRM_DEBUG("%s\n", __FUNCTION__); copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); if (lock.context == DRM_KERNEL_CONTEXT) { @@ -916,16 +1023,15 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, current->pid, lock.context); return -EINVAL; } - - printk("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", - lock.context, current->pid, dev->lock.hw_lock->lock, - lock.flags); - + + DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", + lock.context, current->pid, dev->lock.hw_lock->lock, + lock.flags); if (lock.context < 0) { return -EINVAL; } - + /* Only one queue: */ @@ -948,8 +1054,6 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, /* Contention */ atomic_inc(&dev->total_sleeps); current->state = TASK_INTERRUPTIBLE; - current->policy |= SCHED_YIELD; - printk("Calling lock schedule\n"); schedule(); if (signal_pending(current)) { ret = -ERESTARTSYS; @@ -962,17 +1066,46 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, if (!ret) { if (lock.flags & _DRM_LOCK_QUIESCENT) { - printk("_DRM_LOCK_QUIESCENT\n"); - ret = mga_flush_queue(dev); - if(ret != 0) { - drm_lock_free(dev, &dev->lock.hw_lock->lock, - lock.context); - } else { - mga_dma_quiescent(dev); - } + DRM_DEBUG("_DRM_LOCK_QUIESCENT\n"); + mga_flush_queue(dev); + mga_dma_quiescent(dev); } } - printk("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); + + DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); return ret; } +int mga_flush_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_lock_t lock; + drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private; + + DRM_DEBUG("%s\n", __FUNCTION__); + copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + + if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("mga_flush_ioctl called without lock held\n"); + return -EINVAL; + } + + if(lock.flags & _DRM_LOCK_FLUSH || lock.flags & _DRM_LOCK_FLUSH_ALL) { + drm_mga_prim_buf_t *temp_buf = + dev_priv->prim_bufs[dev_priv->current_prim_idx]; + + if(temp_buf && temp_buf->num_dwords) { + set_bit(MGA_BUF_FORCE_FIRE, &temp_buf->buffer_status); + mga_advance_primary(dev); + mga_dma_schedule(dev, 1); + } + } + if(lock.flags & _DRM_LOCK_QUIESCENT) { + mga_flush_queue(dev); + mga_dma_quiescent(dev); + } + + return 0; +} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h new file mode 100644 index 000000000..e75e91a4f --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h @@ -0,0 +1,269 @@ +/* mga_drm.h -- Public header for the Matrox g200/g400 driver -*- linux-c -*- + * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com + * + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. + * 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 (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 NONINFRINGEMENT. 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: Jeff Hartmann <jhartmann@valinux.com> + * Keith Whitwell <keithw@valinux.com> + * + */ + +#ifndef _MGA_DRM_H_ +#define _MGA_DRM_H_ + +/* WARNING: If you change any of these defines, make sure to change the + * defines in the Xserver file (xf86drmMga.h) + */ +#ifndef _MGA_DEFINES_ +#define _MGA_DEFINES_ + +#define MGA_F 0x1 /* fog */ +#define MGA_A 0x2 /* alpha */ +#define MGA_S 0x4 /* specular */ +#define MGA_T2 0x8 /* multitexture */ + +#define MGA_WARP_TGZ 0 +#define MGA_WARP_TGZF (MGA_F) +#define MGA_WARP_TGZA (MGA_A) +#define MGA_WARP_TGZAF (MGA_F|MGA_A) +#define MGA_WARP_TGZS (MGA_S) +#define MGA_WARP_TGZSF (MGA_S|MGA_F) +#define MGA_WARP_TGZSA (MGA_S|MGA_A) +#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A) +#define MGA_WARP_T2GZ (MGA_T2) +#define MGA_WARP_T2GZF (MGA_T2|MGA_F) +#define MGA_WARP_T2GZA (MGA_T2|MGA_A) +#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F) +#define MGA_WARP_T2GZS (MGA_T2|MGA_S) +#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F) +#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A) +#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A) + +#define MGA_MAX_G400_PIPES 16 +#define MGA_MAX_G200_PIPES 8 /* no multitex */ +#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES + +#define MGA_CARD_TYPE_G200 1 +#define MGA_CARD_TYPE_G400 2 + +#define MGA_FRONT 0x1 +#define MGA_BACK 0x2 +#define MGA_DEPTH 0x4 + +/* 3d state excluding texture units: + */ +#define MGA_CTXREG_DSTORG 0 /* validated */ +#define MGA_CTXREG_MACCESS 1 +#define MGA_CTXREG_PLNWT 2 +#define MGA_CTXREG_DWGCTL 3 +#define MGA_CTXREG_ALPHACTRL 4 +#define MGA_CTXREG_FOGCOLOR 5 +#define MGA_CTXREG_WFLAG 6 +#define MGA_CTXREG_TDUAL0 7 +#define MGA_CTXREG_TDUAL1 8 +#define MGA_CTXREG_FCOL 9 +#define MGA_CTX_SETUP_SIZE 10 + +/* 2d state + */ +#define MGA_2DREG_PITCH 0 +#define MGA_2D_SETUP_SIZE 1 + +/* Each texture unit has a state: + */ +#define MGA_TEXREG_CTL 0 +#define MGA_TEXREG_CTL2 1 +#define MGA_TEXREG_FILTER 2 +#define MGA_TEXREG_BORDERCOL 3 +#define MGA_TEXREG_ORG 4 /* validated */ +#define MGA_TEXREG_ORG1 5 +#define MGA_TEXREG_ORG2 6 +#define MGA_TEXREG_ORG3 7 +#define MGA_TEXREG_ORG4 8 +#define MGA_TEXREG_WIDTH 9 +#define MGA_TEXREG_HEIGHT 10 +#define MGA_TEX_SETUP_SIZE 11 + +/* What needs to be changed for the current vertex dma buffer? + */ +#define MGA_UPLOAD_CTX 0x1 +#define MGA_UPLOAD_TEX0 0x2 +#define MGA_UPLOAD_TEX1 0x4 +#define MGA_UPLOAD_PIPE 0x8 +#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */ +#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */ +#define MGA_UPLOAD_2D 0x40 +#define MGA_WAIT_AGE 0x80 /* handled client-side */ +#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */ +#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock + quiescent */ + +/* 32 buffers of 64k each, total 2 meg. + */ +#define MGA_DMA_BUF_ORDER 16 +#define MGA_DMA_BUF_SZ (1<<MGA_DMA_BUF_ORDER) +#define MGA_DMA_BUF_NR 31 + +/* Keep these small for testing. + */ +#define MGA_NR_SAREA_CLIPRECTS 8 + +/* 2 heaps (1 for card, 1 for agp), each divided into upto 128 + * regions, subject to a minimum region size of (1<<16) == 64k. + * + * Clients may subdivide regions internally, but when sharing between + * clients, the region size is the minimum granularity. + */ + +#define MGA_CARD_HEAP 0 +#define MGA_AGP_HEAP 1 +#define MGA_NR_TEX_HEAPS 2 +#define MGA_NR_TEX_REGIONS 16 +#define MGA_LOG_MIN_TEX_REGION_SIZE 16 +#endif + +typedef struct _drm_mga_warp_index { + int installed; + unsigned long phys_addr; + int size; +} drm_mga_warp_index_t; + +typedef struct drm_mga_init { + enum { + MGA_INIT_DMA = 0x01, + MGA_CLEANUP_DMA = 0x02 + } func; + int reserved_map_agpstart; + int reserved_map_idx; + int buffer_map_idx; + int sarea_priv_offset; + int primary_size; + int warp_ucode_size; + unsigned int frontOffset; + unsigned int backOffset; + unsigned int depthOffset; + unsigned int textureOffset; + unsigned int textureSize; + unsigned int agpTextureOffset; + unsigned int agpTextureSize; + unsigned int cpp; + unsigned int stride; + int sgram; + int chipset; + drm_mga_warp_index_t WarpIndex[MGA_MAX_WARP_PIPES]; + unsigned int mAccess; +} drm_mga_init_t; + +/* Warning: if you change the sarea structure, you must change the Xserver + * structures as well */ + +typedef struct _drm_mga_tex_region { + unsigned char next, prev; + unsigned char in_use; + unsigned int age; +} drm_mga_tex_region_t; + +typedef struct _drm_mga_sarea { + /* The channel for communication of state information to the kernel + * on firing a vertex dma buffer. + */ + unsigned int ContextState[MGA_CTX_SETUP_SIZE]; + unsigned int ServerState[MGA_2D_SETUP_SIZE]; + unsigned int TexState[2][MGA_TEX_SETUP_SIZE]; + unsigned int WarpPipe; + unsigned int dirty; + + unsigned int nbox; + drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS]; + + + /* Information about the most recently used 3d drawable. The + * client fills in the req_* fields, the server fills in the + * exported_ fields and puts the cliprects into boxes, above. + * + * The client clears the exported_drawable field before + * clobbering the boxes data. + */ + unsigned int req_drawable; /* the X drawable id */ + unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */ + + unsigned int exported_drawable; + unsigned int exported_index; + unsigned int exported_stamp; + unsigned int exported_buffers; + unsigned int exported_nfront; + unsigned int exported_nback; + int exported_back_x, exported_front_x, exported_w; + int exported_back_y, exported_front_y, exported_h; + drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS]; + + /* Counters for aging textures and for client-side throttling. + */ + unsigned int last_enqueue; /* last time a buffer was enqueued */ + unsigned int last_dispatch; /* age of the most recently dispatched buffer */ + unsigned int last_quiescent; /* */ + + + /* LRU lists for texture memory in agp space and on the card + */ + drm_mga_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1]; + unsigned int texAge[MGA_NR_TEX_HEAPS]; + + /* Mechanism to validate card state. + */ + int ctxOwner; +} drm_mga_sarea_t; + +/* Device specific ioctls: + */ +typedef struct _drm_mga_clear { + unsigned int clear_color; + unsigned int clear_depth; + unsigned int flags; +} drm_mga_clear_t; + +typedef struct _drm_mga_swap { + int dummy; +} drm_mga_swap_t; + +typedef struct _drm_mga_iload { + int idx; + int length; + unsigned int destOrg; +} drm_mga_iload_t; + +typedef struct _drm_mga_vertex { + int idx; /* buffer to queue */ + int used; /* bytes in use */ + int discard; /* client finished with buffer? */ +} drm_mga_vertex_t; + +typedef struct _drm_mga_indices { + int idx; /* buffer to queue */ + unsigned int start; + unsigned int end; + int discard; /* client finished with buffer? */ +} drm_mga_indices_t; + +#endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c index 8bc25617e..4b2c835fa 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c @@ -2,6 +2,7 @@ * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,10 +24,9 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Jeff Hartmann <jhartmann@precisioninsight.com> + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c,v 1.1 2000/02/11 17:26:07 dawes Exp $ * */ @@ -39,9 +39,9 @@ EXPORT_SYMBOL(mga_cleanup); #define MGA_NAME "mga" #define MGA_DESC "Matrox g200/g400" #define MGA_DATE "19991213" -#define MGA_MAJOR 0 +#define MGA_MAJOR 1 #define MGA_MINOR 0 -#define MGA_PATCHLEVEL 1 +#define MGA_PATCHLEVEL 0 static drm_device_t mga_device; drm_ctx_t mga_res_ctx; @@ -54,6 +54,7 @@ static struct file_operations mga_fops = { mmap: drm_mmap, read: drm_read, fasync: drm_fasync, + poll: drm_poll, }; static struct miscdevice mga_misc = { @@ -105,9 +106,12 @@ static drm_ioctl_desc_t mga_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 }, [DRM_IOCTL_NR(DRM_IOCTL_MGA_INIT)] = { mga_dma_init, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MGA_SWAP)] = { mga_clear_bufs, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MGA_CLEAR)] = { mga_swap_bufs, 1, 1 }, - [DRM_IOCTL_NR(DRM_IOCTL_MGA_ILOAD)] = { mga_iload, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MGA_SWAP)] = { mga_swap_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_MGA_CLEAR)] = { mga_clear_bufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_MGA_ILOAD)] = { mga_iload, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_MGA_VERTEX)] = { mga_vertex, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_MGA_FLUSH)] = { mga_flush_ioctl, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_MGA_INDICES)] = { mga_indices, 1, 0 }, }; #define MGA_IOCTL_COUNT DRM_ARRAY_SIZE(mga_ioctls) @@ -380,6 +384,21 @@ int mga_init(void) drm_proc_init(dev); DRM_DEBUG("doing agp init\n"); dev->agp = drm_agp_init(); + if(dev->agp == NULL) { + DRM_INFO("The mga drm module requires the agpgart module" + " to function correctly\nPlease load the agpgart" + " module before you load the mga module\n"); + drm_proc_cleanup(); + misc_deregister(&mga_misc); + mga_takedown(dev); + return -ENOMEM; + } +#ifdef CONFIG_MTRR + dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base, + dev->agp->agp_info.aper_size * 1024 * 1024, + MTRR_TYPE_WRCOMB, + 1); +#endif DRM_DEBUG("doing ctxbitmap init\n"); if((retcode = drm_ctxbitmap_init(dev))) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); @@ -416,6 +435,16 @@ void mga_cleanup(void) } drm_ctxbitmap_cleanup(dev); mga_dma_cleanup(dev); +#ifdef CONFIG_MTRR + if(dev->agp && dev->agp->agp_mtrr) { + int retval; + retval = mtrr_del(dev->agp->agp_mtrr, + dev->agp->agp_info.aper_base, + dev->agp->agp_info.aper_size * 1024*1024); + DRM_DEBUG("mtrr_del = %d\n", retval); + } +#endif + mga_takedown(dev); if (dev->agp) { drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); @@ -482,27 +511,86 @@ int mga_release(struct inode *inode, struct file *filp) drm_device_t *dev = priv->dev; int retcode = 0; - DRM_DEBUG("open_count = %d\n", dev->open_count); - if (!(retcode = drm_release(inode, filp))) { - MOD_DEC_USE_COUNT; - atomic_inc(&dev->total_close); - spin_lock(&dev->count_lock); - if (!--dev->open_count) { - if (atomic_read(&dev->ioctl_count) || dev->blocked) { - DRM_ERROR("Device busy: %d %d\n", - atomic_read(&dev->ioctl_count), - dev->blocked); - spin_unlock(&dev->count_lock); - return -EBUSY; + DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n", + current->pid, dev->device, dev->open_count); + + if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) + && dev->lock.pid == current->pid) { + mga_reclaim_buffers(dev, priv->pid); + DRM_ERROR("Process %d dead, freeing lock for context %d\n", + current->pid, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + drm_lock_free(dev, + &dev->lock.hw_lock->lock, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + + /* FIXME: may require heavy-handed reset of + hardware at this point, possibly + processed via a callback to the X + server. */ + } else if (dev->lock.hw_lock) { + /* The lock is required to reclaim buffers */ + DECLARE_WAITQUEUE(entry, current); + add_wait_queue(&dev->lock.lock_queue, &entry); + for (;;) { + if (!dev->lock.hw_lock) { + /* Device has been unregistered */ + retcode = -EINTR; + break; + } + if (drm_lock_take(&dev->lock.hw_lock->lock, + DRM_KERNEL_CONTEXT)) { + dev->lock.pid = priv->pid; + dev->lock.lock_time = jiffies; + atomic_inc(&dev->total_locks); + break; /* Got lock */ + } + /* Contention */ + atomic_inc(&dev->total_sleeps); + current->state = TASK_INTERRUPTIBLE; + schedule(); + if (signal_pending(current)) { + retcode = -ERESTARTSYS; + break; } - spin_unlock(&dev->count_lock); - return mga_takedown(dev); } - spin_unlock(&dev->count_lock); + current->state = TASK_RUNNING; + remove_wait_queue(&dev->lock.lock_queue, &entry); + if(!retcode) { + mga_reclaim_buffers(dev, priv->pid); + drm_lock_free(dev, &dev->lock.hw_lock->lock, + DRM_KERNEL_CONTEXT); + } } + drm_fasync(-1, filp, 0); + + down(&dev->struct_sem); + if (priv->prev) priv->prev->next = priv->next; + else dev->file_first = priv->next; + if (priv->next) priv->next->prev = priv->prev; + else dev->file_last = priv->prev; + up(&dev->struct_sem); + + drm_free(priv, sizeof(*priv), DRM_MEM_FILES); + MOD_DEC_USE_COUNT; + atomic_inc(&dev->total_close); + spin_lock(&dev->count_lock); + if (!--dev->open_count) { + if (atomic_read(&dev->ioctl_count) || dev->blocked) { + DRM_ERROR("Device busy: %d %d\n", + atomic_read(&dev->ioctl_count), + dev->blocked); + spin_unlock(&dev->count_lock); + return -EBUSY; + } + spin_unlock(&dev->count_lock); + return mga_takedown(dev); + } + spin_unlock(&dev->count_lock); return retcode; } + /* drm_ioctl is called whenever a process performs an ioctl on /dev/drm. */ int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h index bc7808b0a..f217acb97 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h @@ -2,6 +2,7 @@ * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,51 +24,81 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> - * Jeff Hartmann <jhartmann@precisioninsight.com> + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Jeff Hartmann <jhartmann@valinux.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h,v 1.1 2000/02/11 17:26:08 dawes Exp $ */ #ifndef _MGA_DRV_H_ #define _MGA_DRV_H_ -#include "mga_drm_public.h" + +#define MGA_BUF_IN_USE 0 +#define MGA_BUF_SWAP_PENDING 1 +#define MGA_BUF_FORCE_FIRE 2 +#define MGA_BUF_NEEDS_OVERFLOW 3 + +typedef struct { + u32 buffer_status; + unsigned int num_dwords; + unsigned int max_dwords; + u32 *current_dma_ptr; + u32 *head; + u32 phys_head; + unsigned int prim_age; + int sec_used; + int idx; +} drm_mga_prim_buf_t; + +typedef struct _drm_mga_freelist { + unsigned int age; + drm_buf_t *buf; + struct _drm_mga_freelist *next; + struct _drm_mga_freelist *prev; +} drm_mga_freelist_t; + +#define MGA_IN_DISPATCH 0 +#define MGA_IN_FLUSH 1 +#define MGA_IN_WAIT 2 +#define MGA_IN_GETBUF 3 typedef struct _drm_mga_private { + u32 dispatch_status; + unsigned int next_prim_age; + __volatile__ unsigned int last_prim_age; int reserved_map_idx; int buffer_map_idx; drm_mga_sarea_t *sarea_priv; int primary_size; int warp_ucode_size; int chipset; - int fbOffset; - int backOffset; - int depthOffset; - int textureOffset; - int textureSize; + unsigned int frontOffset; + unsigned int backOffset; + unsigned int depthOffset; + unsigned int textureOffset; + unsigned int textureSize; int cpp; - int stride; + unsigned int stride; int sgram; int use_agp; - mgaWarpIndex WarpIndex[MGA_MAX_G400_PIPES]; - __volatile__ unsigned long softrap_age; - atomic_t dispatch_lock; + drm_mga_warp_index_t WarpIndex[MGA_MAX_G400_PIPES]; + unsigned int WarpPipe; atomic_t pending_bufs; - void *ioremap; - u32 *prim_head; - u32 *current_dma_ptr; - u32 prim_phys_head; - int prim_num_dwords; - int prim_max_dwords; - - + void *status_page; + unsigned long real_status_page; + u8 *ioremap; + drm_mga_prim_buf_t **prim_bufs; + drm_mga_prim_buf_t *next_prim; + drm_mga_prim_buf_t *last_prim; + drm_mga_prim_buf_t *current_prim; + int current_prim_idx; + drm_mga_freelist_t *head; + drm_mga_freelist_t *tail; + wait_queue_head_t flush_queue; /* Processes waiting until flush */ + wait_queue_head_t wait_queue; /* Processes waiting until interrupt */ + wait_queue_head_t buf_queue; /* Processes waiting for a free buf */ /* Some validated register values: */ - u32 frontOrg; - u32 backOrg; - u32 depthOrg; u32 mAccess; - } drm_mga_private_t; /* mga_drv.c */ @@ -92,16 +123,19 @@ extern int mga_control(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); -#if 0 -extern void mga_dma_init(drm_device_t *dev); -extern void mga_dma_cleanup(drm_device_t *dev); -#endif +/* mga_dma_init does init and release */ extern int mga_dma_init(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int mga_dma_cleanup(drm_device_t *dev); - -/* mga_dma_init does init and release */ +extern int mga_flush_ioctl(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern void mga_flush_write_combine(void); +extern unsigned int mga_create_sync_tag(drm_device_t *dev); +extern drm_buf_t *mga_freelist_get(drm_device_t *dev); +extern int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf); +extern int mga_advance_primary(drm_device_t *dev); +extern void mga_reclaim_buffers(drm_device_t *dev, pid_t pid); /* mga_bufs.c */ @@ -124,6 +158,10 @@ extern int mga_swap_bufs(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); extern int mga_iload(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); +extern int mga_vertex(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); +extern int mga_indices(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg); /* mga_context.c */ extern int mga_resctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg); @@ -144,13 +182,124 @@ extern int mga_context_switch(drm_device_t *dev, int old, int new); extern int mga_context_switch_complete(drm_device_t *dev, int new); +typedef enum { + TT_GENERAL, + TT_BLIT, + TT_VECTOR, + TT_VERTEX +} transferType_t; + +typedef struct { + drm_mga_freelist_t *my_freelist; + int discard; + int dispatched; +} drm_mga_buf_priv_t; + +#define DWGREG0 0x1c00 +#define DWGREG0_END 0x1dff +#define DWGREG1 0x2c00 +#define DWGREG1_END 0x2dff + +#define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END) +#define ADRINDEX0(r) (u8)((r - DWGREG0) >> 2) +#define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80) +#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r)) + +#define MGA_VERBOSE 0 +#define MGA_NUM_PRIM_BUFS 8 + +#define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \ + int outcount, num_dwords + +#define PRIM_OVERFLOW(dev, dev_priv, length) do { \ + drm_mga_prim_buf_t *tmp_buf = \ + dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \ + &tmp_buf->buffer_status)) { \ + mga_advance_primary(dev); \ + mga_dma_schedule(dev, 1); \ + } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length ||\ + tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \ + set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \ + mga_advance_primary(dev); \ + mga_dma_schedule(dev, 1); \ + } \ +} while(0) + +#define PRIMGETPTR(dev_priv) do { \ + drm_mga_prim_buf_t *tmp_buf = \ + dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + if(MGA_VERBOSE) \ + DRM_DEBUG("PRIMGETPTR in %s\n", __FUNCTION__); \ + dma_ptr = tmp_buf->current_dma_ptr; \ + num_dwords = tmp_buf->num_dwords; \ + phys_head = tmp_buf->phys_head; \ + outcount = 0; \ +} while(0) + +#define PRIMPTR(prim_buf) do { \ + if(MGA_VERBOSE) \ + DRM_DEBUG("PRIMPTR in %s\n", __FUNCTION__); \ + dma_ptr = prim_buf->current_dma_ptr; \ + num_dwords = prim_buf->num_dwords; \ + phys_head = prim_buf->phys_head; \ + outcount = 0; \ +} while(0) + +#define PRIMFINISH(prim_buf) do { \ + if (MGA_VERBOSE) { \ + DRM_DEBUG( "PRIMFINISH in %s\n", __FUNCTION__); \ + if (outcount & 3) \ + DRM_DEBUG(" --- truncation\n"); \ + } \ + prim_buf->num_dwords = num_dwords; \ + prim_buf->current_dma_ptr = dma_ptr; \ +} while(0) + +#define PRIMADVANCE(dev_priv) do { \ +drm_mga_prim_buf_t *tmp_buf = \ + dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + if (MGA_VERBOSE) { \ + DRM_DEBUG("PRIMADVANCE in %s\n", __FUNCTION__); \ + if (outcount & 3) \ + DRM_DEBUG(" --- truncation\n"); \ + } \ + tmp_buf->num_dwords = num_dwords; \ + tmp_buf->current_dma_ptr = dma_ptr; \ +} while (0) + +#define PRIMUPDATE(dev_priv) do { \ + drm_mga_prim_buf_t *tmp_buf = \ + dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + tmp_buf->sec_used++; \ +} while (0) + +#define AGEBUF(dev_priv, buf_priv) do { \ + drm_mga_prim_buf_t *tmp_buf = \ + dev_priv->prim_bufs[dev_priv->current_prim_idx]; \ + buf_priv->my_freelist->age = tmp_buf->prim_age; \ +} while (0) + + +#define PRIMOUTREG(reg, val) do { \ + tempIndex[outcount]=ADRINDEX(reg); \ + dma_ptr[1+outcount] = val; \ + if (MGA_VERBOSE) \ + DRM_DEBUG(" PRIMOUT %d: 0x%x -- 0x%x\n", \ + num_dwords + 1 + outcount, ADRINDEX(reg), val); \ + if( ++outcount == 4) { \ + outcount = 0; \ + dma_ptr[0] = *(u32 *)tempIndex; \ + dma_ptr+=5; \ + num_dwords += 5; \ + } \ +}while (0) + +/* A reduced set of the mga registers. + */ #define MGAREG_MGA_EXEC 0x0100 -#define MGAREG_AGP_PLL 0x1e4c #define MGAREG_ALPHACTRL 0x2c7c -#define MGAREG_ALPHASTART 0x2c70 -#define MGAREG_ALPHAXINC 0x2c74 -#define MGAREG_ALPHAYINC 0x2c78 #define MGAREG_AR0 0x1c60 #define MGAREG_AR1 0x1c64 #define MGAREG_AR2 0x1c68 @@ -158,39 +307,16 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new); #define MGAREG_AR4 0x1c70 #define MGAREG_AR5 0x1c74 #define MGAREG_AR6 0x1c78 -#define MGAREG_BCOL 0x1c20 #define MGAREG_CXBNDRY 0x1c80 #define MGAREG_CXLEFT 0x1ca0 #define MGAREG_CXRIGHT 0x1ca4 #define MGAREG_DMAPAD 0x1c54 -#define MGAREG_DR0_Z32LSB 0x2c50 -#define MGAREG_DR0_Z32MSB 0x2c54 -#define MGAREG_DR2_Z32LSB 0x2c60 -#define MGAREG_DR2_Z32MSB 0x2c64 -#define MGAREG_DR3_Z32LSB 0x2c68 -#define MGAREG_DR3_Z32MSB 0x2c6c -#define MGAREG_DR0 0x1cc0 -#define MGAREG_DR2 0x1cc8 -#define MGAREG_DR3 0x1ccc -#define MGAREG_DR4 0x1cd0 -#define MGAREG_DR6 0x1cd8 -#define MGAREG_DR7 0x1cdc -#define MGAREG_DR8 0x1ce0 -#define MGAREG_DR10 0x1ce8 -#define MGAREG_DR11 0x1cec -#define MGAREG_DR12 0x1cf0 -#define MGAREG_DR14 0x1cf8 -#define MGAREG_DR15 0x1cfc #define MGAREG_DSTORG 0x2cb8 -#define MGAREG_DWG_INDIR_WT 0x1e80 #define MGAREG_DWGCTL 0x1c00 #define MGAREG_DWGSYNC 0x2c4c #define MGAREG_FCOL 0x1c24 #define MGAREG_FIFOSTATUS 0x1e10 #define MGAREG_FOGCOL 0x1cf4 -#define MGAREG_FOGSTART 0x1cc4 -#define MGAREG_FOGXINC 0x1cd4 -#define MGAREG_FOGYINC 0x1ce4 #define MGAREG_FXBNDRY 0x1c84 #define MGAREG_FXLEFT 0x1ca8 #define MGAREG_FXRIGHT 0x1cac @@ -198,44 +324,22 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new); #define MGAREG_IEN 0x1e1c #define MGAREG_LEN 0x1c5c #define MGAREG_MACCESS 0x1c04 -#define MGAREG_MCTLWTST 0x1c08 -#define MGAREG_MEMRDBK 0x1e44 -#define MGAREG_OPMODE 0x1e54 -#define MGAREG_PAT0 0x1c10 -#define MGAREG_PAT1 0x1c14 #define MGAREG_PITCH 0x1c8c #define MGAREG_PLNWT 0x1c1c #define MGAREG_PRIMADDRESS 0x1e58 #define MGAREG_PRIMEND 0x1e5c #define MGAREG_PRIMPTR 0x1e50 -#define MGAREG_RST 0x1e40 #define MGAREG_SECADDRESS 0x2c40 #define MGAREG_SECEND 0x2c44 #define MGAREG_SETUPADDRESS 0x2cd0 #define MGAREG_SETUPEND 0x2cd4 -#define MGAREG_SGN 0x1c58 -#define MGAREG_SHIFT 0x1c50 #define MGAREG_SOFTRAP 0x2c48 -#define MGAREG_SPECBSTART 0x2c98 -#define MGAREG_SPECBXINC 0x2c9c -#define MGAREG_SPECBYINC 0x2ca0 -#define MGAREG_SPECGSTART 0x2c8c -#define MGAREG_SPECGXINC 0x2c90 -#define MGAREG_SPECGYINC 0x2c94 -#define MGAREG_SPECRSTART 0x2c80 -#define MGAREG_SPECRXINC 0x2c84 -#define MGAREG_SPECRYINC 0x2c88 -#define MGAREG_SRC0 0x1c30 -#define MGAREG_SRC1 0x1c34 -#define MGAREG_SRC2 0x1c38 -#define MGAREG_SRC3 0x1c3c #define MGAREG_SRCORG 0x2cb4 #define MGAREG_STATUS 0x1e14 #define MGAREG_STENCIL 0x2cc8 #define MGAREG_STENCILCTL 0x2ccc #define MGAREG_TDUALSTAGE0 0x2cf8 #define MGAREG_TDUALSTAGE1 0x2cfc -#define MGAREG_TEST0 0x1e48 #define MGAREG_TEXBORDERCOL 0x2c5c #define MGAREG_TEXCTL 0x2c30 #define MGAREG_TEXCTL2 0x2c3c @@ -249,18 +353,6 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new); #define MGAREG_TEXTRANS 0x2c34 #define MGAREG_TEXTRANSHIGH 0x2c38 #define MGAREG_TEXWIDTH 0x2c28 -#define MGAREG_TMR0 0x2c00 -#define MGAREG_TMR1 0x2c04 -#define MGAREG_TMR2 0x2c08 -#define MGAREG_TMR3 0x2c0c -#define MGAREG_TMR4 0x2c10 -#define MGAREG_TMR5 0x2c14 -#define MGAREG_TMR6 0x2c18 -#define MGAREG_TMR7 0x2c1c -#define MGAREG_TMR8 0x2c20 -#define MGAREG_VBIADDR0 0x3e08 -#define MGAREG_VBIADDR1 0x3e0c -#define MGAREG_VCOUNT 0x1e20 #define MGAREG_WACCEPTSEQ 0x1dd4 #define MGAREG_WCODEADDR 0x1e6c #define MGAREG_WFLAG 0x1dc4 @@ -270,18 +362,8 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new); #define MGAREG_WGETMSB 0x1dc8 #define MGAREG_WIADDR 0x1dc0 #define MGAREG_WIADDR2 0x1dd8 -#define MGAREG_WIADDRNB 0x1e60 -#define MGAREG_WIADDRNB1 0x1e04 -#define MGAREG_WIADDRNB2 0x1e00 -#define MGAREG_WIMEMADDR 0x1e68 -#define MGAREG_WIMEMDATA 0x2000 -#define MGAREG_WIMEMDATA1 0x2100 #define MGAREG_WMISC 0x1e70 -#define MGAREG_WR 0x2d00 #define MGAREG_WVRTXSZ 0x1dcc -#define MGAREG_XDST 0x1cb0 -#define MGAREG_XYEND 0x1c44 -#define MGAREG_XYSTRT 0x1c40 #define MGAREG_YBOT 0x1c9c #define MGAREG_YDST 0x1c90 #define MGAREG_YDSTLEN 0x1c88 @@ -289,4 +371,77 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new); #define MGAREG_YTOP 0x1c98 #define MGAREG_ZORG 0x1c0c +#define PDEA_pagpxfer_enable 0x2 + +#define WIA_wmode_suspend 0x0 +#define WIA_wmode_start 0x3 +#define WIA_wagp_agp 0x4 + +#define DC_opcod_line_open 0x0 +#define DC_opcod_autoline_open 0x1 +#define DC_opcod_line_close 0x2 +#define DC_opcod_autoline_close 0x3 +#define DC_opcod_trap 0x4 +#define DC_opcod_texture_trap 0x6 +#define DC_opcod_bitblt 0x8 +#define DC_opcod_iload 0x9 +#define DC_atype_rpl 0x0 +#define DC_atype_rstr 0x10 +#define DC_atype_zi 0x30 +#define DC_atype_blk 0x40 +#define DC_atype_i 0x70 +#define DC_linear_xy 0x0 +#define DC_linear_linear 0x80 +#define DC_zmode_nozcmp 0x0 +#define DC_zmode_ze 0x200 +#define DC_zmode_zne 0x300 +#define DC_zmode_zlt 0x400 +#define DC_zmode_zlte 0x500 +#define DC_zmode_zgt 0x600 +#define DC_zmode_zgte 0x700 +#define DC_solid_disable 0x0 +#define DC_solid_enable 0x800 +#define DC_arzero_disable 0x0 +#define DC_arzero_enable 0x1000 +#define DC_sgnzero_disable 0x0 +#define DC_sgnzero_enable 0x2000 +#define DC_shftzero_disable 0x0 +#define DC_shftzero_enable 0x4000 +#define DC_bop_SHIFT 16 +#define DC_trans_SHIFT 20 +#define DC_bltmod_bmonolef 0x0 +#define DC_bltmod_bmonowf 0x8000000 +#define DC_bltmod_bplan 0x2000000 +#define DC_bltmod_bfcol 0x4000000 +#define DC_bltmod_bu32bgr 0x6000000 +#define DC_bltmod_bu32rgb 0xe000000 +#define DC_bltmod_bu24bgr 0x16000000 +#define DC_bltmod_bu24rgb 0x1e000000 +#define DC_pattern_disable 0x0 +#define DC_pattern_enable 0x20000000 +#define DC_transc_disable 0x0 +#define DC_transc_enable 0x40000000 +#define DC_clipdis_disable 0x0 +#define DC_clipdis_enable 0x80000000 + +#define SETADD_mode_vertlist 0x0 + + +#define MGA_CLEAR_CMD (DC_opcod_trap | DC_arzero_enable | \ + DC_sgnzero_enable | DC_shftzero_enable | \ + (0xC << DC_bop_SHIFT) | DC_clipdis_enable | \ + DC_solid_enable | DC_transc_enable) + + +#define MGA_COPY_CMD (DC_opcod_bitblt | DC_atype_rpl | DC_linear_xy | \ + DC_solid_disable | DC_arzero_disable | \ + DC_sgnzero_enable | DC_shftzero_enable | \ + (0xC << DC_bop_SHIFT) | DC_bltmod_bfcol | \ + DC_pattern_disable | DC_transc_disable | \ + DC_clipdis_enable) \ + +#define MGA_FLUSH_CMD (DC_opcod_texture_trap | (0xF << DC_trans_SHIFT) |\ + DC_arzero_enable | DC_sgnzero_enable | \ + DC_atype_i) + #endif diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c index d09881bad..c9c6ef3df 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c @@ -2,6 +2,7 @@ * Created: Thu Jan 27 02:53:43 2000 by jhartmann@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -26,337 +27,1038 @@ * Authors: Jeff Hartmann <jhartmann@precisioninsight.com> * Keith Whitwell <keithw@precisioninsight.com> * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c,v 1.1 2000/02/11 17:26:08 dawes Exp $ - * */ - + #define __NO_VERSION__ #include "drmP.h" #include "mga_drv.h" -#include "mgareg_flags.h" -#include "mga_dma.h" -#include "mga_state.h" #include "drm.h" -void mgaEmitClipRect( drm_mga_private_t *dev_priv, xf86drmClipRectRec *box ) +static void mgaEmitClipRect(drm_mga_private_t * dev_priv, + drm_clip_rect_t * box) { + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int *regs = sarea_priv->ContextState; PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); - PRIMGETPTR( dev_priv ); + /* This takes 10 dwords */ + PRIMGETPTR(dev_priv); - /* The G400 seems to have an issue with the second WARP not - * stalling clipper register writes. This bothers me, but the only - * way I could get it to never clip the last triangle under any - * circumstances is by inserting TWO dwgsync commands. - */ - if (dev_priv->chipset == MGA_CARD_TYPE_G400) { - PRIMOUTREG( MGAREG_DWGSYNC, 0 ); - PRIMOUTREG( MGAREG_DWGSYNC, 0 ); - } + /* Force reset of dwgctl (eliminates clip disable) */ +#if 0 + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); +#else + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000); +#endif - PRIMOUTREG( MGAREG_CXBNDRY, ((box->x2)<<16)|(box->x1) ); - PRIMOUTREG( MGAREG_YTOP, box->y1 * dev_priv->stride ); - PRIMOUTREG( MGAREG_YBOT, box->y2 * dev_priv->stride ); - PRIMADVANCE( dev_priv ); -} + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_CXBNDRY, ((box->x2) << 16) | (box->x1)); + PRIMOUTREG(MGAREG_YTOP, box->y1 * dev_priv->stride / 2); + PRIMOUTREG(MGAREG_YBOT, box->y2 * dev_priv->stride / 2); + PRIMADVANCE(dev_priv); +} -static void mgaEmitContext(drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv) +static void mgaEmitContext(drm_mga_private_t * dev_priv) { - unsigned int *regs = buf_priv->ContextState; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int *regs = sarea_priv->ContextState; PRIMLOCALS; - - PRIMGETPTR( dev_priv ); - PRIMOUTREG( MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG] ); - PRIMOUTREG( MGAREG_MACCESS, regs[MGA_CTXREG_MACCESS] ); - PRIMOUTREG( MGAREG_PLNWT, regs[MGA_CTXREG_PLNWT] ); - PRIMOUTREG( MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL] ); - PRIMOUTREG( MGAREG_ALPHACTRL, regs[MGA_CTXREG_ALPHACTRL] ); - PRIMOUTREG( MGAREG_FOGCOL, regs[MGA_CTXREG_FOGCOLOR] ); - PRIMOUTREG( MGAREG_WFLAG, regs[MGA_CTXREG_WFLAG] ); - - if (dev_priv->chipset == MGA_CARD_TYPE_G400) { - PRIMOUTREG( MGAREG_WFLAG1, regs[MGA_CTXREG_WFLAG] ); - PRIMOUTREG( MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0] ); - PRIMOUTREG( MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1] ); - } - - PRIMADVANCE( dev_priv ); + DRM_DEBUG("%s\n", __FUNCTION__); + + /* This takes a max of 15 dwords */ + PRIMGETPTR(dev_priv); + + PRIMOUTREG(MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG]); + PRIMOUTREG(MGAREG_MACCESS, regs[MGA_CTXREG_MACCESS]); + PRIMOUTREG(MGAREG_PLNWT, regs[MGA_CTXREG_PLNWT]); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + + PRIMOUTREG(MGAREG_ALPHACTRL, regs[MGA_CTXREG_ALPHACTRL]); + PRIMOUTREG(MGAREG_FOGCOL, regs[MGA_CTXREG_FOGCOLOR]); + PRIMOUTREG(MGAREG_WFLAG, regs[MGA_CTXREG_WFLAG]); + PRIMOUTREG(MGAREG_ZORG, dev_priv->depthOffset); /* invarient */ + + if (dev_priv->chipset == MGA_CARD_TYPE_G400) { + PRIMOUTREG(MGAREG_WFLAG1, regs[MGA_CTXREG_WFLAG]); + PRIMOUTREG(MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0]); + PRIMOUTREG(MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1]); + PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]); + } else { + PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + } + + PRIMADVANCE(dev_priv); } -static void mgaG200EmitTex( drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv ) +static void mgaG200EmitTex(drm_mga_private_t * dev_priv) { - unsigned int *regs = buf_priv->TexState[0]; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int *regs = sarea_priv->TexState[0]; PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); + + PRIMGETPTR(dev_priv); + + /* This takes 20 dwords */ + + PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2]); + PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]); + PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]); + PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]); + + PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]); + PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]); + PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]); + PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]); + + PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); + PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); + PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); + PRIMOUTREG(0x2d00 + 24 * 4, regs[MGA_TEXREG_WIDTH]); - PRIMGETPTR( dev_priv ); - PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] ); - PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL] ); - PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER] ); - PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL] ); - PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG] ); - PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1] ); - PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2] ); - PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3] ); - PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4] ); - PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH] ); - PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT] ); - - PRIMOUTREG(0x2d00 + 24*4, regs[MGA_TEXREG_WIDTH] ); - PRIMOUTREG(0x2d00 + 34*4, regs[MGA_TEXREG_HEIGHT] ); - - PRIMADVANCE( dev_priv ); + PRIMOUTREG(0x2d00 + 34 * 4, regs[MGA_TEXREG_HEIGHT]); + PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); + PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); + PRIMOUTREG(MGAREG_DMAPAD, 0); + + PRIMADVANCE(dev_priv); } -static void mgaG400EmitTex0( drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv ) +static void mgaG400EmitTex0(drm_mga_private_t * dev_priv) { - unsigned int *regs = buf_priv->TexState[0]; - int multitex = buf_priv->WarpPipe & MGA_T2; - + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int *regs = sarea_priv->TexState[0]; + int multitex = sarea_priv->WarpPipe & MGA_T2; PRIMLOCALS; - PRIMGETPTR( dev_priv ); - - PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] ); - PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL] ); - PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER] ); - PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL] ); - PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG] ); - PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1] ); - PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2] ); - PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3] ); - PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4] ); - PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH] ); - PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT] ); - - PRIMOUTREG(0x2d00 + 49*4, 0); - PRIMOUTREG(0x2d00 + 57*4, 0); - PRIMOUTREG(0x2d00 + 53*4, 0); - PRIMOUTREG(0x2d00 + 61*4, 0); + DRM_DEBUG("%s\n", __FUNCTION__); + + PRIMGETPTR(dev_priv); + + /* This takes a max of 30 dwords */ + + PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000); + PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]); + PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]); + PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]); + + PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]); + PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]); + PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]); + PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]); + + PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); + PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); + PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); + PRIMOUTREG(0x2d00 + 49 * 4, 0); + + PRIMOUTREG(0x2d00 + 57 * 4, 0); + PRIMOUTREG(0x2d00 + 53 * 4, 0); + PRIMOUTREG(0x2d00 + 61 * 4, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); if (!multitex) { - PRIMOUTREG(0x2d00 + 52*4, 0x40 ); - PRIMOUTREG(0x2d00 + 60*4, 0x40 ); - } + PRIMOUTREG(0x2d00 + 52 * 4, 0x40); + PRIMOUTREG(0x2d00 + 60 * 4, 0x40); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + } - PRIMOUTREG(0x2d00 + 54*4, regs[MGA_TEXREG_WIDTH] | 0x40 ); - PRIMOUTREG(0x2d00 + 62*4, regs[MGA_TEXREG_HEIGHT] | 0x40 ); + PRIMOUTREG(0x2d00 + 54 * 4, regs[MGA_TEXREG_WIDTH] | 0x40); + PRIMOUTREG(0x2d00 + 62 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40); + PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); + PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); - PRIMADVANCE( dev_priv ); + PRIMADVANCE(dev_priv); } -#define TMC_map1_enable 0x80000000 - +#define TMC_map1_enable 0x80000000 -static void mgaG400EmitTex1( drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv ) +static void mgaG400EmitTex1(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->TexState[1]; - PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); + PRIMGETPTR(dev_priv); - PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | TMC_map1_enable); - PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL] ); - PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER] ); - PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL] ); - PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG] ); - PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1] ); - PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2] ); - PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3] ); - PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4] ); - PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH] ); - PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT] ); - - PRIMOUTREG(0x2d00 + 49*4, 0); - PRIMOUTREG(0x2d00 + 57*4, 0); - PRIMOUTREG(0x2d00 + 53*4, 0); - PRIMOUTREG(0x2d00 + 61*4, 0); - - PRIMOUTREG(0x2d00 + 52*4, regs[MGA_TEXREG_WIDTH] | 0x40 ); - PRIMOUTREG(0x2d00 + 60*4, regs[MGA_TEXREG_HEIGHT] | 0x40 ); - - PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] ); - - PRIMADVANCE( dev_priv ); -} + /* This takes 25 dwords */ + + PRIMOUTREG(MGAREG_TEXCTL2, + regs[MGA_TEXREG_CTL2] | TMC_map1_enable | 0x00008000); + PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]); + PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]); + PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]); + + PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]); + PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]); + PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]); + PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]); + + PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]); + PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]); + PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]); + PRIMOUTREG(0x2d00 + 49 * 4, 0); + PRIMOUTREG(0x2d00 + 57 * 4, 0); + PRIMOUTREG(0x2d00 + 53 * 4, 0); + PRIMOUTREG(0x2d00 + 61 * 4, 0); + PRIMOUTREG(0x2d00 + 52 * 4, regs[MGA_TEXREG_WIDTH] | 0x40); -static void mgaG400EmitPipe(drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv) + PRIMOUTREG(0x2d00 + 60 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40); + PRIMOUTREG(MGAREG_TEXTRANS, 0xffff); + PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff); + PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000); + + PRIMADVANCE(dev_priv); +} + +#define EMIT_PIPE 50 +static void mgaG400EmitPipe(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int pipe = sarea_priv->WarpPipe; float fParam = 12800.0f; PRIMLOCALS; - + DRM_DEBUG("%s\n", __FUNCTION__); + PRIMGETPTR(dev_priv); - PRIMOUTREG(MGAREG_WIADDR2, WIA_wmode_suspend); - + + /* This takes 50 dwords */ + /* Establish vertex size. */ + PRIMOUTREG(MGAREG_WIADDR2, WIA_wmode_suspend); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + if (pipe & MGA_T2) { PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001e09); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + + PRIMOUTREG(MGAREG_WACCEPTSEQ, 0); + PRIMOUTREG(MGAREG_WACCEPTSEQ, 0); + PRIMOUTREG(MGAREG_WACCEPTSEQ, 0); PRIMOUTREG(MGAREG_WACCEPTSEQ, 0x1e000000); } else { + if (dev_priv->WarpPipe & MGA_T2) { + /* Flush the WARP pipe */ + PRIMOUTREG(MGAREG_YDST, 0); + PRIMOUTREG(MGAREG_FXLEFT, 0); + PRIMOUTREG(MGAREG_FXRIGHT, 1); + PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD); + + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGSYNC, 0x7000); + PRIMOUTREG(MGAREG_DMAPAD, 0); + + PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + PRIMOUTREG(MGAREG_TEXCTL2, 0x80 | 0x00008000); + PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0); + } + PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001807); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + + PRIMOUTREG(MGAREG_WACCEPTSEQ, 0); + PRIMOUTREG(MGAREG_WACCEPTSEQ, 0); + PRIMOUTREG(MGAREG_WACCEPTSEQ, 0); PRIMOUTREG(MGAREG_WACCEPTSEQ, 0x18000000); } - + PRIMOUTREG(MGAREG_WFLAG, 0); PRIMOUTREG(MGAREG_WFLAG1, 0); - - PRIMOUTREG(0x2d00 + 56*4, *((u32 *)(&fParam))); - PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(0x2d00 + 56 * 4, *((u32 *) (&fParam))); PRIMOUTREG(MGAREG_DMAPAD, 0); - - PRIMOUTREG(0x2d00 + 49*4, 0); /* Tex stage 0 */ - PRIMOUTREG(0x2d00 + 57*4, 0); /* Tex stage 0 */ - PRIMOUTREG(0x2d00 + 53*4, 0); /* Tex stage 1 */ - PRIMOUTREG(0x2d00 + 61*4, 0); /* Tex stage 1 */ - - PRIMOUTREG(0x2d00 + 54*4, 0x40); /* Tex stage 0 : w */ - PRIMOUTREG(0x2d00 + 62*4, 0x40); /* Tex stage 0 : h */ - PRIMOUTREG(0x2d00 + 52*4, 0x40); /* Tex stage 1 : w */ - PRIMOUTREG(0x2d00 + 60*4, 0x40); /* Tex stage 1 : h */ - + + PRIMOUTREG(0x2d00 + 49 * 4, 0); /* Tex stage 0 */ + PRIMOUTREG(0x2d00 + 57 * 4, 0); /* Tex stage 0 */ + PRIMOUTREG(0x2d00 + 53 * 4, 0); /* Tex stage 1 */ + PRIMOUTREG(0x2d00 + 61 * 4, 0); /* Tex stage 1 */ + + PRIMOUTREG(0x2d00 + 54 * 4, 0x40); /* Tex stage 0 : w */ + PRIMOUTREG(0x2d00 + 62 * 4, 0x40); /* Tex stage 0 : h */ + PRIMOUTREG(0x2d00 + 52 * 4, 0x40); /* Tex stage 1 : w */ + PRIMOUTREG(0x2d00 + 60 * 4, 0x40); /* Tex stage 1 : h */ + /* Dma pading required due to hw bug */ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); - PRIMOUTREG(MGAREG_WIADDR2, (dev_priv->WarpIndex[pipe].phys_addr | - WIA_wmode_start | WIA_wagp_agp)); + PRIMOUTREG(MGAREG_WIADDR2, + (u32) (dev_priv->WarpIndex[pipe]. + phys_addr | WIA_wmode_start | WIA_wagp_agp)); PRIMADVANCE(dev_priv); } -static void mgaG200EmitPipe( drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv ) +static void mgaG200EmitPipe(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int pipe = sarea_priv->WarpPipe; PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); PRIMGETPTR(dev_priv); + + /* This takes 15 dwords */ + PRIMOUTREG(MGAREG_WIADDR, WIA_wmode_suspend); PRIMOUTREG(MGAREG_WVRTXSZ, 7); PRIMOUTREG(MGAREG_WFLAG, 0); - PRIMOUTREG(0x2d00 + 24*4, 0); /* tex w/h */ - - PRIMOUTREG(0x2d00 + 25*4, 0x100); - PRIMOUTREG(0x2d00 + 34*4, 0); /* tex w/h */ - PRIMOUTREG(0x2d00 + 42*4, 0xFFFF); - PRIMOUTREG(0x2d00 + 60*4, 0xFFFF); - + PRIMOUTREG(0x2d00 + 24 * 4, 0); /* tex w/h */ + + PRIMOUTREG(0x2d00 + 25 * 4, 0x100); + PRIMOUTREG(0x2d00 + 34 * 4, 0); /* tex w/h */ + PRIMOUTREG(0x2d00 + 42 * 4, 0xFFFF); + PRIMOUTREG(0x2d00 + 60 * 4, 0xFFFF); + /* Dma pading required due to hw bug */ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff); - PRIMOUTREG(MGAREG_WIADDR, (dev_priv->WarpIndex[pipe].phys_addr | - WIA_wmode_start | WIA_wagp_agp)); + PRIMOUTREG(MGAREG_WIADDR, + (u32) (dev_priv->WarpIndex[pipe]. + phys_addr | WIA_wmode_start | WIA_wagp_agp)); - PRIMADVANCE(dev_priv); + PRIMADVANCE( dev_priv ); } -void mgaEmitState( drm_mga_private_t *dev_priv, drm_mga_buf_priv_t *buf_priv ) +static void mgaEmitState(drm_mga_private_t * dev_priv) { - unsigned int dirty = buf_priv->dirty; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int dirty = sarea_priv->dirty; + DRM_DEBUG("%s\n", __FUNCTION__); + + if (dev_priv->chipset == MGA_CARD_TYPE_G400) { + int multitex = sarea_priv->WarpPipe & MGA_T2; + + if (sarea_priv->WarpPipe != dev_priv->WarpPipe) { + mgaG400EmitPipe(dev_priv); + dev_priv->WarpPipe = sarea_priv->WarpPipe; + } - if (dev_priv->chipset == MGA_CARD_TYPE_G400) { - if (dirty & MGASAREA_NEW_CONTEXT) - mgaEmitContext( dev_priv, buf_priv ); + if (dirty & MGA_UPLOAD_CTX) { + mgaEmitContext(dev_priv); + sarea_priv->dirty &= ~MGA_UPLOAD_CTX; + } - if (dirty & MGASAREA_NEW_TEX1) - mgaG400EmitTex1( dev_priv, buf_priv ); - - if (dirty & MGASAREA_NEW_TEX0) - mgaG400EmitTex0( dev_priv, buf_priv ); + if (dirty & MGA_UPLOAD_TEX0) { + mgaG400EmitTex0(dev_priv); + sarea_priv->dirty &= ~MGA_UPLOAD_TEX0; + } - if (dirty & MGASAREA_NEW_PIPE) - mgaG400EmitPipe( dev_priv, buf_priv ); + if ((dirty & MGA_UPLOAD_TEX1) && multitex) { + mgaG400EmitTex1(dev_priv); + sarea_priv->dirty &= ~MGA_UPLOAD_TEX1; + } } else { - if (dirty & MGASAREA_NEW_CONTEXT) - mgaEmitContext( dev_priv, buf_priv ); + if (sarea_priv->WarpPipe != dev_priv->WarpPipe) { + mgaG200EmitPipe(dev_priv); + dev_priv->WarpPipe = sarea_priv->WarpPipe; + } - if (dirty & MGASAREA_NEW_TEX0) - mgaG200EmitTex( dev_priv, buf_priv ); + if (dirty & MGA_UPLOAD_CTX) { + mgaEmitContext(dev_priv); + sarea_priv->dirty &= ~MGA_UPLOAD_CTX; + } - if (dirty & MGASAREA_NEW_PIPE) - mgaG200EmitPipe( dev_priv, buf_priv ); - } + if (dirty & MGA_UPLOAD_TEX0) { + mgaG200EmitTex(dev_priv); + sarea_priv->dirty &= ~MGA_UPLOAD_TEX0; + } + } } - /* Disallow all write destinations except the front and backbuffer. */ -static int mgaCopyContext(drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv) +static int mgaVerifyContext(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; unsigned int *regs = sarea_priv->ContextState; - - if (regs[MGA_CTXREG_DSTORG] != dev_priv->frontOrg && - regs[MGA_CTXREG_DSTORG] != dev_priv->backOrg) + + DRM_DEBUG("%s\n", __FUNCTION__); + + if (regs[MGA_CTXREG_DSTORG] != dev_priv->frontOffset && + regs[MGA_CTXREG_DSTORG] != dev_priv->backOffset) { + DRM_DEBUG("BAD DSTORG: %x (front %x, back %x)\n\n", + regs[MGA_CTXREG_DSTORG], dev_priv->frontOffset, + dev_priv->backOffset); + regs[MGA_CTXREG_DSTORG] = 0; return -1; + } - memcpy(buf_priv->ContextState, sarea_priv->ContextState, - sizeof(buf_priv->ContextState)); return 0; } - /* Disallow texture reads from PCI space. */ -static int mgaCopyTex(drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv, - int unit) +static int mgaVerifyTex(drm_mga_private_t * dev_priv, int unit) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - if ((sarea_priv->TexState[unit][MGA_TEXREG_ORG] & 0x3) == 0x1) - return -1; + DRM_DEBUG("%s\n", __FUNCTION__); - memcpy(buf_priv->TexState[unit], sarea_priv->TexState[unit], - sizeof(buf_priv->TexState[0])); + if ((sarea_priv->TexState[unit][MGA_TEXREG_ORG] & 0x3) == 0x1) { + DRM_DEBUG("BAD TEXREG_ORG: %x, unit %d\n", + sarea_priv->TexState[unit][MGA_TEXREG_ORG], + unit); + sarea_priv->TexState[unit][MGA_TEXREG_ORG] = 0; + return -1; + } return 0; } - -int mgaCopyAndVerifyState( drm_mga_private_t *dev_priv, - drm_mga_buf_priv_t *buf_priv ) +static int mgaVerifyState(drm_mga_private_t * dev_priv) { drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; - unsigned int dirty = sarea_priv->dirty ; + unsigned int dirty = sarea_priv->dirty; int rv = 0; - buf_priv->dirty = sarea_priv->dirty; - buf_priv->WarpPipe = sarea_priv->WarpPipe; - - if (dirty & MGASAREA_NEW_CONTEXT) - rv |= mgaCopyContext( dev_priv, buf_priv ); - - if (dirty & MGASAREA_NEW_TEX0) - rv |= mgaCopyTex( dev_priv, buf_priv, 0 ); - - if (dev_priv->chipset == MGA_CARD_TYPE_G400) - { - if (dirty & MGASAREA_NEW_TEX1) - rv |= mgaCopyTex( dev_priv, buf_priv, 1 ); - - if (dirty & MGASAREA_NEW_PIPE) - rv |= (buf_priv->WarpPipe > MGA_MAX_G400_PIPES); - } - else - { - if (dirty & MGASAREA_NEW_PIPE) - rv |= (buf_priv->WarpPipe > MGA_MAX_G200_PIPES); - } + DRM_DEBUG("%s\n", __FUNCTION__); + + if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) + sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; + + if (dirty & MGA_UPLOAD_CTX) + rv |= mgaVerifyContext(dev_priv); + + if (dirty & MGA_UPLOAD_TEX0) + rv |= mgaVerifyTex(dev_priv, 0); + + if (dev_priv->chipset == MGA_CARD_TYPE_G400) { + if (dirty & MGA_UPLOAD_TEX1) + rv |= mgaVerifyTex(dev_priv, 1); + + if (dirty & MGA_UPLOAD_PIPE) + rv |= (sarea_priv->WarpPipe > MGA_MAX_G400_PIPES); + } else { + if (dirty & MGA_UPLOAD_PIPE) + rv |= (sarea_priv->WarpPipe > MGA_MAX_G200_PIPES); + } return rv == 0; } +static int mgaVerifyIload(drm_mga_private_t * dev_priv, + unsigned long bus_address, + unsigned int dstOrg, int length) +{ + DRM_DEBUG("%s\n", __FUNCTION__); + + if (dstOrg < dev_priv->textureOffset || + dstOrg + length > + (dev_priv->textureOffset + dev_priv->textureSize)) { + return -EINVAL; + } + if (length % 64) { + return -EINVAL; + } + return 0; +} + +/* This copies a 64 byte aligned agp region to the frambuffer + * with a standard blit, the ioctl needs to do checking */ + +static void mga_dma_dispatch_tex_blit(drm_device_t * dev, + unsigned long bus_address, + int length, unsigned int destOrg) +{ + drm_mga_private_t *dev_priv = dev->dev_private; + int use_agp = PDEA_pagpxfer_enable | 0x00000001; + u16 y2; + PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); + + y2 = length / 64; + + PRIM_OVERFLOW(dev, dev_priv, 30); + PRIMGETPTR(dev_priv); + + PRIMOUTREG(MGAREG_DSTORG, destOrg); + PRIMOUTREG(MGAREG_MACCESS, 0x00000000); + DRM_DEBUG("srcorg : %lx\n", bus_address | use_agp); + PRIMOUTREG(MGAREG_SRCORG, (u32) bus_address | use_agp); + PRIMOUTREG(MGAREG_AR5, 64); + + PRIMOUTREG(MGAREG_PITCH, 64); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGCTL, MGA_COPY_CMD); + + PRIMOUTREG(MGAREG_AR0, 63); + PRIMOUTREG(MGAREG_AR3, 0); + PRIMOUTREG(MGAREG_FXBNDRY, (63 << 16)); + PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC, y2); + + PRIMOUTREG(MGAREG_SRCORG, 0); + PRIMOUTREG(MGAREG_PITCH, dev_priv->stride / dev_priv->cpp); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMADVANCE(dev_priv); +} + +static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf) +{ + drm_mga_private_t *dev_priv = dev->dev_private; + drm_mga_buf_priv_t *buf_priv = buf->dev_private; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned long address = (unsigned long) buf->bus_address; + int length = buf->used; + int use_agp = PDEA_pagpxfer_enable; + int i = 0; + int primary_needed; + PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); + + DRM_DEBUG("dispatch vertex %d addr 0x%lx, " + "length 0x%x nbox %d dirty %x\n", + buf->idx, address, length, + sarea_priv->nbox, sarea_priv->dirty); + + DRM_DEBUG("used : %d, total : %d\n", buf->used, buf->total); + + if (buf->used) { + /* WARNING: if you change any of the state functions verify + * these numbers (Overestimating this doesn't hurt). + */ + buf_priv->dispatched = 1; + primary_needed = (50 + 15 + 15 + 30 + 25 + + 10 + 15 * MGA_NR_SAREA_CLIPRECTS); + PRIM_OVERFLOW(dev, dev_priv, primary_needed); + mgaEmitState(dev_priv); + + do { + if (i < sarea_priv->nbox) { + DRM_DEBUG("idx %d Emit box %d/%d:" + "%d,%d - %d,%d\n", + buf->idx, + i, sarea_priv->nbox, + sarea_priv->boxes[i].x1, + sarea_priv->boxes[i].y1, + sarea_priv->boxes[i].x2, + sarea_priv->boxes[i].y2); + + mgaEmitClipRect(dev_priv, + &sarea_priv->boxes[i]); + } + + PRIMGETPTR(dev_priv); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_SECADDRESS, + ((u32) address) | TT_VERTEX); + PRIMOUTREG(MGAREG_SECEND, + (((u32) (address + length)) | use_agp)); + PRIMADVANCE(dev_priv); + } while (++i < sarea_priv->nbox); + } + + if (buf_priv->discard) { + if (buf_priv->dispatched == 1) + AGEBUF(dev_priv, buf_priv); + buf_priv->dispatched = 0; + mga_freelist_put(dev, buf); + } + + +} + +static void mga_dma_dispatch_indices(drm_device_t * dev, + drm_buf_t * buf, + unsigned int start, unsigned int end) +{ + drm_mga_private_t *dev_priv = dev->dev_private; + drm_mga_buf_priv_t *buf_priv = buf->dev_private; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int address = (unsigned int) buf->bus_address; + int use_agp = PDEA_pagpxfer_enable; + int i = 0; + int primary_needed; + PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); + + DRM_DEBUG("dispatch indices %d addr 0x%x, " + "start 0x%x end 0x%x nbox %d dirty %x\n", + buf->idx, address, start, end, + sarea_priv->nbox, sarea_priv->dirty); + + if (start != end) { + /* WARNING: if you change any of the state functions verify + * these numbers (Overestimating this doesn't hurt). + */ + buf_priv->dispatched = 1; + primary_needed = (50 + 15 + 15 + 30 + 25 + + 10 + 15 * MGA_NR_SAREA_CLIPRECTS); + PRIM_OVERFLOW(dev, dev_priv, primary_needed); + mgaEmitState(dev_priv); + + do { + if (i < sarea_priv->nbox) { + DRM_DEBUG("idx %d Emit box %d/%d:" + "%d,%d - %d,%d\n", + buf->idx, + i, sarea_priv->nbox, + sarea_priv->boxes[i].x1, + sarea_priv->boxes[i].y1, + sarea_priv->boxes[i].x2, + sarea_priv->boxes[i].y2); + + mgaEmitClipRect(dev_priv, + &sarea_priv->boxes[i]); + } + + PRIMGETPTR(dev_priv); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_SETUPADDRESS, + ((address + start) | + SETADD_mode_vertlist)); + PRIMOUTREG(MGAREG_SETUPEND, + ((address + end) | use_agp)); + PRIMADVANCE(dev_priv); + } while (++i < sarea_priv->nbox); + } + if (buf_priv->discard) { + if (buf_priv->dispatched == 1) + AGEBUF(dev_priv, buf_priv); + buf_priv->dispatched = 0; + mga_freelist_put(dev, buf); + } +} + + +static void mga_dma_dispatch_clear(drm_device_t * dev, int flags, + unsigned int clear_color, + unsigned int clear_zval) +{ + drm_mga_private_t *dev_priv = dev->dev_private; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int *regs = sarea_priv->ContextState; + int nbox = sarea_priv->nbox; + drm_clip_rect_t *pbox = sarea_priv->boxes; + unsigned int cmd; + int i; + int primary_needed; + PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); + + if (dev_priv->sgram) + cmd = MGA_CLEAR_CMD | DC_atype_blk; + else + cmd = MGA_CLEAR_CMD | DC_atype_rstr; + + primary_needed = nbox * 70; + if (primary_needed == 0) + primary_needed = 70; + PRIM_OVERFLOW(dev, dev_priv, primary_needed); + PRIMGETPTR(dev_priv); + + for (i = 0; i < nbox; i++) { + unsigned int height = pbox[i].y2 - pbox[i].y1; + + DRM_DEBUG("dispatch clear %d,%d-%d,%d flags %x!\n", + pbox[i].x1, pbox[i].y1, pbox[i].x2, + pbox[i].y2, flags); + + if (flags & MGA_FRONT) { + DRM_DEBUG("clear front\n"); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_YDSTLEN, + (pbox[i].y1 << 16) | height); + PRIMOUTREG(MGAREG_FXBNDRY, + (pbox[i].x2 << 16) | pbox[i].x1); + + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_FCOL, clear_color); + PRIMOUTREG(MGAREG_DSTORG, dev_priv->frontOffset); + PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd); + } + + if (flags & MGA_BACK) { + DRM_DEBUG("clear back\n"); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_YDSTLEN, + (pbox[i].y1 << 16) | height); + PRIMOUTREG(MGAREG_FXBNDRY, + (pbox[i].x2 << 16) | pbox[i].x1); + + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_FCOL, clear_color); + PRIMOUTREG(MGAREG_DSTORG, dev_priv->backOffset); + PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd); + } + + if (flags & MGA_DEPTH) { + DRM_DEBUG("clear depth\n"); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_YDSTLEN, + (pbox[i].y1 << 16) | height); + PRIMOUTREG(MGAREG_FXBNDRY, + (pbox[i].x2 << 16) | pbox[i].x1); + + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_FCOL, clear_zval); + PRIMOUTREG(MGAREG_DSTORG, dev_priv->depthOffset); + PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd); + } + } + + /* Force reset of DWGCTL */ + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + PRIMADVANCE(dev_priv); +} + +static void mga_dma_dispatch_swap(drm_device_t * dev) +{ + drm_mga_private_t *dev_priv = dev->dev_private; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + unsigned int *regs = sarea_priv->ContextState; + int nbox = sarea_priv->nbox; + drm_clip_rect_t *pbox = sarea_priv->boxes; + int i; + int primary_needed; + PRIMLOCALS; + DRM_DEBUG("%s\n", __FUNCTION__); + + primary_needed = nbox * 5; + primary_needed += 60; + PRIM_OVERFLOW(dev, dev_priv, primary_needed); + PRIMGETPTR(dev_priv); + + PRIMOUTREG(MGAREG_DSTORG, dev_priv->frontOffset); + PRIMOUTREG(MGAREG_MACCESS, dev_priv->mAccess); + PRIMOUTREG(MGAREG_SRCORG, dev_priv->backOffset); + PRIMOUTREG(MGAREG_AR5, dev_priv->stride / 2); + + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DWGCTL, MGA_COPY_CMD); + + for (i = 0; i < nbox; i++) { + unsigned int h = pbox[i].y2 - pbox[i].y1; + unsigned int start = pbox[i].y1 * dev_priv->stride / 2; + + DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n", + pbox[i].x1, pbox[i].y1, pbox[i].x2, pbox[i].y2); + + PRIMOUTREG(MGAREG_AR0, start + pbox[i].x2 - 1); + PRIMOUTREG(MGAREG_AR3, start + pbox[i].x1); + PRIMOUTREG(MGAREG_FXBNDRY, + pbox[i].x1 | ((pbox[i].x2 - 1) << 16)); + PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC, + (pbox[i].y1 << 16) | h); + } + + /* Force reset of DWGCTL */ + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_DMAPAD, 0); + PRIMOUTREG(MGAREG_SRCORG, 0); + PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]); + + PRIMADVANCE(dev_priv); +} + +int mga_clear_bufs(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_mga_private_t *dev_priv = + (drm_mga_private_t *) dev->dev_private; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_mga_clear_t clear; + + copy_from_user_ret(&clear, (drm_mga_clear_t *) arg, sizeof(clear), + -EFAULT); + DRM_DEBUG("%s\n", __FUNCTION__); + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("mga_clear_bufs called without lock held\n"); + return -EINVAL; + } + + if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) + sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; + + /* Make sure we restore the 3D state next time. + */ + dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX; + mga_dma_dispatch_clear(dev, clear.flags, + clear.clear_color, clear.clear_depth); + PRIMUPDATE(dev_priv); + mga_flush_write_combine(); + mga_dma_schedule(dev, 1); + return 0; +} + +int mga_swap_bufs(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_mga_private_t *dev_priv = + (drm_mga_private_t *) dev->dev_private; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + DRM_DEBUG("%s\n", __FUNCTION__); + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("mga_swap_bufs called without lock held\n"); + return -EINVAL; + } + + if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS) + sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS; + + /* Make sure we restore the 3D state next time. + */ + dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX; + mga_dma_dispatch_swap(dev); + PRIMUPDATE(dev_priv); + set_bit(MGA_BUF_SWAP_PENDING, + &dev_priv->current_prim->buffer_status); + mga_flush_write_combine(); + mga_dma_schedule(dev, 1); + return 0; +} + +int mga_iload(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_device_dma_t *dma = dev->dma; + drm_mga_private_t *dev_priv = + (drm_mga_private_t *) dev->dev_private; + drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv; + drm_buf_t *buf; + drm_mga_buf_priv_t *buf_priv; + drm_mga_iload_t iload; + unsigned long bus_address; + DRM_DEBUG("%s\n", __FUNCTION__); + + DRM_DEBUG("Starting Iload\n"); + copy_from_user_ret(&iload, (drm_mga_iload_t *) arg, sizeof(iload), + -EFAULT); + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("mga_iload called without lock held\n"); + return -EINVAL; + } + + buf = dma->buflist[iload.idx]; + buf_priv = buf->dev_private; + bus_address = buf->bus_address; + DRM_DEBUG("bus_address %lx, length %d, destorg : %x\n", + bus_address, iload.length, iload.destOrg); + + if (mgaVerifyIload(dev_priv, + bus_address, iload.destOrg, iload.length)) { + mga_freelist_put(dev, buf); + return -EINVAL; + } + + sarea_priv->dirty |= MGA_UPLOAD_CTX; + + mga_dma_dispatch_tex_blit(dev, bus_address, iload.length, + iload.destOrg); + AGEBUF(dev_priv, buf_priv); + buf_priv->discard = 1; + mga_freelist_put(dev, buf); + mga_flush_write_combine(); + mga_dma_schedule(dev, 1); + return 0; +} + +int mga_vertex(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_mga_private_t *dev_priv = + (drm_mga_private_t *) dev->dev_private; + drm_device_dma_t *dma = dev->dma; + drm_buf_t *buf; + drm_mga_buf_priv_t *buf_priv; + drm_mga_vertex_t vertex; + DRM_DEBUG("%s\n", __FUNCTION__); + + copy_from_user_ret(&vertex, (drm_mga_vertex_t *) arg, + sizeof(vertex), -EFAULT); + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("mga_vertex called without lock held\n"); + return -EINVAL; + } + + DRM_DEBUG("mga_vertex\n"); + + buf = dma->buflist[vertex.idx]; + buf_priv = buf->dev_private; + + buf->used = vertex.used; + buf_priv->discard = vertex.discard; + + if (!mgaVerifyState(dev_priv)) { + if (vertex.discard) { + if (buf_priv->dispatched == 1) + AGEBUF(dev_priv, buf_priv); + buf_priv->dispatched = 0; + mga_freelist_put(dev, buf); + } + DRM_DEBUG("bad state\n"); + return -EINVAL; + } + + mga_dma_dispatch_vertex(dev, buf); + + PRIMUPDATE(dev_priv); + mga_flush_write_combine(); + mga_dma_schedule(dev, 1); + return 0; +} + + +int mga_indices(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_mga_private_t *dev_priv = + (drm_mga_private_t *) dev->dev_private; + drm_device_dma_t *dma = dev->dma; + drm_buf_t *buf; + drm_mga_buf_priv_t *buf_priv; + drm_mga_indices_t indices; + DRM_DEBUG("%s\n", __FUNCTION__); + + copy_from_user_ret(&indices, (drm_mga_indices_t *) arg, + sizeof(indices), -EFAULT); + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("mga_indices called without lock held\n"); + return -EINVAL; + } + + DRM_DEBUG("mga_indices\n"); + + buf = dma->buflist[indices.idx]; + buf_priv = buf->dev_private; + + buf_priv->discard = indices.discard; + + if (!mgaVerifyState(dev_priv)) { + if (indices.discard) { + if (buf_priv->dispatched == 1) + AGEBUF(dev_priv, buf_priv); + buf_priv->dispatched = 0; + mga_freelist_put(dev, buf); + } + return -EINVAL; + } + + mga_dma_dispatch_indices(dev, buf, indices.start, indices.end); + + PRIMUPDATE(dev_priv); + mga_flush_write_combine(); + mga_dma_schedule(dev, 1); + return 0; +} + + + +static int mga_dma_get_buffers(drm_device_t * dev, drm_dma_t * d) +{ + int i; + drm_buf_t *buf; + DRM_DEBUG("%s\n", __FUNCTION__); + + for (i = d->granted_count; i < d->request_count; i++) { + buf = mga_freelist_get(dev); + if (!buf) + break; + buf->pid = current->pid; + copy_to_user_ret(&d->request_indices[i], + &buf->idx, sizeof(buf->idx), -EFAULT); + copy_to_user_ret(&d->request_sizes[i], + &buf->total, sizeof(buf->total), -EFAULT); + ++d->granted_count; + } + return 0; +} + +int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_device_dma_t *dma = dev->dma; + int retcode = 0; + drm_dma_t d; + DRM_DEBUG("%s\n", __FUNCTION__); + + copy_from_user_ret(&d, (drm_dma_t *) arg, sizeof(d), -EFAULT); + DRM_DEBUG("%d %d: %d send, %d req\n", + current->pid, d.context, d.send_count, d.request_count); + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { + DRM_ERROR("mga_dma called without lock held\n"); + return -EINVAL; + } + + /* Please don't send us buffers. + */ + if (d.send_count != 0) { + DRM_ERROR + ("Process %d trying to send %d buffers via drmDMA\n", + current->pid, d.send_count); + return -EINVAL; + } + + /* We'll send you buffers. + */ + if (d.request_count < 0 || d.request_count > dma->buf_count) { + DRM_ERROR + ("Process %d trying to get %d buffers (of %d max)\n", + current->pid, d.request_count, dma->buf_count); + return -EINVAL; + } + + d.granted_count = 0; + + if (d.request_count) { + retcode = mga_dma_get_buffers(dev, &d); + } + + DRM_DEBUG("%d returning, granted = %d\n", + current->pid, d.granted_count); + copy_to_user_ret((drm_dma_t *) arg, &d, sizeof(d), -EFAULT); + return retcode; +} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c index 54aba58c4..ba6dee00d 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c @@ -1,8 +1,8 @@ /* proc.c -- /proc support for DRM -*- linux-c -*- * Created: Mon Jan 11 09:48:47 1999 by faith@precisioninsight.com - * Revised: Sun Feb 13 23:41:04 2000 by kevin@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -23,9 +23,9 @@ * 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. - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c,v 1.6 2000/02/23 04:47:30 martin Exp $ * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> */ #define __NO_VERSION__ @@ -164,7 +164,10 @@ static int _drm_vm_info(char *buf, char **start, off_t offset, int len, { drm_device_t *dev = (drm_device_t *)data; drm_map_t *map; - const char *types[] = { "FB", "REG", "SHM" }; + /* Hardcoded from _DRM_FRAME_BUFFER, + _DRM_REGISTERS, _DRM_SHM, and + _DRM_AGP. */ + const char *types[] = { "FB", "REG", "SHM", "AGP" }; const char *type; int i; @@ -175,7 +178,7 @@ static int _drm_vm_info(char *buf, char **start, off_t offset, int len, "address mtrr\n\n"); for (i = 0; i < dev->map_count; i++) { map = dev->maplist[i]; - if (map->type < 0 || map->type > 2) type = "??"; + if (map->type < 0 || map->type > 3) type = "??"; else type = types[map->type]; DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ", i, @@ -397,6 +400,7 @@ static int _drm_vma_info(char *buf, char **start, off_t offset, int len, pgprot & _PAGE_GLOBAL ? 'g' : 'l' ); #endif DRM_PROC_PRINT("\n"); +#if 0 for (i = vma->vm_start; i < vma->vm_end; i += PAGE_SIZE) { pgd = pgd_offset(vma->vm_mm, i); pmd = pmd_offset(pgd, i); @@ -417,6 +421,7 @@ static int _drm_vma_info(char *buf, char **start, off_t offset, int len, DRM_PROC_PRINT(" 0x%08lx\n", i); } } +#endif } return len; diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c new file mode 100644 index 000000000..dd416db17 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c @@ -0,0 +1,923 @@ +/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*- + * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com + * + * Copyright 2000 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, 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 (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 NONINFRINGEMENT. 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> + * + * $XFree86$ + * + */ + +#define __NO_VERSION__ +#include "drmP.h" +#include "r128_drv.h" + +#include <linux/interrupt.h> /* For task queue support */ +#include <linux/delay.h> + + + +#define DO_REMAP(_m) (_m)->handle = drm_ioremap((_m)->offset, (_m)->size) + +#define DO_REMAPFREE(_m) \ + do { \ + if ((_m)->handle && (_m)->size) \ + drm_ioremapfree((_m)->handle, (_m)->size); \ + } while (0) + +#define DO_FIND_MAP(_m, _o) \ + do { \ + int _i; \ + for (_i = 0; _i < dev->map_count; _i++) { \ + if (dev->maplist[_i]->offset == _o) { \ + _m = dev->maplist[_i]; \ + break; \ + } \ + } \ + } while (0) + + +#define R128_MAX_VBUF_AGE 0x10000000 +#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0 + +int R128_READ_PLL(drm_device_t *dev, int addr) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + + R128_WRITE8(R128_CLOCK_CNTL_INDEX, addr & 0x1f); + return R128_READ(R128_CLOCK_CNTL_DATA); +} + +static void r128_flush_write_combine(void) +{ + int xchangeDummy; + + __asm__ volatile("push %%eax ;" + "xchg %%eax, %0 ;" + "pop %%eax" : : "m" (xchangeDummy)); + __asm__ volatile("push %%eax ;" + "push %%ebx ;" + "push %%ecx ;" + "push %%edx ;" + "movl $0,%%eax ;" + "cpuid ;" + "pop %%edx ;" + "pop %%ecx ;" + "pop %%ebx ;" + "pop %%eax" : /* no outputs */ : /* no inputs */ ); +} + +static void r128_status(drm_device_t *dev) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + + printk("GUI_STAT = 0x%08x\n", + (unsigned int)R128_READ(R128_GUI_STAT)); + printk("PM4_STAT = 0x%08x\n", + (unsigned int)R128_READ(R128_PM4_STAT)); + printk("PM4_BUFFER_DL_WPTR = 0x%08x\n", + (unsigned int)R128_READ(R128_PM4_BUFFER_DL_WPTR)); + printk("PM4_BUFFER_DL_RPTR = 0x%08x\n", + (unsigned int)R128_READ(R128_PM4_BUFFER_DL_RPTR)); +} + +static int r128_do_cleanup_cce(drm_device_t *dev) +{ + if (dev->dev_private) { + drm_r128_private_t *dev_priv = dev->dev_private; + + if (!dev_priv->is_pci) { + DO_REMAPFREE(dev_priv->agp_ring); + DO_REMAPFREE(dev_priv->agp_read_ptr); + DO_REMAPFREE(dev_priv->agp_vertbufs); + DO_REMAPFREE(dev_priv->agp_indbufs); + DO_REMAPFREE(dev_priv->agp_textures); + } + + drm_free(dev->dev_private, sizeof(drm_r128_private_t), + DRM_MEM_DRIVER); + dev->dev_private = NULL; + } + + return 0; +} + +static int r128_do_init_cce(drm_device_t *dev, drm_r128_init_t *init) +{ + drm_r128_private_t *dev_priv; + int i; + + dev_priv = drm_alloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER); + if (dev_priv == NULL) return -ENOMEM; + dev->dev_private = (void *)dev_priv; + + memset(dev_priv, 0, sizeof(drm_r128_private_t)); + + dev_priv->is_pci = init->is_pci; + + dev_priv->usec_timeout = init->usec_timeout; + if (dev_priv->usec_timeout < 1 || + dev_priv->usec_timeout > R128_MAX_USEC_TIMEOUT) { + drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); + dev->dev_private = NULL; + return -EINVAL; + } + + dev_priv->cce_mode = init->cce_mode; + dev_priv->cce_fifo_size = init->cce_fifo_size; + dev_priv->cce_is_bm_mode = + ((init->cce_mode == R128_PM4_192BM) || + (init->cce_mode == R128_PM4_128BM_64INDBM) || + (init->cce_mode == R128_PM4_64BM_128INDBM) || + (init->cce_mode == R128_PM4_64BM_64VCBM_64INDBM)); + dev_priv->cce_secure = init->cce_secure; + + if (dev_priv->cce_is_bm_mode && dev_priv->is_pci) { + drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER); + dev->dev_private = NULL; + return -EINVAL; + } + + for (i = 0; i < dev->map_count; i++) { + if (dev->maplist[i]->type == _DRM_SHM) { + dev_priv->sarea = dev->maplist[i]; + break; + } + } + + DO_FIND_MAP(dev_priv->fb, init->fb_offset); + if (!dev_priv->is_pci) { + DO_FIND_MAP(dev_priv->agp_ring, init->agp_ring_offset); + DO_FIND_MAP(dev_priv->agp_read_ptr, init->agp_read_ptr_offset); + DO_FIND_MAP(dev_priv->agp_vertbufs, init->agp_vertbufs_offset); + DO_FIND_MAP(dev_priv->agp_indbufs, init->agp_indbufs_offset); + DO_FIND_MAP(dev_priv->agp_textures, init->agp_textures_offset); + } + DO_FIND_MAP(dev_priv->mmio, init->mmio_offset); + + dev_priv->sarea_priv = + (drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle + + init->sarea_priv_offset); + + if (!dev_priv->is_pci) { + DO_REMAP(dev_priv->agp_ring); + DO_REMAP(dev_priv->agp_read_ptr); + DO_REMAP(dev_priv->agp_vertbufs); +#if 0 + DO_REMAP(dev_priv->agp_indirectbufs); + DO_REMAP(dev_priv->agp_textures); +#endif + + dev_priv->ring_size = init->ring_size; + dev_priv->ring_sizel2qw = drm_order(init->ring_size/8); + dev_priv->ring_entries = init->ring_size/sizeof(u32); + dev_priv->ring_read_ptr = ((__volatile__ u32 *) + dev_priv->agp_read_ptr->handle); + dev_priv->ring_start = (u32 *)dev_priv->agp_ring->handle; + dev_priv->ring_end = ((u32 *)dev_priv->agp_ring->handle + + dev_priv->ring_entries); + } + + dev_priv->submit_age = 0; + R128_WRITE(R128_VB_AGE_REG, dev_priv->submit_age); + + return 0; +} + +int r128_init_cce(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_init_t init; + + copy_from_user_ret(&init, (drm_r128_init_t *)arg, sizeof(init), + -EFAULT); + + switch (init.func) { + case R128_INIT_CCE: + return r128_do_init_cce(dev, &init); + case R128_CLEANUP_CCE: + return r128_do_cleanup_cce(dev); + } + + return -EINVAL; +} + +static void r128_mark_vertbufs_done(drm_device_t *dev) +{ + drm_device_dma_t *dma = dev->dma; + int i; + + for (i = 0; i < dma->buf_count; i++) { + drm_buf_t *buf = dma->buflist[i]; + drm_r128_buf_priv_t *buf_priv = buf->dev_private; + buf_priv->age = 0; + } +} + +static int r128_do_pixcache_flush(drm_device_t *dev) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + u32 tmp; + int i; + + tmp = R128_READ(R128_PC_NGUI_CTLSTAT) | R128_PC_FLUSH_ALL; + R128_WRITE(R128_PC_NGUI_CTLSTAT, tmp); + + for (i = 0; i < dev_priv->usec_timeout; i++) { + if (!(R128_READ(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY)) + return 0; + udelay(1); + } + + return -EBUSY; +} + +static int r128_do_wait_for_fifo(drm_device_t *dev, int entries) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int i; + + for (i = 0; i < dev_priv->usec_timeout; i++) { + int slots = R128_READ(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK; + if (slots >= entries) return 0; + udelay(1); + } + return -EBUSY; +} + +static int r128_do_wait_for_idle(drm_device_t *dev) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int i, ret; + + if (!(ret = r128_do_wait_for_fifo(dev, 64))) return ret; + + for (i = 0; i < dev_priv->usec_timeout; i++) { + if (!(R128_READ(R128_GUI_STAT) & R128_GUI_ACTIVE)) { + (void)r128_do_pixcache_flush(dev); + return 0; + } + udelay(1); + } + return -EBUSY; +} + +int r128_do_engine_reset(drm_device_t *dev) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + u32 clock_cntl_index, mclk_cntl, gen_reset_cntl; + + (void)r128_do_pixcache_flush(dev); + + clock_cntl_index = R128_READ(R128_CLOCK_CNTL_INDEX); + mclk_cntl = R128_READ_PLL(dev, R128_MCLK_CNTL); + + R128_WRITE_PLL(R128_MCLK_CNTL, + mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CPP); + + gen_reset_cntl = R128_READ(R128_GEN_RESET_CNTL); + + R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI); + (void)R128_READ(R128_GEN_RESET_CNTL); + R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI); + (void)R128_READ(R128_GEN_RESET_CNTL); + + R128_WRITE_PLL(R128_MCLK_CNTL, mclk_cntl); + R128_WRITE(R128_CLOCK_CNTL_INDEX, clock_cntl_index); + R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl); + + /* For CCE ring buffer only */ + if (dev_priv->cce_is_bm_mode) { + R128_WRITE(R128_PM4_BUFFER_DL_WPTR, 0); + R128_WRITE(R128_PM4_BUFFER_DL_RPTR, 0); + *dev_priv->ring_read_ptr = 0; + dev_priv->sarea_priv->ring_write = 0; + } + + /* Reset the CCE mode */ + (void)r128_do_wait_for_idle(dev); + R128_WRITE(R128_PM4_BUFFER_CNTL, + dev_priv->cce_mode | dev_priv->ring_sizel2qw); + (void)R128_READ(R128_PM4_BUFFER_ADDR); /* as per the sample code */ + R128_WRITE(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN); + + r128_mark_vertbufs_done(dev); + return 0; +} + +int r128_eng_reset(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || + dev->lock.pid != current->pid) { + DRM_ERROR("r128_eng_reset called without holding the lock\n"); + return -EINVAL; + } + + return r128_do_engine_reset(dev); +} + +static int r128_do_engine_flush(drm_device_t *dev) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + u32 tmp; + + tmp = R128_READ(R128_PM4_BUFFER_DL_WPTR); + R128_WRITE(R128_PM4_BUFFER_DL_WPTR, tmp | R128_PM4_BUFFER_DL_DONE); + + return 0; +} + +int r128_eng_flush(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || + dev->lock.pid != current->pid) { + DRM_ERROR("r128_eng_flush called without holding the lock\n"); + return -EINVAL; + } + + return r128_do_engine_flush(dev); +} + +static int r128_do_cce_wait_for_fifo(drm_device_t *dev, int entries) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int i; + + for (i = 0; i < dev_priv->usec_timeout; i++) { + int slots = R128_READ(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK; + if (slots >= entries) return 0; + udelay(1); + } + return -EBUSY; +} + +int r128_do_cce_wait_for_idle(drm_device_t *dev) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int i; + + if (dev_priv->cce_is_bm_mode) { + for (i = 0; i < dev_priv->usec_timeout; i++) { + if (*dev_priv->ring_read_ptr == dev_priv->sarea_priv->ring_write) { + int pm4stat = R128_READ(R128_PM4_STAT); + if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= dev_priv->cce_fifo_size && + !(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) { + return r128_do_pixcache_flush(dev); + } + } + udelay(1); + } + return -EBUSY; + } else { + int ret = r128_do_cce_wait_for_fifo(dev, dev_priv->cce_fifo_size); + if (ret < 0) return ret; + + for (i = 0; i < dev_priv->usec_timeout; i++) { + int pm4stat = R128_READ(R128_PM4_STAT); + if (!(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) { + return r128_do_pixcache_flush(dev); + } + udelay(1); + } + return -EBUSY; + } +} + +int r128_cce_idle(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || + dev->lock.pid != current->pid) { + DRM_ERROR("r128_wait_idle called without holding the lock\n"); + return -EINVAL; + } + + return r128_do_cce_wait_for_idle(dev); +} + +static int r128_submit_packets_ring_secure(drm_device_t *dev, + u32 *commands, int *count) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int write = dev_priv->sarea_priv->ring_write; + int *write_ptr = dev_priv->ring_start + write; + int c = *count; + u32 tmp = 0; + int psize = 0; + int writing = 1; + int timeout; + + while (c > 0) { + tmp = *commands++; + if (!psize) { + writing = 1; + + if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) { + if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) { + if ((tmp & R128_CCE_PACKET0_REG_MASK) != + (R128_PM4_VC_FPU_SETUP >> 2)) { + writing = 0; + } + } + psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; + } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) { + if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) { + if ((tmp & R128_CCE_PACKET1_REG0_MASK) != + (R128_PM4_VC_FPU_SETUP >> 2)) { + writing = 0; + } + } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <= + (0x1004 << 9)) { + if ((tmp & R128_CCE_PACKET1_REG1_MASK) != + (R128_PM4_VC_FPU_SETUP << 9)) { + writing = 0; + } + } + psize = 3; + } else { + psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; + } + } + psize--; + + if (writing) { + write++; + *write_ptr++ = tmp; + } + if (write >= dev_priv->ring_entries) { + write = 0; + write_ptr = dev_priv->ring_start; + } + timeout = 0; + while (write == *dev_priv->ring_read_ptr) { + (void)R128_READ(R128_PM4_BUFFER_DL_RPTR); + if (timeout++ >= dev_priv->usec_timeout) + return -EBUSY; + udelay(1); + } + c--; + } + + if (write < 32) + memcpy(dev_priv->ring_end, + dev_priv->ring_start, + write * sizeof(u32)); + + /* Make sure WC cache has been flushed */ + r128_flush_write_combine(); + + dev_priv->sarea_priv->ring_write = write; + R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write); + + *count = 0; + + return 0; +} + +static int r128_submit_packets_pio_secure(drm_device_t *dev, + u32 *commands, int *count) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + u32 tmp = 0; + int psize = 0; + int writing = 1; + int addr = R128_PM4_FIFO_DATA_EVEN; + int ret; + + while (*count > 0) { + tmp = *commands++; + if (!psize) { + writing = 1; + + if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) { + if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) { + if ((tmp & R128_CCE_PACKET0_REG_MASK) != + (R128_PM4_VC_FPU_SETUP >> 2)) { + writing = 0; + } + } + psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; + } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) { + if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) { + if ((tmp & R128_CCE_PACKET1_REG0_MASK) != + (R128_PM4_VC_FPU_SETUP >> 2)) { + writing = 0; + } + } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <= + (0x1004 << 9)) { + if ((tmp & R128_CCE_PACKET1_REG1_MASK) != + (R128_PM4_VC_FPU_SETUP << 9)) { + writing = 0; + } + } + psize = 3; + } else { + psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; + } + } + psize--; + + if (writing) { + if ((ret = r128_do_cce_wait_for_fifo(dev, 1)) < 0) + return ret; + R128_WRITE(addr, tmp); + addr ^= 0x0004; + } + + *count -= 1; + } + + if (addr == R128_PM4_FIFO_DATA_ODD) { + if ((ret = r128_do_cce_wait_for_fifo(dev, 1)) < 0) return ret; + R128_WRITE(addr, R128_CCE_PACKET2); + } + + return 0; +} + +static int r128_submit_packets_ring(drm_device_t *dev, + u32 *commands, int *count) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int write = dev_priv->sarea_priv->ring_write; + int *write_ptr = dev_priv->ring_start + write; + int c = *count; + int timeout; + + while (c > 0) { + write++; + *write_ptr++ = *commands++; + if (write >= dev_priv->ring_entries) { + write = 0; + write_ptr = dev_priv->ring_start; + } + timeout = 0; + while (write == *dev_priv->ring_read_ptr) { + (void)R128_READ(R128_PM4_BUFFER_DL_RPTR); + if (timeout++ >= dev_priv->usec_timeout) + return -EBUSY; + udelay(1); + } + c--; + } + + if (write < 32) + memcpy(dev_priv->ring_end, + dev_priv->ring_start, + write * sizeof(u32)); + + /* Make sure WC cache has been flushed */ + r128_flush_write_combine(); + + dev_priv->sarea_priv->ring_write = write; + R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write); + + *count = 0; + + return 0; +} + +static int r128_submit_packets_pio(drm_device_t *dev, + u32 *commands, int *count) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int ret; + + while (*count > 1) { + if ((ret = r128_do_cce_wait_for_fifo(dev, 2)) < 0) return ret; + R128_WRITE(R128_PM4_FIFO_DATA_EVEN, *commands++); + R128_WRITE(R128_PM4_FIFO_DATA_ODD, *commands++); + *count -= 2; + } + + if (*count) { + if ((ret = r128_do_cce_wait_for_fifo(dev, 2)) < 0) return ret; + R128_WRITE(R128_PM4_FIFO_DATA_EVEN, *commands++); + R128_WRITE(R128_PM4_FIFO_DATA_ODD, R128_CCE_PACKET2); + *count = 0; + } + + return 0; +} + +static int r128_do_submit_packets(drm_device_t *dev, u32 *buffer, int count) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + int c = count; + int ret; + + if (dev_priv->cce_is_bm_mode) { + int left = 0; + + if (c >= dev_priv->ring_entries) { + c = dev_priv->ring_entries-1; + left = count - c; + } + + /* Since this is only used by the kernel we can use the + insecure ring buffer submit packet routine */ + ret = r128_submit_packets_ring(dev, buffer, &c); + + c += left; + } else { + /* Since this is only used by the kernel we can use the + insecure PIO submit packet routine */ + ret = r128_submit_packets_pio(dev, buffer, &c); + } + + if (ret < 0) return ret; + else return c; +} + +int r128_submit_pkt(struct inode *inode, struct file *filp, + unsigned int cmd, unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_packet_t packet; + u32 *buffer; + int c; + int size; + int ret = 0; + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || + dev->lock.pid != current->pid) { + DRM_ERROR("r128_submit_pkt called without holding the lock\n"); + return -EINVAL; + } + + copy_from_user_ret(&packet, (drm_r128_packet_t *)arg, sizeof(packet), + -EFAULT); + + c = packet.count; + size = c * sizeof(*buffer); + + if (dev_priv->cce_is_bm_mode) { + int left = 0; + + if (c >= dev_priv->ring_entries) { + c = dev_priv->ring_entries-1; + size = c * sizeof(*buffer); + left = packet.count - c; + } + + if ((buffer = kmalloc(size, 0)) == NULL) return -ENOMEM; + copy_from_user_ret(buffer, packet.buffer, size, -EFAULT); + + if (dev_priv->cce_secure) + ret = r128_submit_packets_ring_secure(dev, buffer, &c); + else + ret = r128_submit_packets_ring(dev, buffer, &c); + + c += left; + } else { + if ((buffer = kmalloc(size, 0)) == NULL) return -ENOMEM; + copy_from_user_ret(buffer, packet.buffer, size, -EFAULT); + + if (dev_priv->cce_secure) + ret = r128_submit_packets_pio_secure(dev, buffer, &c); + else + ret = r128_submit_packets_pio(dev, buffer, &c); + } + + kfree(buffer); + + packet.count = c; + copy_to_user_ret((drm_r128_packet_t *)arg, &packet, sizeof(packet), + -EFAULT); + + if (ret) return ret; + else if (c > 0) return -EAGAIN; + + return 0; +} + +static int r128_send_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v) +{ + drm_device_dma_t *dma = dev->dma; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_buf_priv_t *buf_priv; + drm_buf_t *buf; + int i, ret; + u32 cce[2]; + + /* Make sure we have valid data */ + for (i = 0; i < v->send_count; i++) { + int idx = v->send_indices[i]; + + if (idx < 0 || idx >= dma->buf_count) { + DRM_ERROR("Index %d (of %d max)\n", + idx, dma->buf_count - 1); + return -EINVAL; + } + buf = dma->buflist[idx]; + if (buf->pid != current->pid) { + DRM_ERROR("Process %d using buffer owned by %d\n", + current->pid, buf->pid); + return -EINVAL; + } + if (buf->pending) { + DRM_ERROR("Sending pending buffer:" + " buffer %d, offset %d\n", + v->send_indices[i], i); + return -EINVAL; + } + } + + /* Wait for idle, if we've wrapped to make sure that all pending + buffers have been processed */ + if (dev_priv->submit_age == R128_MAX_VBUF_AGE) { + if ((ret = r128_do_cce_wait_for_idle(dev)) < 0) return ret; + dev_priv->submit_age = 0; + r128_mark_vertbufs_done(dev); + } + + /* Make sure WC cache has been flushed (if in PIO mode) */ + if (!dev_priv->cce_is_bm_mode) r128_flush_write_combine(); + + /* FIXME: Add support for sending vertex buffer to the CCE here + instead of in client code. The v->prim holds the primitive + type that should be drawn. Loop over the list buffers in + send_indices[] and submit a packet for each VB. + + This will require us to loop over the clip rects here as + well, which implies that we extend the kernel driver to allow + cliprects to be stored here. Note that the cliprects could + possibly come from the X server instead of the client, but + this will require additional changes to the DRI to allow for + this optimization. */ + + /* Submit a CCE packet that writes submit_age to R128_VB_AGE_REG */ + cce[0] = R128CCE0(R128_CCE_PACKET0, R128_VB_AGE_REG, 0); + cce[1] = dev_priv->submit_age; + if ((ret = r128_do_submit_packets(dev, cce, 2)) < 0) { + /* Until we add support for sending VBs to the CCE in + this routine, we can recover from this error. After + we add that support, we won't be able to easily + recover, so we will probably have to implement + another mechanism for handling timeouts from packets + submitted directly by the kernel. */ + return ret; + } + + /* Now that the submit packet request has succeeded, we can mark + the buffers as pending */ + for (i = 0; i < v->send_count; i++) { + buf = dma->buflist[v->send_indices[i]]; + buf->pending = 1; + + buf_priv = buf->dev_private; + buf_priv->age = dev_priv->submit_age; + } + + dev_priv->submit_age++; + + return 0; +} + +static drm_buf_t *r128_freelist_get(drm_device_t *dev) +{ + drm_device_dma_t *dma = dev->dma; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_r128_buf_priv_t *buf_priv; + drm_buf_t *buf; + int i, t; + + /* FIXME: Optimize -- use freelist code */ + + for (i = 0; i < dma->buf_count; i++) { + buf = dma->buflist[i]; + buf_priv = buf->dev_private; + if (buf->pid == 0) return buf; + } + + for (t = 0; t < dev_priv->usec_timeout; t++) { + u32 done_age = R128_READ(R128_VB_AGE_REG); + + for (i = 0; i < dma->buf_count; i++) { + buf = dma->buflist[i]; + buf_priv = buf->dev_private; + if (buf->pending && buf_priv->age <= done_age) { + /* The buffer has been processed, so it + can now be used */ + buf->pending = 0; + return buf; + } + } + udelay(1); + } + + r128_status(dev); + return NULL; +} + + +static int r128_get_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v) +{ + drm_buf_t *buf; + int i; + + for (i = v->granted_count; i < v->request_count; i++) { + buf = r128_freelist_get(dev); + if (!buf) break; + buf->pid = current->pid; + copy_to_user_ret(&v->request_indices[i], + &buf->idx, + sizeof(buf->idx), + -EFAULT); + copy_to_user_ret(&v->request_sizes[i], + &buf->total, + sizeof(buf->total), + -EFAULT); + ++v->granted_count; + } + return 0; +} + +int r128_vertex_buf(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_r128_private_t *dev_priv = dev->dev_private; + drm_device_dma_t *dma = dev->dma; + int retcode = 0; + drm_r128_vertex_t v; + + if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || + dev->lock.pid != current->pid) { + DRM_ERROR("r128_vertex_buf called without holding the lock\n"); + return -EINVAL; + } + + if (!dev_priv || dev_priv->is_pci) { + DRM_ERROR("r128_vertex_buf called with a PCI card\n"); + return -EINVAL; + } + + copy_from_user_ret(&v, (drm_r128_vertex_t *)arg, sizeof(v), -EFAULT); + DRM_DEBUG("%d: %d send, %d req\n", + current->pid, v.send_count, v.request_count); + + if (v.send_count < 0 || v.send_count > dma->buf_count) { + DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n", + current->pid, v.send_count, dma->buf_count); + return -EINVAL; + } + if (v.request_count < 0 || v.request_count > dma->buf_count) { + DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", + current->pid, v.request_count, dma->buf_count); + return -EINVAL; + } + + if (v.send_count) { + retcode = r128_send_vertbufs(dev, &v); + } + + v.granted_count = 0; + + if (!retcode && v.request_count) { + retcode = r128_get_vertbufs(dev, &v); + } + + DRM_DEBUG("%d returning, granted = %d\n", + current->pid, v.granted_count); + copy_to_user_ret((drm_r128_vertex_t *)arg, &v, sizeof(v), -EFAULT); + + return retcode; +} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c new file mode 100644 index 000000000..e5a85af90 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c @@ -0,0 +1,737 @@ +/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*- + * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com + * + * Copyright 1999, 2000 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, 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 (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 NONINFRINGEMENT. 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: Rickard E. (Rik) Faith <faith@precisioninsight.com> + * Kevin E. Martin <kevin@precisioninsight.com> + * + * $XFree86$ + * + */ + +#define EXPORT_SYMTAB +#include "drmP.h" +#include "r128_drv.h" +EXPORT_SYMBOL(r128_init); +EXPORT_SYMBOL(r128_cleanup); + +#define R128_NAME "r128" +#define R128_DESC "r128" +#define R128_DATE "20000607" +#define R128_MAJOR 1 +#define R128_MINOR 0 +#define R128_PATCHLEVEL 0 + +static drm_device_t r128_device; +drm_ctx_t r128_res_ctx; + +static struct file_operations r128_fops = { + open: r128_open, + flush: drm_flush, + release: r128_release, + ioctl: r128_ioctl, + mmap: drm_mmap, + read: drm_read, + fasync: drm_fasync, + poll: drm_poll, +}; + +static struct miscdevice r128_misc = { + minor: MISC_DYNAMIC_MINOR, + name: R128_NAME, + fops: &r128_fops, +}; + +static drm_ioctl_desc_t r128_ioctls[] = { + [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { r128_version, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 }, + + [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { r128_addbufs, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { r128_mapbufs, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 }, + + [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { r128_addctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { r128_rmctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { r128_modctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { r128_getctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { r128_switchctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { r128_newctx, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { r128_resctx, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { r128_lock, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { r128_unlock, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 }, + +#ifdef DRM_AGP + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { drm_agp_release, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { drm_agp_enable, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 }, +#endif + + [DRM_IOCTL_NR(DRM_IOCTL_R128_INIT)] = { r128_init_cce, 1, 1 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_RESET)] = { r128_eng_reset, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_FLUSH)] = { r128_eng_flush, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_PACKET)] = { r128_submit_pkt, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_IDLE)] = { r128_cce_idle, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_VERTEX)] = { r128_vertex_buf, 1, 0 }, +}; +#define R128_IOCTL_COUNT DRM_ARRAY_SIZE(r128_ioctls) + +#ifdef MODULE +int init_module(void); +void cleanup_module(void); +static char *r128 = NULL; + +MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas."); +MODULE_DESCRIPTION("r128"); +MODULE_PARM(r128, "s"); + +/* init_module is called when insmod is used to load the module */ + +int init_module(void) +{ + return r128_init(); +} + +/* cleanup_module is called when rmmod is used to unload the module */ + +void cleanup_module(void) +{ + r128_cleanup(); +} +#endif + +#ifndef MODULE +/* r128_setup is called by the kernel to parse command-line options passed + * via the boot-loader (e.g., LILO). It calls the insmod option routine, + * drm_parse_drm. + * + * This is not currently supported, since it requires changes to + * linux/init/main.c. */ + + +void __init r128_setup(char *str, int *ints) +{ + if (ints[0] != 0) { + DRM_ERROR("Illegal command line format, ignored\n"); + return; + } + drm_parse_options(str); +} +#endif + +static int r128_setup(drm_device_t *dev) +{ + int i; + + atomic_set(&dev->ioctl_count, 0); + atomic_set(&dev->vma_count, 0); + dev->buf_use = 0; + atomic_set(&dev->buf_alloc, 0); + + drm_dma_setup(dev); + + atomic_set(&dev->total_open, 0); + atomic_set(&dev->total_close, 0); + atomic_set(&dev->total_ioctl, 0); + atomic_set(&dev->total_irq, 0); + atomic_set(&dev->total_ctx, 0); + atomic_set(&dev->total_locks, 0); + atomic_set(&dev->total_unlocks, 0); + atomic_set(&dev->total_contends, 0); + atomic_set(&dev->total_sleeps, 0); + + for (i = 0; i < DRM_HASH_SIZE; i++) { + dev->magiclist[i].head = NULL; + dev->magiclist[i].tail = NULL; + } + dev->maplist = NULL; + dev->map_count = 0; + dev->vmalist = NULL; + dev->lock.hw_lock = NULL; + init_waitqueue_head(&dev->lock.lock_queue); + dev->queue_count = 0; + dev->queue_reserved = 0; + dev->queue_slots = 0; + dev->queuelist = NULL; + dev->irq = 0; + dev->context_flag = 0; + dev->interrupt_flag = 0; + dev->dma_flag = 0; + dev->last_context = 0; + dev->last_switch = 0; + dev->last_checked = 0; + init_timer(&dev->timer); + init_waitqueue_head(&dev->context_wait); + + dev->ctx_start = 0; + dev->lck_start = 0; + + dev->buf_rp = dev->buf; + dev->buf_wp = dev->buf; + dev->buf_end = dev->buf + DRM_BSZ; + dev->buf_async = NULL; + init_waitqueue_head(&dev->buf_readers); + init_waitqueue_head(&dev->buf_writers); + + r128_res_ctx.handle=-1; + + DRM_DEBUG("\n"); + + /* The kernel's context could be created here, but is now created + in drm_dma_enqueue. This is more resource-efficient for + hardware that does not do DMA, but may mean that + drm_select_queue fails between the time the interrupt is + initialized and the time the queues are initialized. */ + + return 0; +} + + +static int r128_takedown(drm_device_t *dev) +{ + int i; + drm_magic_entry_t *pt, *next; + drm_map_t *map; + drm_vma_entry_t *vma, *vma_next; + + DRM_DEBUG("\n"); + + down(&dev->struct_sem); + del_timer(&dev->timer); + + if (dev->devname) { + drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); + dev->devname = NULL; + } + + if (dev->unique) { + drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); + dev->unique = NULL; + dev->unique_len = 0; + } + /* Clear pid list */ + for (i = 0; i < DRM_HASH_SIZE; i++) { + for (pt = dev->magiclist[i].head; pt; pt = next) { + next = pt->next; + drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC); + } + dev->magiclist[i].head = dev->magiclist[i].tail = NULL; + } + +#ifdef DRM_AGP + /* Clear AGP information */ + if (dev->agp) { + drm_agp_mem_t *entry; + drm_agp_mem_t *nexte; + + /* Remove AGP resources, but leave dev->agp + intact until r128_cleanup is called. */ + for (entry = dev->agp->memory; entry; entry = nexte) { + nexte = entry->next; + if (entry->bound) drm_unbind_agp(entry->memory); + drm_free_agp(entry->memory, entry->pages); + drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); + } + dev->agp->memory = NULL; + + if (dev->agp->acquired && drm_agp.release) + (*drm_agp.release)(); + + dev->agp->acquired = 0; + dev->agp->enabled = 0; + } +#endif + + /* Clear vma list (only built for debugging) */ + if (dev->vmalist) { + for (vma = dev->vmalist; vma; vma = vma_next) { + vma_next = vma->next; + drm_free(vma, sizeof(*vma), DRM_MEM_VMAS); + } + dev->vmalist = NULL; + } + + /* Clear map area and mtrr information */ + if (dev->maplist) { + for (i = 0; i < dev->map_count; i++) { + map = dev->maplist[i]; + switch (map->type) { + case _DRM_REGISTERS: + case _DRM_FRAME_BUFFER: +#ifdef CONFIG_MTRR + if (map->mtrr >= 0) { + int retcode; + retcode = mtrr_del(map->mtrr, + map->offset, + map->size); + DRM_DEBUG("mtrr_del = %d\n", retcode); + } +#endif + drm_ioremapfree(map->handle, map->size); + break; + case _DRM_SHM: + drm_free_pages((unsigned long)map->handle, + drm_order(map->size) + - PAGE_SHIFT, + DRM_MEM_SAREA); + break; + case _DRM_AGP: + /* Do nothing here, because this is all + handled in the AGP/GART driver. */ + break; + } + drm_free(map, sizeof(*map), DRM_MEM_MAPS); + } + drm_free(dev->maplist, + dev->map_count * sizeof(*dev->maplist), + DRM_MEM_MAPS); + dev->maplist = NULL; + dev->map_count = 0; + } + + drm_dma_takedown(dev); + + dev->queue_count = 0; + if (dev->lock.hw_lock) { + dev->lock.hw_lock = NULL; /* SHM removed */ + dev->lock.pid = 0; + wake_up_interruptible(&dev->lock.lock_queue); + } + up(&dev->struct_sem); + + return 0; +} + +/* r128_init is called via init_module at module load time, or via + * linux/init/main.c (this is not currently supported). */ + +int r128_init(void) +{ + int retcode; + drm_device_t *dev = &r128_device; + + DRM_DEBUG("\n"); + + memset((void *)dev, 0, sizeof(*dev)); + dev->count_lock = SPIN_LOCK_UNLOCKED; + sema_init(&dev->struct_sem, 1); + +#ifdef MODULE + drm_parse_options(r128); +#endif + + if ((retcode = misc_register(&r128_misc))) { + DRM_ERROR("Cannot register \"%s\"\n", R128_NAME); + return retcode; + } + dev->device = MKDEV(MISC_MAJOR, r128_misc.minor); + dev->name = R128_NAME; + + drm_mem_init(); + drm_proc_init(dev); + +#ifdef DRM_AGP + dev->agp = drm_agp_init(); + +#ifdef CONFIG_MTRR + dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base, + dev->agp->agp_info.aper_size*1024*1024, + MTRR_TYPE_WRCOMB, + 1); +#endif +#endif + + if((retcode = drm_ctxbitmap_init(dev))) { + DRM_ERROR("Cannot allocate memory for context bitmap.\n"); + drm_proc_cleanup(); + misc_deregister(&r128_misc); + r128_takedown(dev); + return retcode; + } + + DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", + R128_NAME, + R128_MAJOR, + R128_MINOR, + R128_PATCHLEVEL, + R128_DATE, + r128_misc.minor); + + return 0; +} + +/* r128_cleanup is called via cleanup_module at module unload time. */ + +void r128_cleanup(void) +{ + drm_device_t *dev = &r128_device; + + DRM_DEBUG("\n"); + + drm_proc_cleanup(); + if (misc_deregister(&r128_misc)) { + DRM_ERROR("Cannot unload module\n"); + } else { + DRM_INFO("Module unloaded\n"); + } + drm_ctxbitmap_cleanup(dev); + r128_takedown(dev); +#ifdef DRM_AGP + if (dev->agp) { + /* FIXME -- free other information, too */ + drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); + dev->agp = NULL; + } +#endif +} + +int r128_version(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_version_t version; + int len; + + copy_from_user_ret(&version, + (drm_version_t *)arg, + sizeof(version), + -EFAULT); + +#define DRM_COPY(name,value) \ + len = strlen(value); \ + if (len > name##_len) len = name##_len; \ + name##_len = strlen(value); \ + if (len && name) { \ + copy_to_user_ret(name, value, len, -EFAULT); \ + } + + version.version_major = R128_MAJOR; + version.version_minor = R128_MINOR; + version.version_patchlevel = R128_PATCHLEVEL; + + DRM_COPY(version.name, R128_NAME); + DRM_COPY(version.date, R128_DATE); + DRM_COPY(version.desc, R128_DESC); + + copy_to_user_ret((drm_version_t *)arg, + &version, + sizeof(version), + -EFAULT); + return 0; +} + +int r128_open(struct inode *inode, struct file *filp) +{ + drm_device_t *dev = &r128_device; + int retcode = 0; + + DRM_DEBUG("open_count = %d\n", dev->open_count); + if (!(retcode = drm_open_helper(inode, filp, dev))) { + MOD_INC_USE_COUNT; + atomic_inc(&dev->total_open); + spin_lock(&dev->count_lock); + if (!dev->open_count++) { + spin_unlock(&dev->count_lock); + return r128_setup(dev); + } + spin_unlock(&dev->count_lock); + } + return retcode; +} + +int r128_release(struct inode *inode, struct file *filp) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + int retcode = 0; + + DRM_DEBUG("open_count = %d\n", dev->open_count); + if (!(retcode = drm_release(inode, filp))) { + MOD_DEC_USE_COUNT; + atomic_inc(&dev->total_close); + spin_lock(&dev->count_lock); + if (!--dev->open_count) { + if (atomic_read(&dev->ioctl_count) || dev->blocked) { + DRM_ERROR("Device busy: %d %d\n", + atomic_read(&dev->ioctl_count), + dev->blocked); + spin_unlock(&dev->count_lock); + return -EBUSY; + } + spin_unlock(&dev->count_lock); + return r128_takedown(dev); + } + spin_unlock(&dev->count_lock); + } + return retcode; +} + +/* r128_ioctl is called whenever a process performs an ioctl on /dev/drm. */ + +int r128_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + int nr = DRM_IOCTL_NR(cmd); + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + int retcode = 0; + drm_ioctl_desc_t *ioctl; + drm_ioctl_t *func; + + atomic_inc(&dev->ioctl_count); + atomic_inc(&dev->total_ioctl); + ++priv->ioctl_count; + + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", + current->pid, cmd, nr, dev->device, priv->authenticated); + + if (nr >= R128_IOCTL_COUNT) { + retcode = -EINVAL; + } else { + ioctl = &r128_ioctls[nr]; + func = ioctl->func; + + if (!func) { + DRM_DEBUG("no function\n"); + retcode = -EINVAL; + } else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN)) + || (ioctl->auth_needed && !priv->authenticated)) { + retcode = -EACCES; + } else { + retcode = (func)(inode, filp, cmd, arg); + } + } + + atomic_dec(&dev->ioctl_count); + return retcode; +} + +int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + DECLARE_WAITQUEUE(entry, current); + int ret = 0; + drm_lock_t lock; +#if DRM_DMA_HISTOGRAM + cycles_t start; + + dev->lck_start = start = get_cycles(); +#endif + + copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + + if (lock.context == DRM_KERNEL_CONTEXT) { + DRM_ERROR("Process %d using kernel context %d\n", + current->pid, lock.context); + return -EINVAL; + } + + DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", + lock.context, current->pid, dev->lock.hw_lock->lock, + lock.flags); + +#if 0 + /* dev->queue_count == 0 right now for + r128. FIXME? */ + if (lock.context < 0 || lock.context >= dev->queue_count) + return -EINVAL; +#endif + + if (!ret) { +#if 0 + if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) + != lock.context) { + long j = jiffies - dev->lock.lock_time; + + if (lock.context == r128_res_ctx.handle && + j >= 0 && j < DRM_LOCK_SLICE) { + /* Can't take lock if we just had it and + there is contention. */ + DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n", + lock.context, current->pid, j, + dev->lock.lock_time, jiffies); + current->state = TASK_INTERRUPTIBLE; + current->policy |= SCHED_YIELD; + schedule_timeout(DRM_LOCK_SLICE-j); + DRM_DEBUG("jiffies=%d\n", jiffies); + } + } +#endif + add_wait_queue(&dev->lock.lock_queue, &entry); + for (;;) { + if (!dev->lock.hw_lock) { + /* Device has been unregistered */ + ret = -EINTR; + break; + } + if (drm_lock_take(&dev->lock.hw_lock->lock, + lock.context)) { + dev->lock.pid = current->pid; + dev->lock.lock_time = jiffies; + atomic_inc(&dev->total_locks); + break; /* Got lock */ + } + + /* Contention */ + atomic_inc(&dev->total_sleeps); + current->state = TASK_INTERRUPTIBLE; +#if 1 + current->policy |= SCHED_YIELD; +#endif + schedule(); + if (signal_pending(current)) { + ret = -ERESTARTSYS; + break; + } + } + current->state = TASK_RUNNING; + remove_wait_queue(&dev->lock.lock_queue, &entry); + } + +#if 0 + if (!ret && dev->last_context != lock.context && + lock.context != r128_res_ctx.handle && + dev->last_context != r128_res_ctx.handle) { + add_wait_queue(&dev->context_wait, &entry); + current->state = TASK_INTERRUPTIBLE; + /* PRE: dev->last_context != lock.context */ + r128_context_switch(dev, dev->last_context, lock.context); + /* POST: we will wait for the context + switch and will dispatch on a later call + when dev->last_context == lock.context + NOTE WE HOLD THE LOCK THROUGHOUT THIS + TIME! */ + current->policy |= SCHED_YIELD; + schedule(); + current->state = TASK_RUNNING; + remove_wait_queue(&dev->context_wait, &entry); + if (signal_pending(current)) { + ret = -EINTR; + } else if (dev->last_context != lock.context) { + DRM_ERROR("Context mismatch: %d %d\n", + dev->last_context, lock.context); + } + } +#endif + + if (!ret) { + if (lock.flags & _DRM_LOCK_READY) { + /* Wait for space in DMA/FIFO */ + } + if (lock.flags & _DRM_LOCK_QUIESCENT) { + /* Make hardware quiescent */ +#if 0 + r128_quiescent(dev); +#endif + } + } + +#if 0 + DRM_ERROR("pid = %5d, old counter = %5ld\n", + current->pid, current->counter); +#endif + if (lock.context != r128_res_ctx.handle) { + current->counter = 5; + current->priority = DEF_PRIORITY/4; + } +#if 0 + while (current->counter > 25) + current->counter >>= 1; /* decrease time slice */ + DRM_ERROR("pid = %5d, new counter = %5ld\n", + current->pid, current->counter); +#endif + DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock"); + +#if DRM_DMA_HISTOGRAM + atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); +#endif + + return ret; +} + + +int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd, + unsigned long arg) +{ + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; + drm_lock_t lock; + + copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); + + if (lock.context == DRM_KERNEL_CONTEXT) { + DRM_ERROR("Process %d using kernel context %d\n", + current->pid, lock.context); + return -EINVAL; + } + + DRM_DEBUG("%d frees lock (%d holds)\n", + lock.context, + _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); + atomic_inc(&dev->total_unlocks); + if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) + atomic_inc(&dev->total_contends); + drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); + /* FIXME: Try to send data to card here */ + if (!dev->context_flag) { + if (drm_lock_free(dev, &dev->lock.hw_lock->lock, + DRM_KERNEL_CONTEXT)) { + DRM_ERROR("\n"); + } + } + +#if 0 + current->policy |= SCHED_YIELD; + current->state = TASK_INTERRUPTIBLE; + schedule_timeout(1000); +#endif + + if (lock.context != r128_res_ctx.handle) { + current->counter = 5; + current->priority = DEF_PRIORITY; + } +#if 0 + current->state = TASK_INTERRUPTIBLE; + schedule_timeout(10); +#endif + + return 0; +} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c index 842d6f5d5..c8d6e50ea 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c @@ -1,8 +1,8 @@ /* tdfx_context.c -- IOCTLs for tdfx contexts -*- linux-c -*- * Created: Thu Oct 7 10:50:22 1999 by faith@precisioninsight.com - * Revised: Sat Oct 9 23:39:56 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,8 +24,10 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c,v 1.2 2000/02/23 04:47:30 martin Exp $ - * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * Daryll Strauss <daryll@valinux.com> + * */ #include <linux/sched.h> @@ -38,9 +40,7 @@ extern drm_ctx_t tdfx_res_ctx; static int tdfx_alloc_queue(drm_device_t *dev) { - static int context = 0; - - return ++context; /* Should this reuse contexts in the future? */ + return drm_ctxbitmap_next(dev); } int tdfx_context_switch(drm_device_t *dev, int old, int new) @@ -137,6 +137,12 @@ int tdfx_addctx(struct inode *inode, struct file *filp, unsigned int cmd, ctx.handle = tdfx_alloc_queue(dev); } DRM_DEBUG("%d\n", ctx.handle); + if (ctx.handle == -1) { + DRM_DEBUG("Not enough free contexts.\n"); + /* Should this return -EBUSY instead? */ + return -ENOMEM; + } + copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT); return 0; } @@ -193,13 +199,13 @@ int tdfx_newctx(struct inode *inode, struct file *filp, unsigned int cmd, int tdfx_rmctx(struct inode *inode, struct file *filp, unsigned int cmd, unsigned long arg) { + drm_file_t *priv = filp->private_data; + drm_device_t *dev = priv->dev; drm_ctx_t ctx; copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT); DRM_DEBUG("%d\n", ctx.handle); - /* This is currently a noop because we - don't reuse context values. Perhaps we - should? */ - + drm_ctxbitmap_free(dev, ctx.handle); + return 0; } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c index 57c1c719d..d8fef9538 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c @@ -1,8 +1,8 @@ /* tdfx.c -- tdfx driver -*- linux-c -*- * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com - * Revised: Tue Oct 12 08:51:35 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,9 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c,v 1.3 2000/02/23 04:47:31 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> + * Daryll Strauss <daryll@valinux.com> * */ @@ -37,9 +39,9 @@ EXPORT_SYMBOL(tdfx_cleanup); #define TDFX_NAME "tdfx" #define TDFX_DESC "tdfx" #define TDFX_DATE "19991009" -#define TDFX_MAJOR 0 +#define TDFX_MAJOR 1 #define TDFX_MINOR 0 -#define TDFX_PATCHLEVEL 1 +#define TDFX_PATCHLEVEL 0 static drm_device_t tdfx_device; drm_ctx_t tdfx_res_ctx; @@ -85,6 +87,16 @@ static drm_ioctl_desc_t tdfx_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { tdfx_lock, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { tdfx_unlock, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 }, +#ifdef DRM_AGP + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_unbind, 1, 1}, + [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_bind, 1, 1}, +#endif }; #define TDFX_IOCTL_COUNT DRM_ARRAY_SIZE(tdfx_ioctls) @@ -228,7 +240,24 @@ static int tdfx_takedown(drm_device_t *dev) } dev->magiclist[i].head = dev->magiclist[i].tail = NULL; } - +#ifdef DRM_AGP + /* Clear AGP information */ + if (dev->agp) { + drm_agp_mem_t *temp; + drm_agp_mem_t *temp_next; + + temp = dev->agp->memory; + while(temp != NULL) { + temp_next = temp->next; + drm_free_agp(temp->memory, temp->pages); + drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS); + temp = temp_next; + } + if(dev->agp->acquired) (*drm_agp.release)(); + drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); + dev->agp = NULL; + } +#endif /* Clear vma list (only built for debugging) */ if (dev->vmalist) { for (vma = dev->vmalist; vma; vma = vma_next) { @@ -262,6 +291,10 @@ static int tdfx_takedown(drm_device_t *dev) - PAGE_SHIFT, DRM_MEM_SAREA); break; + case _DRM_AGP: + /* Do nothing here, because this is all + handled in the AGP/GART driver. */ + break; } drm_free(map, sizeof(*map), DRM_MEM_MAPS); } @@ -309,6 +342,16 @@ int tdfx_init(void) drm_mem_init(); drm_proc_init(dev); +#ifdef DRM_AGP + dev->agp = drm_agp_init(); +#endif + if((retcode = drm_ctxbitmap_init(dev))) { + DRM_ERROR("Cannot allocate memory for context bitmap.\n"); + drm_proc_cleanup(); + misc_deregister(&tdfx_misc); + tdfx_takedown(dev); + return retcode; + } DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", TDFX_NAME, @@ -335,6 +378,7 @@ void tdfx_cleanup(void) } else { DRM_INFO("Module unloaded\n"); } + drm_ctxbitmap_cleanup(dev); tdfx_takedown(dev); } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h index 3866010a8..6b1c208ef 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h @@ -1,8 +1,8 @@ /* tdfx_drv.h -- Private header for tdfx driver -*- linux-c -*- * Created: Thu Oct 7 10:40:04 1999 by faith@precisioninsight.com - * Revised: Sat Oct 9 23:38:19 1999 by faith@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,6 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h,v 1.2 2000/02/23 04:47:31 martin Exp $ * */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c index 85470ac52..0b2b00e0a 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c @@ -1,8 +1,8 @@ /* vm.c -- Memory mapping for DRM -*- linux-c -*- * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com - * Revised: Mon Feb 14 00:16:45 2000 by kevin@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,7 +24,8 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c,v 1.5 2000/02/23 04:47:31 martin Exp $ + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * */ @@ -246,13 +247,26 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma) /* Check for valid size. */ if (map->size != vma->vm_end - vma->vm_start) return -EINVAL; + if (!capable(CAP_SYS_ADMIN) && (map->flags & _DRM_READ_ONLY)) { + vma->vm_flags &= VM_MAYWRITE; +#if defined(__i386__) + pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW; +#else + /* Ye gads this is ugly. With more thought + we could move this up higher and use + `protection_map' instead. */ + vma->vm_page_prot = __pgprot(pte_val(pte_wrprotect( + __pte(pgprot_val(vma->vm_page_prot))))); +#endif + } switch (map->type) { case _DRM_FRAME_BUFFER: case _DRM_REGISTERS: + case _DRM_AGP: if (VM_OFFSET(vma) >= __pa(high_memory)) { #if defined(__i386__) - if (boot_cpu_data.x86 > 3) { + if (boot_cpu_data.x86 > 3 && map->type != _DRM_AGP) { pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; pgprot_val(vma->vm_page_prot) &= ~_PAGE_PWT; } @@ -264,6 +278,10 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma) vma->vm_end - vma->vm_start, vma->vm_page_prot)) return -EAGAIN; + DRM_DEBUG(" Type = %d; start = 0x%lx, end = 0x%lx," + " offset = 0x%lx\n", + map->type, + vma->vm_start, vma->vm_end, VM_OFFSET(vma)); vma->vm_ops = &drm_vm_ops; break; case _DRM_SHM: @@ -276,19 +294,7 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma) return -EINVAL; /* This should never happen. */ } vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */ - if (map->flags & _DRM_READ_ONLY) { -#if defined(__i386__) - pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW; -#else - /* Ye gads this is ugly. With more thought - we could move this up higher and use - `protection_map' instead. */ - vma->vm_page_prot = __pgprot(pte_val(pte_wrprotect( - __pte(pgprot_val(vma->vm_page_prot))))); -#endif - } - #if LINUX_VERSION_CODE < 0x020203 /* KERNEL_VERSION(2,2,3) */ /* In Linux 2.2.3 and above, this is handled in do_mmap() in mm/mmap.c. */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c index 3b0f98acd..1174a0fa2 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c @@ -1,8 +1,8 @@ /* xf86drm.c -- User-level interface to DRM device * Created: Tue Jan 5 08:16:21 1999 by faith@precisioninsight.com - * Revised: Sun Feb 13 23:43:32 2000 by kevin@precisioninsight.com * * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -24,6 +24,9 @@ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * + * Authors: Rickard E. (Rik) Faith <faith@valinux.com> + * Kevin E. Martin <martin@valinux.com> + * * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v 1.10 2000/02/23 04:47:23 martin Exp $ * */ @@ -70,10 +73,23 @@ extern int xf86RemoveSIGIOHandler(int fd); #define MAP_FAILED ((void *)-1) #endif -#include <sys/sysmacros.h> /* for makedev() */ #include "xf86drm.h" #include "drm.h" +#define DRM_FIXED_DEVICE_MAJOR 145 + +#ifdef __linux__ +#include <sys/sysmacros.h> /* for makedev() */ +#endif + +#ifndef makedev + /* This definition needs to be changed on + some systems if dev_t is a structure. + If there is a header file we can get it + from, there would be best. */ +#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) +#endif + static void *drmHashTable = NULL; /* Context switch callbacks */ typedef struct drmHashEntry { @@ -94,9 +110,16 @@ void drmFree(void *pt) if (pt) _DRM_FREE(pt); } +/* drmStrdup can't use strdup(3), since it doesn't call _DRM_MALLOC... */ static char *drmStrdup(const char *s) { - return s ? strdup(s) : NULL; + char *retval = NULL; + + if (s) { + retval = _DRM_MALLOC(strlen(s)+1); + strcpy(retval, s); + } + return retval; } @@ -133,7 +156,7 @@ static drmHashEntry *drmGetEntry(int fd) return entry; } -/* drm_open is used to open the /dev/drm device */ +/* drm_open is used to open the /dev/dri device */ static int drm_open(const char *file) { @@ -143,14 +166,6 @@ static int drm_open(const char *file) return -errno; } -/* drmAvailable looks for /proc/drm, and returns 1 if it is present. */ - -int drmAvailable(void) -{ - if (!access("/proc/dri/0", R_OK)) return 1; - return 0; -} - static int drmOpenDevice(const char *path, long dev, mode_t mode, uid_t user, gid_t group) { @@ -160,7 +175,16 @@ static int drmOpenDevice(const char *path, long dev, struct stat st; #endif - if (!stat(path, &st) && st.st_rdev == dev) return drm_open(path); + /* Fiddle mode to remove execute bits */ + mode &= ~(S_IXUSR|S_IXGRP|S_IXOTH); + + if (!stat(path, &st) && st.st_rdev == dev) { + if (!geteuid()) { + chown(path, user, group); + chmod(path, mode); + } + return drm_open(path); + } if (geteuid()) return DRM_ERR_NOT_ROOT; remove(path); @@ -173,6 +197,38 @@ static int drmOpenDevice(const char *path, long dev, return drm_open(path); } +/* drmAvailable looks for /proc/dri, and returns 1 if it is present. On + OSs that do not have a Linux-like /proc, this information will not be + available, and we'll have to create a device and check if the driver is + loaded that way. */ + +int drmAvailable(void) +{ + char dev_name[64]; + drmVersionPtr version; + int retval = 0; + int fd; + + if (!access("/proc/dri/0", R_OK)) return 1; + + sprintf(dev_name, "/dev/dri-temp-%d", getpid()); + + remove(dev_name); + if ((fd = drmOpenDevice(dev_name, makedev(DRM_FIXED_DEVICE_MAJOR, 0), + S_IRUSR, geteuid(), getegid())) >= 0) { + /* Read version to make sure this is + actually a DRI device. */ + if ((version = drmGetVersion(fd))) { + retval = 1; + drmFreeVersion(version); + } + close(fd); + } + remove(dev_name); + + return retval; +} + static int drmOpenByBusid(const char *busid) { int i; @@ -217,6 +273,20 @@ static int drmOpenByName(const char *name) group = xf86ConfigDRI.group ? xf86ConfigDRI.group : DRM_DEV_GID; #endif +#if defined(XFree86Server) + if (!drmAvailable()) { + /* try to load the kernel module now */ + if (!xf86LoadKernelModule(name)) { + ErrorF("[drm] failed to load kernel module \"%s\"\n", + name); + return -1; + } + } +#else + if (!drmAvailable()) + return -1; +#endif + if (!geteuid()) { dirmode = mode; if (dirmode & S_IRUSR) dirmode |= S_IXUSR; @@ -253,7 +323,24 @@ static int drmOpenByName(const char *name) } } } - } else remove(dev_name); + } else { + drmVersionPtr version; + /* /proc/dri not available, possibly + because we aren't on a Linux system. + So, try to create the next device and + see if it's active. */ + dev = makedev(DRM_FIXED_DEVICE_MAJOR, i); + if ((fd = drmOpenDevice(dev_name, dev, mode, user, group))) { + if ((version = drmGetVersion(fd))) { + if (!strcmp(version->name, name)) { + drmFreeVersion(version); + return fd; + } + drmFreeVersion(version); + } + } + remove(dev_name); + } } return -1; } @@ -288,7 +375,7 @@ static void drmFreeKernelVersion(drm_version_t *v) drmFree(v); } -static void drmCopyVersion(drmVersionPtr d, drm_version_t *s) +static void drmCopyVersion(drmVersionPtr d, const drm_version_t *s) { d->version_major = s->version_major; d->version_minor = s->version_minor; @@ -302,7 +389,7 @@ static void drmCopyVersion(drmVersionPtr d, drm_version_t *s) } /* drmVersion obtains the version information via an ioctl. Similar - * information is available via /proc/drm. */ + * information is available via /proc/dri. */ drmVersionPtr drmGetVersion(int fd) { @@ -418,7 +505,8 @@ int drmAddMap(int fd, return 0; } -int drmAddBufs(int fd, int count, int size, int flags) +int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags, + int agp_offset) { drm_buf_desc_t request; @@ -427,6 +515,8 @@ int drmAddBufs(int fd, int count, int size, int flags) request.low_mark = 0; request.high_mark = 0; request.flags = flags; + request.agp_start = agp_offset; + if (ioctl(fd, DRM_IOCTL_ADD_BUFS, &request)) return -errno; return request.count; } @@ -744,6 +834,143 @@ int drmDestroyDrawable(int fd, drmDrawable handle) return 0; } +int drmAgpAcquire(int fd) +{ + if (ioctl(fd, DRM_IOCTL_AGP_ACQUIRE, NULL)) return -errno; + return 0; +} + +int drmAgpRelease(int fd) +{ + if (ioctl(fd, DRM_IOCTL_AGP_RELEASE, NULL)) return -errno; + return 0; +} + +int drmAgpEnable(int fd, unsigned long mode) +{ + drm_agp_mode_t m; + + m.mode = mode; + if (ioctl(fd, DRM_IOCTL_AGP_ENABLE, &m)) return -errno; + return 0; +} + +int drmAgpAlloc(int fd, unsigned long size, unsigned long type, + unsigned long *address, unsigned long *handle) +{ + drm_agp_buffer_t b; + *handle = 0; + b.size = size; + b.handle = 0; + b.type = type; + if (ioctl(fd, DRM_IOCTL_AGP_ALLOC, &b)) return -errno; + if (address != 0UL) *address = b.physical; + *handle = b.handle; + return 0; +} + +int drmAgpFree(int fd, unsigned long handle) +{ + drm_agp_buffer_t b; + + b.size = 0; + b.handle = handle; + if (ioctl(fd, DRM_IOCTL_AGP_FREE, &b)) return -errno; + return 0; +} + +int drmAgpBind(int fd, unsigned long handle, unsigned long offset) +{ + drm_agp_binding_t b; + + b.handle = handle; + b.offset = offset; + if (ioctl(fd, DRM_IOCTL_AGP_BIND, &b)) return -errno; + return 0; +} + +int drmAgpUnbind(int fd, unsigned long handle) +{ + drm_agp_binding_t b; + + b.handle = handle; + b.offset = 0; + if (ioctl(fd, DRM_IOCTL_AGP_UNBIND, &b)) return -errno; + return 0; +} + +int drmAgpVersionMajor(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno; + return i.agp_version_major; +} + +int drmAgpVersionMinor(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno; + return i.agp_version_minor; +} + +unsigned long drmAgpGetMode(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + return i.mode; +} + +unsigned long drmAgpBase(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + return i.aperture_base; +} + +unsigned long drmAgpSize(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + return i.aperture_size; +} + +unsigned long drmAgpMemoryUsed(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + return i.memory_used; +} + +unsigned long drmAgpMemoryAvail(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + return i.memory_allowed; +} + +unsigned int drmAgpVendorId(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + return i.id_vendor; +} + +unsigned int drmAgpDeviceId(int fd) +{ + drm_agp_info_t i; + + if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0; + return i.id_device; +} + int drmError(int err, const char *label) { switch (err) { diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c new file mode 100644 index 000000000..e08a3185d --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c @@ -0,0 +1,199 @@ +/* xf86drmR128.c -- User-level interface to Rage 128 DRM device + * Created: Sun Apr 9 18:13:54 2000 by kevin@precisioninsight.com + * + * Copyright 1999, 2000 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, 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 (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 NONINFRINGEMENT. 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. + * + * Author: Kevin E. Martin <kevin@precisioninsight.com> + * + * $XFree86$ + * + */ + +#ifdef XFree86Server +# include "xf86.h" +# include "xf86_OSproc.h" +# include "xf86_ansic.h" +# include "xf86Priv.h" +# define _DRM_MALLOC xalloc +# define _DRM_FREE xfree +# ifndef XFree86LOADER +# include <sys/stat.h> +# include <sys/mman.h> +# endif +#else +# include <stdio.h> +# include <stdlib.h> +# include <unistd.h> +# include <string.h> +# include <ctype.h> +# include <fcntl.h> +# include <errno.h> +# include <signal.h> +# include <sys/types.h> +# include <sys/stat.h> +# include <sys/ioctl.h> +# include <sys/mman.h> +# include <sys/time.h> +# ifdef DRM_USE_MALLOC +# define _DRM_MALLOC malloc +# define _DRM_FREE free +extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *); +extern int xf86RemoveSIGIOHandler(int fd); +# else +# include <Xlibint.h> +# define _DRM_MALLOC Xmalloc +# define _DRM_FREE Xfree +# endif +#endif + +/* Not all systems have MAP_FAILED defined */ +#ifndef MAP_FAILED +#define MAP_FAILED ((void *)-1) +#endif + +#include <sys/sysmacros.h> /* for makedev() */ +#include "xf86drm.h" +#include "xf86drmR128.h" +#include "drm.h" + +int drmR128InitCCE(int fd, drmR128Init *info) +{ + drm_r128_init_t init; + + memset(&init, 0, sizeof(drm_r128_init_t)); + + init.func = R128_INIT_CCE; + init.sarea_priv_offset = info->sarea_priv_offset; + init.is_pci = info->is_pci; + init.cce_mode = info->cce_mode; + init.cce_fifo_size = info->cce_fifo_size; + init.cce_secure = info->cce_secure; + init.ring_size = info->ring_size; + init.usec_timeout = info->usec_timeout; + + init.fb_offset = info->fb_offset; + init.agp_ring_offset = info->agp_ring_offset; + init.agp_read_ptr_offset = info->agp_read_ptr_offset; + init.agp_vertbufs_offset = info->agp_vertbufs_offset; + init.agp_indbufs_offset = info->agp_indbufs_offset; + init.agp_textures_offset = info->agp_textures_offset; + init.mmio_offset = info->mmio_offset; + + if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno; + + return 0; +} + +int drmR128CleanupCCE(int fd) +{ + drm_r128_init_t init; + + memset(&init, 0, sizeof(drm_r128_init_t)); + + init.func = R128_CLEANUP_CCE; + + if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno; + + return 0; +} + +int drmR128EngineReset(int fd) +{ + if (ioctl(fd, DRM_IOCTL_R128_RESET, NULL)) return -errno; + + return 0; +} + +int drmR128EngineFlush(int fd) +{ + if (ioctl(fd, DRM_IOCTL_R128_FLUSH, NULL)) return -errno; + + return 0; +} + +int drmR128WaitForIdle(int fd) +{ + if (ioctl(fd, DRM_IOCTL_R128_IDLE, NULL)) return -errno; + + return 0; +} + +int drmR128SubmitPacket(int fd, CARD32 *buffer, int *count, int flags) +{ + drm_r128_packet_t packet; + int ret; + + memset(&packet, 0, sizeof(drm_r128_packet_t)); + + packet.count = *count; + packet.flags = flags; + + while (packet.count > 0) { + packet.buffer = buffer + (*count - packet.count); + ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet); + if (ret < 0 && ret != -EAGAIN) { + *count = packet.count; + return -errno; + } + } + + *count = 0; + return 0; +} + +int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes) +{ + drm_r128_vertex_t v; + + v.send_count = 0; + v.send_indices = NULL; + v.send_sizes = NULL; + v.prim = DRM_R128_PRIM_NONE; + v.request_count = count; + v.request_indices = indices; + v.request_sizes = sizes; + v.granted_count = 0; + + if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v)) return -errno; + + return v.granted_count; +} + +int drmR128FlushVertexBuffers(int fd, int count, int *indices, + int *sizes, drmR128PrimType prim) +{ + drm_r128_vertex_t v; + + v.send_count = count; + v.send_indices = indices; + v.send_sizes = sizes; + v.prim = prim; + v.request_count = 0; + v.request_indices = NULL; + v.request_sizes = NULL; + v.granted_count = 0; + + if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v) < 0) return -errno; + + return 0; +} diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h index b2e2a0ac6..56ef48d2c 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h @@ -1,7 +1,8 @@ /* drm.h -- Header for Direct Rendering Manager -*- linux-c -*- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com * - * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. + * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -10,11 +11,11 @@ * 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 (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 NONINFRINGEMENT. IN NO EVENT SHALL @@ -22,8 +23,9 @@ * 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. - * - * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h,v 1.5 2000/02/23 04:47:26 martin Exp $ + * + * Authors: + * Rickard E. (Rik) Faith <faith@valinux.com> * * Acknowledgements: * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg. @@ -60,7 +62,7 @@ typedef unsigned int drm_context_t; typedef unsigned int drm_drawable_t; typedef unsigned int drm_magic_t; -/* Warning: If you change this structure, make sure you change +/* Warning: If you change this structure, make sure you change * XF86DRIClipRectRec in the server as well */ typedef struct drm_clip_rect { @@ -356,7 +358,7 @@ typedef struct drm_agp_info { #define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t) #define DRM_IOCTL_R128_RESET DRM_IO( 0x41) #define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42) -#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43) +#define DRM_IOCTL_R128_IDLE DRM_IO( 0x43) #define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t) #define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c index fc08cb51a..14a8c9f5a 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c @@ -1361,6 +1361,18 @@ xf86geteuid(void) return geteuid(); } +xf86gid_t +xf86getegid(void) +{ + return getegid(); +} + +int +xf86getpid(void) +{ + return getpid(); +} + static mode_t xfToOsMknodMode(xf86mode_t xfmode) { diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h index 23389ea39..01e12ec0f 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h @@ -267,6 +267,8 @@ extern long xf86fpossize(void); extern int xf86chmod(const char *, xf86mode_t); extern int xf86chown(const char *, xf86uid_t, xf86gid_t); extern xf86uid_t xf86geteuid(void); +extern xf86gid_t xf86getegid(void); +extern int xf86getpid(void); extern int xf86mknod(const char *, xf86mode_t, xf86dev_t); extern int xf86mkdir(const char *, xf86mode_t); unsigned int xf86sleep(unsigned int seconds); diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h index 321fd3f13..c11c73c48 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h @@ -421,6 +421,10 @@ typedef int xf86key_t; #define chown(a,b,c) xf86chown(a,b,c) #undef geteuid #define geteuid xf86geteuid +#undef getegid +#define getegid xf86getegid +#undef getpid +#define getpid xf86getpid #undef mknod #define mknod(a,b,c) xf86mknod(a,b,c) #undef sleep diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h new file mode 100644 index 000000000..dd430ed87 --- /dev/null +++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h @@ -0,0 +1,80 @@ +/* xf86drm.h -- OS-independent header for DRM user-level library interface + * Created: Sun Apr 9 18:16:28 2000 by kevin@precisioninsight.com + * + * Copyright 1999, 2000 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, 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 (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 NONINFRINGEMENT. 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. + * + * Author: Kevin E. Martin <kevin@precisioninsight.com> + * + * $XFree86$ + * + */ + +#ifndef _XF86DRI_R128_H_ +#define _XF86DRI_R128_H_ + +/* WARNING: If you change any of these defines, make sure to change + * the kernel include file as well (r128_drm.h) + */ + +typedef struct _drmR128Init { + int sarea_priv_offset; + int is_pci; + int cce_mode; + int cce_fifo_size; + int cce_secure; + int ring_size; + int usec_timeout; + + int fb_offset; + int agp_ring_offset; + int agp_read_ptr_offset; + int agp_vertbufs_offset; + int agp_indbufs_offset; + int agp_textures_offset; + int mmio_offset; +} drmR128Init; + +typedef enum { + DRM_R128_PRIM_NONE = 0x0001, + DRM_R128_PRIM_POINT = 0x0002, + DRM_R128_PRIM_LINE = 0x0004, + DRM_R128_PRIM_POLY_LINE = 0x0008, + DRM_R128_PRIM_TRI_LIST = 0x0010, + DRM_R128_PRIM_TRI_FAN = 0x0020, + DRM_R128_PRIM_TRI_STRIP = 0x0040, + DRM_R128_PRIM_TRI_TYPE2 = 0x0080 +} drmR128PrimType; + + +extern int drmR128InitCCE(int fd, drmR128Init *info); +extern int drmR128CleanupCCE(int fd); +extern int drmR128EngineReset(int fd); +extern int drmR128EngineFlush(int fd); +extern int drmR128WaitForIdle(int fd); +extern int drmR128SubmitPacket(int fd, CARD32 *buffer, int *count, int flags); +extern int drmR128GetVertexBuffers(int fd, int count, int *indices, + int *sizes); +extern int drmR128FlushVertexBuffers(int fd, int count, int *indices, + int *sizes, drmR128PrimType prim); + +#endif |